示例#1
0
    def update(self, record, library=None):
        """
        Changes the last_updated of a legfiles feed to most recent intro date.

        Iterate through each item (page) in the feed (book) and check when it
        was last updated.  Be careful and don't use this as a matter of normal
        course; it may be slow.
        """
        if library is None:
            library = FeedLibrary()

        feed = library.get_feed(record)

        all_content = feed.get_content()
        latest = None
        if all_content:
            latest = feed.get_last_updated_time()

        if latest is None:
            latest = datetime.min

        record.last_updated = latest
        record.save()
示例#2
0
    def __init__(self, url):
        self.url = url

    def get_content(self):
        import feedparser
        self.rss = feedparser.parse(self.url)
        return self.rss.entries

    def get_last_updated_time(self):
        from dateutil.parser import parse
        updated_time = parse(self.rss['updated'])
        return updated_time

    def get_updated_since(self, previous):
        from dateutil.parser import parse
        entries = self.get_content()
        return [entry for entry in entries if parse(entry.published) > previous]

    def get_changes_to(self, entry, since):
        """
        Returns a dictionary representing the changes to the item.  The nature
        of this dictionary may vary depending on the item type.
        """
        from dateutil.parser import parse
        return entry, parse(entry.published)


from subscriptions.feeds.library import FeedLibrary
library = FeedLibrary()
library.register(RSSFeedReader, 'rss')