From 56a5eca57641038b7c62b2147c624fcdd3121f0f 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 | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/dlfp/backend.py b/modules/dlfp/backend.py index 1da716bf..a0874ab4 100644 --- a/modules/dlfp/backend.py +++ b/modules/dlfp/backend.py @@ -108,7 +108,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) if thread.date: diff --git a/modules/dlfp/browser.py b/modules/dlfp/browser.py index a237ae00..bb20ba90 100644 --- a/modules/dlfp/browser.py +++ b/modules/dlfp/browser.py @@ -133,8 +133,11 @@ 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'): + myhash = hashlib.md5(lxml.etree.tostring(self.page.document)).hexdigest() + return myhash + else: + return None def get_content(self, _id): url, _id = self.parse_id(_id)