From ca8edb11b334972c66dddd4db310485443a9d1f3 Mon Sep 17 00:00:00 2001 From: Artem Baguinski Date: Thu, 3 Apr 2008 21:20:20 +0200 Subject: [PATCH] deal with broken url timestamps --- pod.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/pod.py b/pod.py index 2b0bd17..0450d20 100755 --- a/pod.py +++ b/pod.py @@ -3,18 +3,27 @@ from __future__ import with_statement import urllib2 from email.utils import parsedate +import time class Feed: + # consider timestamps earlier then this non-existant + self.reasonable_timestamp = time.strptime("2008", "%Y") + def __init__(self, url): self.url = url - self.timestamp = None # last url timestamp if any - self.watermark = None # ignore episodes older then + # last url timestamp if any + self.timestamp = None + # ignore episodes older then this + self.watermark = time.strptime("03 2008", "%m %Y") def get_remote_timestamp(self): conn = urllib2.urlopen(self.url) try: if 'Last-Modified' in conn.info(): - return parsedate( conn.info()['Last-Modified'] ) + t = time.mktime( parsedate( conn.info()['Last-Modified'] ) ) + if t > self.reasonable_timestamp: + return t + return None finally: conn.close() @@ -40,12 +49,11 @@ def get_updated_feeds(): yield feed def download_episode(url): - print "Download", url + pass dl_queue = [] for feed in get_updated_feeds(): - print "Feed %s updated" % feed.url for url in feed.get_new_episodes(): dl_queue.append(url) # update feed watermark -- 2.11.4.GIT