summaryrefslogtreecommitdiffstats
path: root/module/plugins
diff options
context:
space:
mode:
authorGravatar mkaay <mkaay@mkaay.de> 2011-02-07 20:48:23 +0100
committerGravatar mkaay <mkaay@mkaay.de> 2011-02-07 20:48:23 +0100
commit6c7725cee8f320ae8de087aaf753169f11c907f9 (patch)
tree87a1c1fed1158f44ad43734533705badd829cfc2 /module/plugins
parentcaptchamanager fix (diff)
downloadpyload-6c7725cee8f320ae8de087aaf753169f11c907f9.tar.xz
Ev0InFetcher update (thanks to KurrKurr)
Diffstat (limited to 'module/plugins')
-rw-r--r--module/plugins/PluginStorage.py11
-rw-r--r--module/plugins/hooks/Ev0InFetcher.py35
2 files changed, 30 insertions, 16 deletions
diff --git a/module/plugins/PluginStorage.py b/module/plugins/PluginStorage.py
index 31a3616f4..02498a446 100644
--- a/module/plugins/PluginStorage.py
+++ b/module/plugins/PluginStorage.py
@@ -17,8 +17,13 @@
"""
class PluginStorage():
- def getStorage(self, key, default=None):
- return self.core.files.getStorage(self.__name__, key, default)
+ def getStorage(self, key=None, default=None):
+ if key is not None:
+ return self.core.db.getStorage(self.__name__, key) or default
+ return self.core.db.getStorage(self.__name__, key)
def setStorage(self, key, value):
- self.core.files.setStorage(self.__name__, key, value)
+ self.core.db.setStorage(self.__name__, key, value)
+
+ def delStorage(self, key):
+ self.core.db.delStorage(self.__name__, key)
diff --git a/module/plugins/hooks/Ev0InFetcher.py b/module/plugins/hooks/Ev0InFetcher.py
index 59e1c5462..9b9b11337 100644
--- a/module/plugins/hooks/Ev0InFetcher.py
+++ b/module/plugins/hooks/Ev0InFetcher.py
@@ -36,7 +36,7 @@ class Ev0InFetcher(Hook, PluginStorage):
def setup(self):
self.interval = self.getConfig("interval") * 60
-
+
def filterLinks(self, links):
results = self.core.pluginManager.parseUrls(links)
sortedLinks = {}
@@ -63,16 +63,25 @@ class Ev0InFetcher(Hook, PluginStorage):
shows = [s.strip() for s in self.getConfig("shows").split(",")]
feed = feedparser.parse("http://feeds.feedburner.com/ev0in/%s?format=xml" % self.getConfig("quality"))
- currentTime = time()
- lastCheck = int(self.getStorage("last_check", 0))
-
- for item in feed['items']:
- if mktime(item.date_parsed) > lastCheck:
- for x in shows:
- if x.lower() in normalizefiletitle(item['title']):
- links = self.filterLinks(item['description'].split("<br />"))
- packagename = item['title'].encode("utf-8")
- self.core.log.debug("Ev0InFetcher: new episode %s" % packagename)
- self.core.server_methods.add_package(packagename, links, queue=(1 if self.getConfig("queue") else 0))
- self.setStorage("last_check", int(currentTime))
+
+ showStorage = {}
+ for show in shows:
+ showStorage[show] = int(self.getStorage("show_%s_lastfound" % show, 0))
+ found = False
+ for item in feed['items']:
+ for show, lastfound in showStorage.iteritems():
+ if show.lower() in normalizefiletitle(item['title']) and lastfound < int(mktime(item.date_parsed)):
+ links = self.filterLinks(item['description'].split("<br />"))
+ packagename = item['title'].encode("utf-8")
+ self.core.log.info("Ev0InFetcher: new episode '%s' (matched '%s')" % (packagename, show))
+ self.core.server_methods.add_package(packagename, links, queue=(1 if self.getConfig("queue") else 0))
+ self.setStorage("show_%s_lastfound" % show, int(mktime(item.date_parsed)))
+ found = True
+ if not found:
+ self.core.log.debug("Ev0InFetcher: no new episodes found")
+
+ for show, lastfound in showStorage.iteritems():
+ if lastfound > 0 and lastfound + (3600*24*30) < int(time()):
+ self.delStorage("show_%s_lastfound" % show)
+ self.core.log.debug("Ev0InFetcher: cleaned '%s' record" % show)