diff --git a/modules/dlfp/backend.py b/modules/dlfp/backend.py index a5e040b2..3513890e 100644 --- a/modules/dlfp/backend.py +++ b/modules/dlfp/backend.py @@ -86,6 +86,7 @@ class DLFPBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapContent): continue thread = Thread(article.id) thread.title = article.title + thread._rsscomment = article.rsscomment if article.datetime: thread.date = article.datetime yield thread @@ -97,6 +98,12 @@ class DLFPBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapContent): else: thread = None + oldhash = self.storage.get('hash', id, default="") + newhash = self.browser.get_hash(thread._rsscomment) + if not getseen and oldhash == newhash: + return None + self.storage.set('hash', id, newhash) + self.storage.save() with self.browser: content = self.browser.get_content(id) @@ -138,7 +145,7 @@ class DLFPBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapContent): flags = Message.IS_HTML if not com.id in self.storage.get('seen', parent.thread.id, 'comments', default=[]): flags |= Message.IS_UNREAD - + if getseen or flags & Message.IS_UNREAD: com.parse() message = Message(thread=parent.thread, diff --git a/modules/dlfp/browser.py b/modules/dlfp/browser.py index 1ac86cef..9e55900f 100644 --- a/modules/dlfp/browser.py +++ b/modules/dlfp/browser.py @@ -20,12 +20,14 @@ import urllib import re +import hashlib +import lxml from weboob.tools.browser import BaseBrowser, BrowserHTTPNotFound, BrowserHTTPError, BrowserIncorrectPassword, BrokenPageError from weboob.capabilities.messages import CantSendMessage from .pages.index import IndexPage, LoginPage -from .pages.news import ContentPage, NewCommentPage, NodePage, CommentPage, NewTagPage +from .pages.news import ContentPage, NewCommentPage, NodePage, CommentPage, NewTagPage, RSSComment from .pages.board import BoardIndexPage from .pages.wiki import WikiEditPage from .tools import id2url, url2id @@ -50,6 +52,7 @@ class DLFP(BaseBrowser): 'https?://[^/]*linuxfr\.org/nodes/(\d+)/comments': NodePage, 'https?://[^/]*linuxfr\.org/nodes/(\d+)/tags/nouveau': NewTagPage, 'https?://[^/]*linuxfr\.org/board/index.xml': BoardIndexPage, + 'https?://[^/]*linuxfr\.org/nodes/(\d+)/comments.atom': RSSComment, } last_board_msg_id = None @@ -128,6 +131,11 @@ class DLFP(BaseBrowser): elif self.is_on_page(ContentPage): return self.page.get_article().body + def get_hash(self, url): + self.location(url) + myhash = hashlib.md5(lxml.etree.tostring(self.page.document)).hexdigest() + return myhash + def get_content(self, _id): url, _id = self.parse_id(_id) diff --git a/modules/dlfp/pages/news.py b/modules/dlfp/pages/news.py index 02f49983..6945feb7 100644 --- a/modules/dlfp/pages/news.py +++ b/modules/dlfp/pages/news.py @@ -26,6 +26,10 @@ from ..tools import url2id from .index import DLFPPage +class RSSComment(DLFPPage): + def on_loaded(self): + pass + class Content(object): TAGGABLE = False