diff options
Diffstat (limited to 'module')
-rw-r--r-- | module/FileDatabase.py | 63 | ||||
-rw-r--r-- | module/PluginThread.py | 37 | ||||
-rw-r--r-- | module/ThreadManager.py | 300 | ||||
-rw-r--r-- | module/plugins/Crypter.py | 3 | ||||
-rw-r--r-- | module/plugins/Hoster.py | 3 | ||||
-rw-r--r-- | module/plugins/Plugin.py | 7 | ||||
-rw-r--r-- | module/plugins/crypter/SerienjunkiesOrg.py | 101 | ||||
-rw-r--r-- | module/plugins/hoster/RapidshareCom.py | 12 | ||||
-rw-r--r-- | module/plugins/hoster/UploadedTo.py | 9 |
9 files changed, 295 insertions, 240 deletions
diff --git a/module/FileDatabase.py b/module/FileDatabase.py index e2b7a47a4..507b5ae7f 100644 --- a/module/FileDatabase.py +++ b/module/FileDatabase.py @@ -81,6 +81,7 @@ class FileHandler: #@TODO: purge the cache self.jobCache = {} + self.noNewInfoJobs = False self.lock = RLock() @@ -132,6 +133,7 @@ class FileHandler: for x in self.core.pluginManager.parseUrls(urls): # tuple of (url, name, plugin, package) lastID = self.db.addLink(x[0], x[0], x[1], package) + self.noNewInfoJobs = False f = self.db.getFile(lastID) e = InsertEvent("file", lastID, f.order, "collector" if not self.getPackage(package).queue else "queue") self.core.pullManager.addEvent(e) @@ -154,7 +156,8 @@ class FileHandler: self.lock.acquire() - e = RemoveEvent("pack", id, "collector" if not self.getPackage(id).queue else "queue") + p = self.getPackage(id) + e = RemoveEvent("pack", id, "collector" if not p.queue else "queue") if self.packageCache.has_key(id): del self.packageCache[id] @@ -166,7 +169,7 @@ class FileHandler: pyfile.abortDownload() pyfile.release() - self.db.deletePackage(id) + self.db.deletePackage(p) self.core.pullManager.addEvent(e) self.lock.release() @@ -178,7 +181,8 @@ class FileHandler: self.lock.acquire() - e = RemoveEvent("file", id, "collector" if not self.getFile(id).package().queue else "queue") + f = self.getFile(id) + e = RemoveEvent("file", id, "collector" if not f.package().queue else "queue") if self.cache.has_key(id): if id in self.core.threadManager.processingIds(): @@ -186,7 +190,7 @@ class FileHandler: self.lock.release() - self.db.deleteLink(id) + self.db.deleteLink(f) self.core.pullManager.addEvent(e) @@ -250,7 +254,7 @@ class FileHandler: """returns dict with file information""" pyfile = self.getFile(id) - return pyfile.toDbDict() + return pyfile.toDbDict() if pyfile else {} #---------------------------------------------------------------------- def getFile(self, id): @@ -304,6 +308,14 @@ class FileHandler: self.lock.release() return pyfile + def getInfoJob(self): + if self.noNewInfoJobs: + return None + jobs = self.db.getInfoJob() + if not jobs: + self.noNewInfoJobs = True + return None + return self.getFile(jobs[0]) #---------------------------------------------------------------------- def getFileCount(self): @@ -525,18 +537,16 @@ class FileDatabaseBackend(Thread): return self.c.lastrowid @queue - def deletePackage(self, id): - p = self.getPackage(id) + def deletePackage(self, p): - self.c.execute('DELETE FROM links WHERE package=?', (str(id), )) - self.c.execute('DELETE FROM packages WHERE id=?', (str(id), )) + self.c.execute('DELETE FROM links WHERE package=?', (str(p.id), )) + self.c.execute('DELETE FROM packages WHERE id=?', (str(p.id), )) self.c.execute('UPDATE packages SET packageorder=packageorder-1 WHERE packageorder > ? AND queue=?', ( p.order, p.queue) ) @queue - def deleteLink(self, id): - f = self.getFile(id) + def deleteLink(self, f): - self.c.execute('DELETE FROM links WHERE id=?', (str(id), )) + self.c.execute('DELETE FROM links WHERE id=?', (str(f.id), )) self.c.execute('UPDATE links SET linkorder=linkorder-1 WHERE linkorder > ? AND package=?', ( f.order, str(f.packageid)) ) @@ -554,7 +564,7 @@ class FileDatabaseBackend(Thread): } """ - self.c.execute('SELECT l.id,l.url,l.name,l.size,l.status,l.error,l.plugin,l.package,l.linkorder FROM links as l INNER JOIN packages as p ON l.package=p.id WHERE p.queue=? ORDER BY p.packageorder, l.linkorder', (q, )) + self.c.execute('SELECT l.id,l.url,l.name,l.size,l.status,l.error,l.plugin,l.package,l.linkorder FROM links as l INNER JOIN packages as p ON l.package=p.id WHERE p.queue=? ORDER BY l.linkorder', (q, )) data = {} for r in self.c: data[str(r[0])] = { @@ -707,7 +717,18 @@ class FileDatabaseBackend(Thread): cmd += ")" - cmd = "SELECT l.id FROM links as l INNER JOIN packages as p ON l.package=p.id WHERE p.queue=1 AND l.plugin NOT IN %s AND l.status IN (2,3,6) Order BY p.packageorder, l.linkorder LIMIT 5" % cmd + cmd = "SELECT l.id FROM links as l INNER JOIN packages as p ON l.package=p.id WHERE p.queue=1 AND l.plugin NOT IN %s AND l.status IN (2,3,6) ORDER BY p.packageorder, l.linkorder LIMIT 5" % cmd + + self.c.execute(cmd) # very bad! + + return [x[0] for x in self.c ] + + + @queue + def getInfoJob(self): + """return pyfile instance, which is suitable for info grabbing""" + + cmd = "SELECT l.id FROM links as l INNER JOIN packages as p ON l.package=p.id WHERE l.url = l.name ORDER BY l.linkorder LIMIT 5" self.c.execute(cmd) # very bad! @@ -756,7 +777,7 @@ class PyFile(): def setStatus(self, status): self.status = statusMap[status] self.sync() #@TODO needed aslong no better job approving exists - + def hasStatus(self, status): return statusMap[status] == self.status @@ -882,6 +903,10 @@ class PyFile(): return self.plugin.req.dl_size except: return 0 + + def notifyChange(self): + e = UpdateEvent("file", self.id, "collector" if not self.package().queue else "queue") + self.m.core.pullManager.addEvent(e) class PyPackage(): def __init__(self, manager, id, name, folder, site, password, queue, order, priority): @@ -923,6 +948,10 @@ class PyPackage(): def getChildren(self): """get information about contained links""" raise NotImplementedError + + def setPriority(self, priority): + self.priority = priority + self.sync() def sync(self): """sync with db""" @@ -935,6 +964,10 @@ class PyPackage(): def delete(self): self.m.deletePackage(self.id) + + def notifyChange(self): + e = UpdateEvent("file", self.id, "collector" if not self.queue else "queue") + self.m.core.pullManager.addEvent(e) if __name__ == "__main__": diff --git a/module/PluginThread.py b/module/PluginThread.py index 35ad796b3..d17f638f0 100644 --- a/module/PluginThread.py +++ b/module/PluginThread.py @@ -263,5 +263,38 @@ class HookThread(PluginThread): self.active.finishIfDone() - -
\ No newline at end of file +######################################################################## +class InfoThread(PluginThread): + + #---------------------------------------------------------------------- + def __init__(self, manager): + """Constructor""" + PluginThread.__init__(self, manager) + + self.queue = Queue() # job queue + self.active = False + + self.start() + + #---------------------------------------------------------------------- + def run(self): + """run method""" + + while True: + self.active = self.queue.get() + if self.active == "quit": + return True + pyfile = self.active + + pyfile.plugin.getInfo() + + #---------------------------------------------------------------------- + def put(self, job): + """assing job to thread""" + self.queue.put(job) + + #---------------------------------------------------------------------- + def stop(self): + """stops the thread""" + self.put("quit") + diff --git a/module/ThreadManager.py b/module/ThreadManager.py index 1db9ea5ba..1e4b8ac2b 100644 --- a/module/ThreadManager.py +++ b/module/ThreadManager.py @@ -30,152 +30,166 @@ import PluginThread ######################################################################## class ThreadManager: - """manages the download threads, assign jobs, reconnect etc""" + """manages the download threads, assign jobs, reconnect etc""" - #---------------------------------------------------------------------- - def __init__(self, core): - """Constructor""" - self.core = core - self.log = core.log - - self.threads = [] # thread list - self.localThreads = [] #hook+decrypter threads - - self.pause = True - - self.reconnecting = Event() - self.reconnecting.clear() - - for i in range(0, self.core.config.get("general","max_downloads") ): - self.createThread() - - - - #---------------------------------------------------------------------- - def createThread(self): - """create a download thread""" - - thread = PluginThread.DownloadThread(self) - self.threads.append(thread) - - #---------------------------------------------------------------------- - def downloadingIds(self): - """get a list of the currently downloading pyfile's ids""" - return [x.active.id for x in self.threads if x.active and x.active != "quit"] - - #---------------------------------------------------------------------- - def processingIds(self): - """get a id list of all pyfiles processed""" - return [x.active.id for x in self.threads+self.localThreads if x.active and x.active != "quit"] - - - #---------------------------------------------------------------------- - def work(self): - """run all task which have to be done (this is for repetivive call by core)""" - - self.tryReconnect() - self.checkThreadCount() - self.assignJob() - - #---------------------------------------------------------------------- - def tryReconnect(self): - """checks if reconnect needed""" - - if not (self.core.server_methods.is_time_reconnect() and self.core.config["reconnect"]["activated"] ): - return False - - active = [x.active.plugin.wantReconnect and x.active.plugin.waiting for x in self.threads if x.active] + #---------------------------------------------------------------------- + def __init__(self, core): + """Constructor""" + self.core = core + self.log = core.log + + self.threads = [] # thread list + self.localThreads = [] #hook+decrypter threads + + self.infoThread = PluginThread.InfoThread(self) + + self.pause = True + + self.reconnecting = Event() + self.reconnecting.clear() + + for i in range(0, self.core.config.get("general","max_downloads") ): + self.createThread() + + + + #---------------------------------------------------------------------- + def createThread(self): + """create a download thread""" + + thread = PluginThread.DownloadThread(self) + self.threads.append(thread) + + #---------------------------------------------------------------------- + def downloadingIds(self): + """get a list of the currently downloading pyfile's ids""" + return [x.active.id for x in self.threads if x.active and x.active != "quit"] + + #---------------------------------------------------------------------- + def processingIds(self): + """get a id list of all pyfiles processed""" + return [x.active.id for x in self.threads+self.localThreads if x.active and x.active != "quit"] + + + #---------------------------------------------------------------------- + def work(self): + """run all task which have to be done (this is for repetivive call by core)""" + + self.tryReconnect() + self.checkThreadCount() + self.assignJob() + + #---------------------------------------------------------------------- + def tryReconnect(self): + """checks if reconnect needed""" + + if not (self.core.server_methods.is_time_reconnect() and self.core.config["reconnect"]["activated"] ): + return False + + active = [x.active.plugin.wantReconnect and x.active.plugin.waiting for x in self.threads if x.active] - if active.count(True) > 0 and len(active) == active.count(True): - - if not exists(self.core.config['reconnect']['method']): - if exists(join(pypath, self.core.config['reconnect']['method'])): - self.core.config['reconnect']['method'] = join(pypath, self.core.config['reconnect']['method']) - else: - self.core.config["reconnect"]["activated"] = False - self.log.warning(_("Reconnect script not found!")) - return - - - self.reconnecting.set() - - #Do reconnect - self.log.info(_("Starting reconnect")) + if active.count(True) > 0 and len(active) == active.count(True): + + if not exists(self.core.config['reconnect']['method']): + if exists(join(pypath, self.core.config['reconnect']['method'])): + self.core.config['reconnect']['method'] = join(pypath, self.core.config['reconnect']['method']) + else: + self.core.config["reconnect"]["activated"] = False + self.log.warning(_("Reconnect script not found!")) + return + + + self.reconnecting.set() + + #Do reconnect + self.log.info(_("Starting reconnect")) - - while [x.active.plugin.waiting for x in self.threads if x.active].count(True) != 0: - sleep(0.25) - - - ip = re.match(".*Current IP Address: (.*)</body>.*", getURL("http://checkip.dyndns.org/")).group(1) - - self.core.hookManager.beforeReconnecting(ip) - reconn = Popen(self.core.config['reconnect']['method'])#, stdout=subprocess.PIPE) - reconn.wait() - sleep(1) - ip = "" - while ip == "": - try: - ip = re.match(".*Current IP Address: (.*)</body>.*", getURL("http://checkip.dyndns.org/")).group(1) #get new ip - except: - ip = "" - sleep(1) - self.core.hookManager.afterReconnecting(ip) - - self.log.info(_("Reconnected, new IP: %s") % ip) - - - self.reconnecting.clear() - - #---------------------------------------------------------------------- - def checkThreadCount(self): - """checks if there are need for increasing or reducing thread count""" - - if len(self.threads) == self.core.config.get("general", "max_downloads"): - return True - elif len(self.threads) < self.core.config.get("general", "max_downloads"): - self.createThread() - else: - #@TODO: close thread - pass - - - #---------------------------------------------------------------------- - def assignJob(self): - """assing a job to a thread if possible""" - - if self.pause: return - - free = [x for x in self.threads if not x.active] + + while [x.active.plugin.waiting for x in self.threads if x.active].count(True) != 0: + sleep(0.25) + + + ip = re.match(".*Current IP Address: (.*)</body>.*", getURL("http://checkip.dyndns.org/")).group(1) + + self.core.hookManager.beforeReconnecting(ip) + reconn = Popen(self.core.config['reconnect']['method'])#, stdout=subprocess.PIPE) + reconn.wait() + sleep(1) + ip = "" + while ip == "": + try: + ip = re.match(".*Current IP Address: (.*)</body>.*", getURL("http://checkip.dyndns.org/")).group(1) #get new ip + except: + ip = "" + sleep(1) + self.core.hookManager.afterReconnecting(ip) + + self.log.info(_("Reconnected, new IP: %s") % ip) + + + self.reconnecting.clear() + + #---------------------------------------------------------------------- + def checkThreadCount(self): + """checks if there are need for increasing or reducing thread count""" + + if len(self.threads) == self.core.config.get("general", "max_downloads"): + return True + elif len(self.threads) < self.core.config.get("general", "max_downloads"): + self.createThread() + else: + #@TODO: close thread + pass + + + #---------------------------------------------------------------------- + def assignJob(self): + """assing a job to a thread if possible""" + + if self.pause: return + + free = [x for x in self.threads if not x.active] - - occ = [x.active.pluginname for x in self.threads if x.active and not x.active.plugin.multiDL ] - occ.sort() - occ = tuple(set(occ)) - job = self.core.files.getJob(occ) - if job: - try: - job.initPlugin() - except Exception, e: - self.log.critical(str(e)) - if self.core.debug: - print_exc() - - if job.plugin.__type__ == "hoster": - if free: - thread = free[0] - thread.put(job) - else: - #put job back - self.core.files.jobCache[occ].append(job.id) - - else: - thread = PluginThread.DecrypterThread(self, job) - - - - - + + occ = [x.active.pluginname for x in self.threads if x.active and not x.active.plugin.multiDL ] + occ.sort() + occ = tuple(set(occ)) + job = self.core.files.getJob(occ) + if job: + try: + job.initPlugin() + except Exception, e: + self.log.critical(str(e)) + if self.core.debug: + print_exc() + + if job.plugin.__type__ == "hoster": + if free: + thread = free[0] + thread.put(job) + else: + #put job back + self.core.files.jobCache[occ].append(job.id) + + else: + thread = PluginThread.DecrypterThread(self, job) + + job = self.core.files.getInfoJob() + if job: + try: + job.initPlugin() + except Exception, e: + self.log.critical(str(e)) + if self.core.debug: + print_exc() + + if job.plugin.__type__ == "hoster": + self.infoThread.put(job) + + + + + + - diff --git a/module/plugins/Crypter.py b/module/plugins/Crypter.py index aaf003063..6d42b9d2c 100644 --- a/module/plugins/Crypter.py +++ b/module/plugins/Crypter.py @@ -59,6 +59,7 @@ class Crypter(Plugin): # replace current package with new one self.pyfile.package().name = pack[0] self.pyfile.package().folder = pack[2] + self.pyfile.package().notifyChange() self.core.files.addLinks(pack[1], self.pyfile.package().id) @@ -67,4 +68,4 @@ class Crypter(Plugin): self.core.server_methods.add_package(pack[0], pack[1]) i += 1 -
\ No newline at end of file + diff --git a/module/plugins/Hoster.py b/module/plugins/Hoster.py index 16c018a99..d4157f1f8 100644 --- a/module/plugins/Hoster.py +++ b/module/plugins/Hoster.py @@ -27,4 +27,7 @@ class Hoster(Plugin): __description__ = """Base hoster plugin""" __author_name__ = ("mkaay") __author_mail__ = ("mkaay@mkaay.de") + + def getInfo(self): + return diff --git a/module/plugins/Plugin.py b/module/plugins/Plugin.py index 8c2a648fd..8392486f1 100644 --- a/module/plugins/Plugin.py +++ b/module/plugins/Plugin.py @@ -232,8 +232,11 @@ class Plugin(object): self.pyfile.setStatus("downloading") download_folder = self.config['general']['download_folder'] - - location = join(download_folder, self.pyfile.package().folder.decode(sys.getfilesystemencoding())) + + if self.config['general']['folder_per_package']: + location = join(download_folder, self.pyfile.package().folder.decode(sys.getfilesystemencoding())) + else: + location = download_folder if not exists(location): makedirs(location) diff --git a/module/plugins/crypter/SerienjunkiesOrg.py b/module/plugins/crypter/SerienjunkiesOrg.py index 6733be2bb..99eaa3f3c 100644 --- a/module/plugins/crypter/SerienjunkiesOrg.py +++ b/module/plugins/crypter/SerienjunkiesOrg.py @@ -2,26 +2,22 @@ import re -from module.plugins.Plugin import Plugin +from module.plugins.Crypter import Crypter from module.BeautifulSoup import BeautifulSoup from module.unescape import unescape -from module.DownloadThread import CaptchaError +from module.plugins.Plugin import Fail -class SerienjunkiesOrg(Plugin): +class SerienjunkiesOrg(Crypter): __name__ = "SerienjunkiesOrg" __type__ = "container" __pattern__ = r"http://.*?serienjunkies.org/.*?" __version__ = "0.2" + __config__ = [ ("preferredHoster", "str", "preferred hoster" , "RapidshareCom,UploadedTo,NetloadIn,FilefactoryCom,RapidshareDe") ] __description__ = """serienjunkies.org Container Plugin""" __author_name__ = ("mkaay") __author_mail__ = ("mkaay@mkaay.de") - def __init__(self, parent): - Plugin.__init__(self, parent) - self.parent = parent - self.html = None - self.multi_dl = False - + def setup(self): self.hosterMap = { "rc": "RapidshareCom", "ff": "FilefactoryCom", @@ -31,43 +27,6 @@ class SerienjunkiesOrg(Plugin): "rs": "RapidshareDe" } self.hosterMapReverse = dict((v,k) for k, v in self.hosterMap.iteritems()) - episodePattern = re.compile("^http://download.serienjunkies.org/f-.*?.html$") - oldStyleLink = re.compile("^http://serienjunkies.org/safe/(.*)$") - if episodePattern.match(self.parent.url) or oldStyleLink.match(self.parent.url): - self.decryptNow = False - else: - self.decryptNow = True - - def prepare(self, thread): - pyfile = self.parent - - self.want_reconnect = False - - pyfile.status.exists = self.file_exists() - - if not pyfile.status.exists: - raise Exception, "File not found" - return False - - pyfile.status.filename = self.get_file_name() - - pyfile.status.waituntil = self.time_plus_wait - pyfile.status.url = self.get_file_url() - pyfile.status.want_reconnect = self.want_reconnect - - thread.wait(self.parent) - - return True - - def get_file_name(self): - showPattern = re.compile("^http://serienjunkies.org/serie/(.*)/$") - seasonPattern = re.compile("^http://serienjunkies.org/.*?/(.*)/$") - m = showPattern.match(self.parent.url) - if not m: - m = seasonPattern.match(self.parent.url) - if m: - return m.group(1) - return "n/a" def getSJSrc(self, url): src = self.req.load(str(url)) @@ -75,16 +34,13 @@ class SerienjunkiesOrg(Plugin): src = self.req.load(str(url)) return src - def file_exists(self): - return True - def handleSeason(self, url): src = self.getSJSrc(url) soup = BeautifulSoup(src) post = soup.find("div", attrs={"class": "post-content"}) ps = post.findAll("p") hosterPattern = re.compile("^http://download\.serienjunkies\.org/f-.*?/([rcfultns]{2})_.*?\.html$") - preferredHoster = self.get_config("preferredHoster").split(",") + preferredHoster = self.getConfig("preferredHoster").split(",") self.logger.debug("Preferred hoster: %s" % ", ".join(preferredHoster)) groups = {} gid = -1 @@ -113,14 +69,13 @@ class SerienjunkiesOrg(Plugin): links2 = p.findAll("a", attrs={"href": re.compile("^http://serienjunkies.org/safe/.*$")}) for link in links1 + links2: groups[gid]["ep"].append(link["href"]) - packages = {} for g in groups.values(): links = [] linklist = g["ep"] package = "%s (%s, %s)" % (seasonName, g["opts"]["Format"], g["opts"]["Sprache"]) linkgroups = {} for link in linklist: - key = re.sub("^http://download\.serienjunkies\.org/f-.*?/([rcfultns]{2})_", "", link) + key = re.sub("^http://download\.serienjunkies\.org/f-.*?/(.{2})_", "", link) if not linkgroups.has_key(key): linkgroups[key] = [] linkgroups[key].append(link) @@ -136,27 +91,26 @@ class SerienjunkiesOrg(Plugin): break if hmatch: break - packages[package] = links - return packages + self.packages.append((package, links, package)) def handleEpisode(self, url): - if not self.parent.core.isGUIConnected(): - raise CaptchaError + if not self.core.isClientConnected(): + raise Fail(_("No Client connected for captcha decrypting.")) for i in range(3): src = self.getSJSrc(url) if not src.find("Du hast das Download-Limit überschritten! Bitte versuche es später nocheinmal.") == -1: - self.logger.info("Downloadlimit reached") + self.log.info(_("Downloadlimit reached")) return False else: soup = BeautifulSoup(src) form = soup.find("form") + packageName = soup.find("h1", attrs={"class":"wrap"}).text captchaTag = soup.find(attrs={"src":re.compile("^/secure/")}) captchaUrl = "http://download.serienjunkies.org"+captchaTag["src"] - captchaData = self.req.load(str(captchaUrl)) - result = self.waitForCaptcha(captchaData, "png") - url = "http://download.serienjunkies.org"+form["action"] + result = self.decryptCaptcha(str(captchaUrl)) sinp = form.find(attrs={"name":"s"}) + self.req.lastUrl = url sj = self.req.load(str(url), post={'s': sinp["value"], 'c': result, 'action': "Download"}) soup = BeautifulSoup(sj) @@ -169,11 +123,12 @@ class SerienjunkiesOrg(Plugin): for link in rawLinks: frameUrl = link["action"].replace("/go-", "/frame/go-") links.append(self.handleFrame(frameUrl)) - return links + self.packages.append((packageName, links, packageName)) + break def handleOldStyleLink(self, url): - if not self.parent.core.isGUIConnected(): - raise CaptchaError + if not self.core.isClientConnected(): + raise Fail(_("No Client connected for captcha decrypting.")) for i in range(3): sj = self.req.load(str(url)) soup = BeautifulSoup(sj) @@ -189,28 +144,26 @@ class SerienjunkiesOrg(Plugin): decrypted = self.req.lastEffectiveURL if decrypted == str(url): continue - return [decrypted] - return False + self.packages.append((self.pyfile.package().name, [decrypted], self.pyfile.package().folder)) def handleFrame(self, url): self.req.load(str(url), cookies=False, just_header=True) return self.req.lastEffectiveURL - def proceed(self, url, location): - links = False + def decrypt(self, pyfile): + showPattern = re.compile("^http://serienjunkies.org/serie/(.*)/$") + seasonPattern = re.compile("^http://serienjunkies.org/.*?/(.*)/$") episodePattern = re.compile("^http://download.serienjunkies.org/f-.*?.html$") oldStyleLink = re.compile("^http://serienjunkies.org/safe/(.*)$") framePattern = re.compile("^http://download.serienjunkies.org/frame/go-.*?/$") - showPattern = re.compile("^http://serienjunkies.org/serie/.*/$") - seasonPattern = re.compile("^http://serienjunkies.org/.*?/.*/$") + url = pyfile.url if framePattern.match(url): - links = [self.handleFrame(url)] + self.packages.append((self.pyfile.package().name, [self.handleFrame(url)], self.pyfile.package().name)) elif episodePattern.match(url): - links = self.handleEpisode(url) + self.handleEpisode(url) elif oldStyleLink.match(url): - links = self.handleOldStyleLink(url) + self.handleOldStyleLink(url) elif showPattern.match(url): pass elif seasonPattern.match(url): - links = self.handleSeason(url) - self.links = links + self.handleSeason(url) diff --git a/module/plugins/hoster/RapidshareCom.py b/module/plugins/hoster/RapidshareCom.py index fa6dad837..07dc3ed21 100644 --- a/module/plugins/hoster/RapidshareCom.py +++ b/module/plugins/hoster/RapidshareCom.py @@ -31,7 +31,13 @@ class RapidshareCom(Hoster): self.url = self.pyfile.url self.prepare() self.proceed(self.url) - + + def getInfo(self): + self.url = self.pyfile.url + self.download_api_data() + self.pyfile.name = self.api_data["filename"] + self.pyfile.sync() + def prepare(self): # self.no_slots = True # self.want_reconnect = False @@ -69,10 +75,12 @@ class RapidshareCom(Hoster): else: self.fail("Unknown response code.") - def download_api_data(self): + def download_api_data(self, force=False): """ http://images.rapidshare.com/apidoc.txt """ + if self.api_data and not force: + return api_url_base = "http://api.rapidshare.com/cgi-bin/rsapi.cgi" api_param_file = {"sub": "checkfiles_v1", "files": "", "filenames": "", "incmd5": "1"} m = re.compile(self.__pattern__).search(self.url) diff --git a/module/plugins/hoster/UploadedTo.py b/module/plugins/hoster/UploadedTo.py index 573119680..2226f2943 100644 --- a/module/plugins/hoster/UploadedTo.py +++ b/module/plugins/hoster/UploadedTo.py @@ -29,6 +29,11 @@ class UploadedTo(Hoster): self.prepare() self.proceed() + + def getInfo(self): + self.download_api_data() + self.pyfile.name = self.api_data["filename"] + self.pyfile.sync() def prepare(self): tries = 0 @@ -66,7 +71,9 @@ class UploadedTo(Hoster): self.fail("Error while preparing DL") return True - def download_api_data(self): + def download_api_data(self, force=False): + if self.api_data and not force: + return match = re.compile(self.__pattern__).search(self.pyfile.url) if match: src = self.load("http://uploaded.to/api/file", cookies=False, get={"id": match.group(1).split("/")[0]}) |