diff --git a/defaults.py b/defaults.py index 6694d8b..dc7fe15 100644 --- a/defaults.py +++ b/defaults.py @@ -24,7 +24,7 @@ def load_revision(): # Application Settings APP_ID = 'FeedNotifier' APP_NAME = 'Feed Notifier' -APP_VERSION = '2.6' +APP_VERSION = '2.6.1' APP_URL = 'http://www.feednotifier.com/' USER_AGENT = '%s/%s +%s' % (APP_ID, APP_VERSION, APP_URL) DEFAULT_POLLING_INTERVAL = 60 * 15 diff --git a/feeds.py b/feeds.py index ef87bb2..fd5dc37 100644 --- a/feeds.py +++ b/feeds.py @@ -16,7 +16,10 @@ def cmp_timestamp(a, b): def create_id(entry): keys = ['id', 'link', 'title'] - values = tuple(util.get(entry, key, None) for key in keys) + values = list(util.get(entry, key, None) for key in keys) + pubDate_value = util.get_pubDate(entry, None) # Default should be None + values.append(pubDate_value) + values = tuple(values) return values if any(values) else uuid.uuid4().hex class Item(object): @@ -131,9 +134,9 @@ def poll(self, timestamp, filters): self.id_list.append(id) self.id_set.add(id) item = Item(self, id) - item.timestamp = calendar.timegm(util.get(entry, 'date_parsed', time.gmtime())) item.title = util.format(util.get(entry, 'title', ''), settings.POPUP_TITLE_LENGTH) item.description = util.format(util.get(entry, 'description', ''), settings.POPUP_BODY_LENGTH) + item.timestamp = util.get_pubDate(entry, time.gmtime())# Default should be current time item.link = util.get(entry, 'link', '') item.author = util.format(util.get(entry, 'author', '')) # TODO: max length if all(filter.filter(item) for filter in filters): @@ -272,4 +275,4 @@ def clear_feed_cache(self): logging.info('Clearing feed caches') for feed in self.feeds: feed.clear_cache() - \ No newline at end of file + diff --git a/setup.py b/setup.py index 53866ed..e22ca64 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ name="Feed Notifier" type="win32" /> - Feed Notifier 2.6 + Feed Notifier 2.6.1 diff --git a/util.py b/util.py index 61ff2a5..250c09a 100644 --- a/util.py +++ b/util.py @@ -2,6 +2,7 @@ import os import re import time +import calendar import base64 import calendar import urllib2 @@ -70,7 +71,15 @@ def get_top_window(window): def get(obj, key, default): value = obj.get(key, None) return value or default - + +def get_pubDate(obj, default): + value = get(obj, 'published_parsed', None) + if value == None: + value = get(obj, 'updated_parsed', default)# Default None for create_id , Default current_time for timestamp + if not value == None : + value = calendar.timegm(value) + return value or default + def abspath(path): path = os.path.abspath(path) path = 'file:///%s' % path.replace('\\', '/') @@ -143,7 +152,7 @@ def guess_polling_interval(entries): return settings.DEFAULT_POLLING_INTERVAL timestamps = [] for entry in entries: - timestamp = calendar.timegm(get(entry, 'date_parsed', time.gmtime())) + timestamp = calendar.timegm(get(entry, 'published_parsed', time.gmtime())) timestamps.append(timestamp) timestamps.sort() durations = [b - a for a, b in zip(timestamps, timestamps[1:])] @@ -260,4 +269,4 @@ def format(text, max_length=400): text.append('[...]') text = ' '.join(text) return text - \ No newline at end of file +