diff --git a/bumblebee/modules/rss.py b/bumblebee/modules/rss.py index a4d6d89..c2db30b 100644 --- a/bumblebee/modules/rss.py +++ b/bumblebee/modules/rss.py @@ -65,23 +65,25 @@ class Module(bumblebee.engine.Module): engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE, cmd=self._open) engine.input.register_callback(self, button=bumblebee.input.RIGHT_MOUSE, cmd=self._create_newspaper) - self._history = {} + self._history = {'ticker': {}, 'newspaper': {}} self._load_history() def _load_history(self): if os.path.isfile(self.HISTORY_FILENAME): self._history = json.loads(open(self.HISTORY_FILENAME, "r").read()) - def _save_history(self): + def _update_history(self, group): sources = set([i['source'] for i in self._items]) - self._history = dict([[s, [i['title'] for i in self._items if i['source'] == s]] for s in sources]) + self._history[group] = dict([[s, [i['title'] for i in self._items if i['source'] == s]] for s in sources]) + + def _save_history(self): if not os.path.exists(os.path.dirname(self.HISTORY_FILENAME)): os.makedirs(os.path.dirname(self.HISTORY_FILENAME)) open(self.HISTORY_FILENAME, "w").write(json.dumps(self._history)) - def _check_history(self, items): + def _check_history(self, items, group): for i in items: - i['new'] &= not (i['source'] in self._history and i['title'] in self._history[i['source']]) + i['new'] = not (i['source'] in self._history[group] and i['title'] in self._history[group][i['source']]) def _open(self, _): if self._current_item: @@ -118,7 +120,7 @@ class Module(bumblebee.engine.Module): parser = feedparser.parse(url) new_items = [self._create_item(entry, url, parser['feed']['title']) for entry in parser['entries']] # Check history - self._check_history(new_items) + self._check_history(new_items, 'ticker') # Remove the previous items self._items = [i for i in self._items if i['source'] != url] # Add the new items @@ -133,6 +135,7 @@ class Module(bumblebee.engine.Module): self._update_items_from_feed(url) if not self._feeds_to_update: + self._update_history('ticker') self._save_history() if not self._current_item: @@ -221,7 +224,7 @@ class Module(bumblebee.engine.Module): element = "