ed1f1ae2ec157ee66aa5c1abca69431646ef977c — Emil Oppeln-Bronikowski 1 year, 23 days ago 6ac28ba
It was terrible idea to write this configuration module like that.

__setitem__ does not work with .append() or any other thing that works
on dicts, so I had to introduce .save() for now to avoid getting stuck
in the weeds.
3 files changed, 22 insertions(+), 13 deletions(-)

M collector.py
M config.py
A feeds.py
M collector.py => collector.py +2 -9
@@ 11,7 11,7 @@ import config
 widgets = [progressbar.Percentage(), progressbar.Bar()]
 
 configuration = config.Application('application')
-feeds = config.Feeds('feeds')
+subscribed_feeds = config.Feeds('feeds')
 
 def parse_feed(feed_uri):
 


@@ 23,14 23,7 @@ def parse_feed(feed_uri):
     return parsed
 
 def feeds():
-
-    return [
-        'http://uncannyjapan.libsyn.com/rss',
-        'https://ted-walker-mb37.squarespace.com/blog?format=rss',
-        'http://feeds.feedburner.com/manuscriptingpodcom',
-        'http://relay.fm/penaddict/feed',
-        'http://feeds.feedburner.com/AnimeWorldOrder',
-    ];
+    return subscribed_feeds['podcasts'].keys()
 
 def extract_media(feed):
     if not feed.entries:

M config.py => config.py +6 -4
@@ 20,9 20,8 @@ class Config:
                 self.configuration = json.load(f)
             self.name = name
         except FileNotFoundError as e:
-            with open(self.filename, 'w') as f:
-                json.dump(self.default, f)
                 self.configuration = self.default
+                self.save()
         except Exception as e:
             raise e
 


@@ 33,18 32,21 @@ class Config:
     def __setitem__(self, key, value):
 
         self.configuration[key] = value
+        self.save()
 
+        return False
+
+    def save(self):
         with open(self.filename, 'w') as f:
             json.dump(self.configuration, f)
             return True
-        return False
 
     def all(self):
         return self.configuration
 
 class Feeds(Config):
 
-    default = {'podcasts': []}
+    default = {'podcasts': {}}
 
 class Application(Config):
 

A feeds.py => feeds.py +14 -0
@@ 0,0 1,14 @@
+import config
+
+subscribed_feeds = config.Feeds('feeds')
+
+def add(feed):
+
+    if feed not in subscribed_feeds['podcasts']:
+        subscribed_feeds['podcasts'][feed] = {'last_checked': None}
+        subscribed_feeds.save()
+        return True
+
+def remove(feed):
+    del subscribed_feeds['podcasts'][feed]
+    subscribed_feeds.save()