From 4a5456b152f4e6c018fce2f0fb100bce02d80a54 Mon Sep 17 00:00:00 2001 From: Florent Date: Tue, 20 Mar 2012 14:38:49 +0100 Subject: [PATCH] Don't get page with 0 comment --- modules/dlfp/backend.py | 2 +- modules/dlfp/browser.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/dlfp/backend.py b/modules/dlfp/backend.py index 7acdd0ef..37eab6e4 100644 --- a/modules/dlfp/backend.py +++ b/modules/dlfp/backend.py @@ -101,7 +101,7 @@ class DLFPBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapContent): # Check if we have seen all comments of this thread. oldhash = self.storage.get('hash', id, default="") newhash = self.browser.get_hash(thread._rsscomment) - if not getseen and oldhash == newhash: + if not getseen and (oldhash == newhash or newhash is None): return None self.storage.set('hash', id, newhash) self.storage.save() diff --git a/modules/dlfp/browser.py b/modules/dlfp/browser.py index 9e55900f..0f0160d8 100644 --- a/modules/dlfp/browser.py +++ b/modules/dlfp/browser.py @@ -133,8 +133,10 @@ class DLFP(BaseBrowser): def get_hash(self, url): self.location(url) - myhash = hashlib.md5(lxml.etree.tostring(self.page.document)).hexdigest() - return myhash + if self.page.document.xpath('//entry'): + return hashlib.md5(lxml.etree.tostring(self.page.document)).hexdigest() + else: + return None def get_content(self, _id): url, _id = self.parse_id(_id)