A more solid id and article merging. - zs - Zeitungsschau rss to email converter
       
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
 (DIR) commit a6344904fc25294ad3a3e8c15b8db1c2815e5c8b
 (DIR) parent 0de453a0f79eb0c1ea0f98a23d365a3394131e39
 (HTM) Author: Christoph Lohmann <20h@r-36.net>
       Date:   Sun,  9 Mar 2014 21:27:56 +0100
       
       A more solid id and article merging.
       
       Diffstat:
         feed.py                             |      15 +++++++++++----
         feeddb.py                           |      11 ++++++++---
       
       2 files changed, 19 insertions(+), 7 deletions(-)
       ---
 (DIR) diff --git a/feed.py b/feed.py
       @@ -106,10 +106,6 @@ def parse(astr):
                                elif hasattr(entry, "source"):
                                        article["link"] = str(entry.source)
        
       -                        # id
       -                        if hasattr(entry, "id"):
       -                                article["id"] = str(entry["id"])
       -
                                # enclosure
                                if hasattr(entry, "enclosure"):
                                        if "href" in entry.enclosure.attrib:
       @@ -156,6 +152,17 @@ def parse(astr):
                                elif hasattr(entry, "description"):
                                        article["text"] = str(entry.description)
        
       +                        # id
       +                        if hasattr(entry, "id"):
       +                                article["id"] = str(entry["id"])
       +                        else:
       +                                if "link" in article:
       +                                        article["id"] = article["link"]
       +                                elif "file" in article:
       +                                        article["id"] = article["file"]
       +                                else:
       +                                        article["id"] = article["text"][:30]
       +
                                articles.append(article)
                feed["articles"] = articles
        
 (DIR) diff --git a/feeddb.py b/feeddb.py
       @@ -134,7 +134,9 @@ class feeddb(object):
        
                        history = feed["articles"]
                        for article in curfeed["articles"]:
       -                        if not article in history:
       +                        a = [art for art in history if art["id"] == \
       +                                article["id"]]
       +                        if len(a) == 0:
                                        article["unread"] = True
                                        history.append(article)
                                        rarticles.append(article)
       @@ -175,8 +177,11 @@ class feeddb(object):
                                return
        
                        for article in curfeed["articles"]:
       -                        if article in feed["articles"]:
       -                                article["unread"] == False
       +                        a = [art for art in history if art["id"] == \
       +                                article["id"]]
       +                        if len(a) > 0:
       +                                for aa in a:
       +                                        a["unread"] = False:
                        self.writefeed(uri, feed);
        
                def resetarticles(self, uri):