backend newsfeed version is 0.3 (conforming to weboob version)

This commit is contained in:
Romain Bignon 2010-10-16 18:58:54 +02:00
commit fe39601810
3 changed files with 15 additions and 19 deletions

View file

@ -44,7 +44,7 @@ class DLFPBackend(BaseBackend, ICapMessages, ICapMessagesPost):
BROWSER = DLFP
RSS_TELEGRAMS= "https://linuxfr.org/backend/journaux/rss20.rss"
RSS_NEWSPAPERS = "https://linuxfr.org/backend/news/rss20.rss"
def create_default_browser(self):
return self.create_browser(self.config['username'], self.config['password'])
@ -55,7 +55,7 @@ class DLFPBackend(BaseBackend, ICapMessages, ICapMessagesPost):
whats.add(self.RSS_NEWSPAPERS)
if self.config['get_telegrams']:
whats.add(self.RSS_TELEGRAMS)
for what in whats:
for article in Newsfeed(what, url2id).iter_entries():

View file

@ -18,29 +18,29 @@
from weboob.tools.backend import BaseBackend
from weboob.capabilities.messages import ICapMessages, Message, Thread
from weboob.tools.newsfeed import Newsfeed
from weboob.tools.newsfeed import Newsfeed
class NewsfeedBackend(BaseBackend, ICapMessages):
NAME = 'newsfeed'
MAINTAINER = u"Clément Schreiner"
EMAIL = "clemux@clemux.info"
VERSION = "0.1"
VERSION = "0.3"
DESCRIPTION = "Loads RSS and Atom feeds from any websites"
LICENSE = "GPLv3"
CONFIG = {'url': BaseBackend.ConfigField(description="Atom/RSS feed's url"),}
STORAGE = {'seen': []}
def iter_threads(self):
for article in Newsfeed(self.config["url"]).iter_entries():
thread = Thread(article.id)
thread.title = article.title
yield thread
def get_thread(self, id):
if isinstance(id, Thread):
@ -68,8 +68,8 @@ class NewsfeedBackend(BaseBackend, ICapMessages):
children=[],
flags=flags)
return thread
def iter_unread_messages(self, thread=None):
for thread in self.iter_threads():

View file

@ -19,6 +19,9 @@ import datetime
import feedparser
__all__ = ['Entry', 'Newsfeed']
class Entry:
def __init__(self, entry, url2id=None):
if url2id:
@ -50,7 +53,7 @@ class Entry:
self.summary = entry["summary"]
else:
self.summary = None
self.content = []
if entry.has_key("content"):
for i in entry["content"]:
@ -59,18 +62,12 @@ class Entry:
self.content.append(self.summary)
else:
self.content = None
class Newsfeed:
def __init__(self, url, url2id=None):
self.feed = feedparser.parse(url)
self.url2id = url2id
def iter_entries(self):
for entry in self.feed['entries']:
yield Entry(entry, self.url2id)
@ -79,4 +76,3 @@ class Newsfeed:
for entry in self.feed['entries']:
if entry.id == id:
return Entry(entry, self.url2id)