Fix Inoreader sub sync with duplicate names
authorJack Miller <jack@codezen.org>
Thu, 18 Jun 2015 15:09:27 +0000 (10:09 -0500)
committerJack Miller <jack@codezen.org>
Thu, 18 Jun 2015 15:09:27 +0000 (10:09 -0500)
plugins/sync-inoreader.py

index 9cc2d0a..439f003 100644 (file)
@@ -453,6 +453,16 @@ def on_daemon_serving():
     log.debug("Synchronizing subscriptions.")
     ino_subs = api.get_subs()
 
+    for c_feed in config.json["feeds"]:
+        url = c_feed["url"]
+
+        for sub in ino_subs:
+            if sub["url"] == url:
+                break
+        else:
+            log.debug("Old feed: %s", url)
+            call_hook("daemon_del_configs", [ None, { "feeds" : [ c_feed ] } ] )
+
     for sub in ino_subs:
         url = sub["url"]
         name = sub["title"]
@@ -460,18 +470,12 @@ def on_daemon_serving():
         for c_feed in config.json["feeds"]:
             if c_feed["url"] == url:
                 break
+            if c_feed["name"] == name:
+                log.info("Found feed with same name, but not URL? Skipping.")
+                break
         else:
             log.debug("New feed: %s", url)
             call_hook("daemon_set_configs", [ None, { "feeds" : [ { "name" : name, "url" : url } ] } ])
 
-    for c_feed in config.json["feeds"]:
-        url = c_feed["url"]
-
-        for sub in ino_subs:
-            if sub["url"] == url:
-                break
-        else:
-            log.debug("Old feed: %s", url)
-            call_hook("daemon_del_configs", [ None, { "feeds" : [ c_feed ] } ] )
 
 on_hook("daemon_serving", on_daemon_serving)