Ejemplo n.º 1
0
    def get_thread(self, id, entry=None):
        if isinstance(id, Thread):
            thread = id
            id = thread.id
        else:
            thread = Thread(id)

        if entry is None:
            entry = Newsfeed(self.config['url'].get()).get_entry(id)
        if entry is None:
            return None

        flags = Message.IS_HTML
        if thread.id not in self.storage.get('seen', default=[]):
            flags |= Message.IS_UNREAD
        if len(entry.content) > 0:
            content = u"<p>Link %s</p> %s" % (entry.link, entry.content[0])
        else:
            content = entry.link

        thread.title = entry.title
        thread.root = Message(thread=thread,
                              id=0,
                              title=entry.title,
                              sender=entry.author,
                              receivers=None,
                              date=entry.datetime,
                              parent=None,
                              content=content,
                              children=[],
                              flags=flags)
        return thread
Ejemplo n.º 2
0
 def iter_threads(self):
     for article in Newsfeed(self.RSS_FEED,
                             GenericNewspaperModule.RSSID).iter_entries():
         thread = Thread(article.id)
         thread.title = article.title
         thread.date = article.datetime
         yield (thread)
Ejemplo n.º 3
0
    def iter_unread_messages(self):
        with self.browser:
            url = self.browser.get_root_feed_url()
            for article in Newsfeed(url, rssid).iter_entries():
                id = url2id(article.link)
                thread = None

                try:
                    last_seen_id = self.storage.get('seen',
                                                    default={})[id2topic(id)]
                except KeyError:
                    last_seen_id = 0

                child = None
                iterator = self.browser.riter_posts(id, last_seen_id)
                if self.config['thread_unread_messages'].get() > 0:
                    iterator = limit(
                        iterator, self.config['thread_unread_messages'].get())
                for post in iterator:
                    if not thread:
                        thread = Thread('%s.%s' %
                                        (post.forum_id, post.topic_id))
                    message = self._post2message(thread, post)

                    if child:
                        message.children.append(child)
                        child.parent = message

                    if post.parent:
                        message.parent = Message(thread=thread, id=post.parent)
                    else:
                        thread.root = message
                    yield message
Ejemplo n.º 4
0
    def iter_threads(self):
        whats = set()
        for param, url in self.FEEDS.iteritems():
            if self.config[param].get():
                whats.add(url)

        for what in whats:
            for article in Newsfeed(what, rssid).iter_entries():
                if article.datetime and (datetime.now() - article.datetime) > timedelta(days=60):
                    continue
                thread = Thread(article.id, article.link)
                thread.title = article.title
                thread._rsscomment = article.rsscomment
                if article.datetime:
                    thread.date = article.datetime
                yield thread
Ejemplo n.º 5
0
 def iter_threads(self):
     daily = []
     for article in Newsfeed(self.RSS_FEED, self.RSSID).iter_entries():
         if "/news-brief/" in article.link:
             day = self.browser.get_daily_date(article.link)
             if day and (day not in daily):
                 localid = url2id(article.link)
                 daily.append(day)
                 id, title, date = self.browser.get_daily_infos(day)
                 id = id + "#" + localid
                 thread = Thread(id)
                 thread.title = title
                 thread.date = date
                 yield (thread)
             elif day is None:
                 thread = Thread(article.link)
                 thread.title = article.title
                 thread.date = article.datetime
                 yield (thread)
         else:
             thread = Thread(article.link)
             thread.title = article.title
             thread.date = article.datetime
             yield (thread)
Ejemplo n.º 6
0
 def iter_threads(self):
     for article in Newsfeed(self.config['url'].get()).iter_entries():
         yield self.get_thread(article.id, article)
Ejemplo n.º 7
0
 def iter_threads(self):
     for article in Newsfeed(self.RSS_FEED, self.RSSID).iter_entries():
         thread = Thread(article.link)
         thread.title = article.title
         thread.date = article.datetime
         yield (thread)