My first standalone Python script.
by Jeffrey Paul
Clocking in at a heavyweight 27 whole lines, I present housedl.py:
#!/usr/bin/python
#^34567891123456789212345678931234567894123456789512345678961234567897123456789$
import feedparser, datetime, time, pickle, os, urllib, os.path
dlto = '/home/sneak/rt/tfiles/'
url = 'http://www.ezrss.it/search/index.php?show_name=House&' + \
'show_name_exact=true&date=&quality=720P&release_group=DIMENSION&' + \
'mode=rss'
tsfile = os.environ['HOME'] + '/.housedownload.ts'
try:
lastcheck = pickle.load(open(tsfile))
except:
lastcheck = time.mktime(
datetime.datetime.now().timetuple()
) - (30*86400)
feed = feedparser.parse(url)
list = []
for entry in feed.entries:
dt = datetime.datetime(*entry.updated_parsed[0:6])
ts = time.mktime(dt.timetuple())
if ( ts > lastcheck ):
list.append( [
time.mktime(dt.timetuple()),
entry.enclosures[0].href
] )
for item in list:
fn = dlto + '/%i.torrent' % item[0]
if not os.path.exists(fn):
urllib.urlretrieve(item[1],fn)
lastcheck = time.mktime(datetime.datetime.now().timetuple())
pickle.dump(lastcheck,open(tsfile,"w"))
I never thought I’d say this, but here it is: Perl can go suck it now.
Comments
Happy to see you ditch your false god, but must it be for another?
Nice little script though…