#!/usr/bin/python # image url: http://www.archiecomics.com/pops_shop/dailycomics/image07.gif from time import time, gmtime, strftime def GetImageData (): imgnums = [] todaysDate = gmtime(time())[2] # the date of month, like 19 or 27 for ix in range(todaysDate, todaysDate-7, -1): # last 7 days if ix < 1: break imgnums.append(ix) return imgnums def RssHeader (): print """ Archie Daily Comic http://www.archiecomics.com/pops_shop/dailycomics/dailycomic.html Today's Newspaper Strip """ def RssBody (imginfo): timeNow = gmtime(time()) vtimeNow = [] for tmp in timeNow: vtimeNow.append(tmp) for imgnum in imginfo: vtimeNow[2] = imgnum pubDate = strftime("%a, %d %b %Y 00:00:00 UTC", vtimeNow) print """ Issue %(num)d ]]> http://www.archiecomics.com/pops_shop/dailycomics/dailycomic.html www.archiecomics.com:dailycomics:archie:%(year)d%(month)02d%(num)02d %(pubdate)s """ % { 'num': imgnum, 'year': timeNow[0], \ 'month': timeNow[1], 'pubdate': pubDate } def RssFooter (): print "" def ExpiryTime (): # content expires 12 hours from now return strftime("%a, %d %b %Y %H:%M:%S UTC", gmtime(time() + 43200)) def Main (): print "Content-Type: application/rss+xml" print "Expires: " + ExpiryTime() + "\n" RssHeader() RssBody(GetImageData()) RssFooter() if __name__ == '__main__': Main()