diff options
Diffstat (limited to 'module')
17 files changed, 110 insertions, 119 deletions
diff --git a/module/plugins/accounts/XFileSharingPro.py b/module/plugins/accounts/XFileSharingPro.py index 354fc6446..1696042d6 100644 --- a/module/plugins/accounts/XFileSharingPro.py +++ b/module/plugins/accounts/XFileSharingPro.py @@ -3,13 +3,13 @@ from module.plugins.internal.XFSAccount import XFSAccount -class XFileSharingPro(XFSAccount): - __name__ = "XFileSharingPro" +class XFileSharing(XFSAccount): + __name__ = "XFileSharing" __type__ = "account" __version__ = "0.11" __status__ = "testing" - __description__ = """XFileSharingPro multi-purpose account plugin""" + __description__ = """XFileSharing multi-purpose account plugin""" __license__ = "GPLv3" __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] @@ -19,8 +19,8 @@ class XFileSharingPro(XFSAccount): def signin(self, user, password, data): try: - return super(XFileSharingPro, self).signin(user, password, data) + return super(XFileSharing, self).signin(user, password, data) except Fail: self.PLUGIN_URL = self.PLUGIN_URL.replace("www.", "") - return super(XFileSharingPro, self).signin(user, password, data) + return super(XFileSharing, self).signin(user, password, data) diff --git a/module/plugins/crypter/XFileSharingProFolder.py b/module/plugins/crypter/XFileSharingFolder.py index 527564293..0c6befb91 100644 --- a/module/plugins/crypter/XFileSharingProFolder.py +++ b/module/plugins/crypter/XFileSharingFolder.py @@ -5,8 +5,8 @@ import re from module.plugins.internal.XFSCrypter import XFSCrypter, create_getInfo -class XFileSharingProFolder(XFSCrypter): - __name__ = "XFileSharingProFolder" +class XFileSharingFolder(XFSCrypter): + __name__ = "XFileSharingFolder" __type__ = "crypter" __version__ = "0.17" __status__ = "testing" @@ -16,20 +16,18 @@ class XFileSharingProFolder(XFSCrypter): ("use_subfolder" , "bool", "Save package to subfolder" , True), ("subfolder_per_pack", "bool", "Create a subfolder for each package", True)] - __description__ = """XFileSharingPro dummy folder decrypter plugin for hook""" + __description__ = """XFileSharing dummy folder decrypter plugin for hook""" __license__ = "GPLv3" __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] def _log(self, level, plugintype, pluginname, messages): - return super(XFileSharingProFolder, self)._log(level, - plugintype, - "%s: %s" % (pluginname, self.PLUGIN_NAME), - messages) + messages = (self.PLUGIN_NAME,) + messages + return self.plugin._log(level, plugintype, pluginname, messages) def init(self): - super(XFileSharingProFolder, self).init() + super(XFileSharingFolder, self).init() self.__pattern__ = self.pyload.pluginManager.crypterPlugins[self.classname]['pattern'] @@ -73,4 +71,4 @@ class XFileSharingProFolder(XFSCrypter): self.account = False -getInfo = create_getInfo(XFileSharingProFolder) +getInfo = create_getInfo(XFileSharingFolder) diff --git a/module/plugins/hooks/TransmissionRPC.py b/module/plugins/hooks/TransmissionRPC.py index fa19a5f91..7d166ef20 100644 --- a/module/plugins/hooks/TransmissionRPC.py +++ b/module/plugins/hooks/TransmissionRPC.py @@ -14,7 +14,7 @@ from module.plugins.internal.Addon import Addon class TransmissionRPC(Addon): __name__ = "TransmissionRPC" __type__ = "hook" - __version__ = "0.13" + __version__ = "0.14" __status__ = "testing" __pattern__ = r"https?://.+\.torrent|magnet:\?.+" @@ -52,29 +52,24 @@ class TransmissionRPC(Addon): 'tag' : client_request_id}), req=req) - except BadHeader, e: - if e.code == 409: - headers = dict(re.findall(r"(?P<name>.+?): (?P<value>.+?)\r?\n", req.header)) - session_id = headers['X-Transmission-Session-Id'] - req.c.setopt(pycurl.HTTPHEADER, ["X-Transmission-Session-Id: %s" % session_id]) - try: - response = self.load(transmission_rpc_url, - post=json.dumps({'arguments': {'filename': url}, - 'method' : 'torrent-add', - 'tag' : client_request_id}), - req=req) - - except Exception, e: - self.log_error(e, trace=True) - return - - else: - self.log_error(e, trace=True) - return - except Exception, e: - self.log_error(e, trace=True) + self.log_error(e) return + + if req.code == 409: + headers = dict(re.findall(r"(?P<name>.+?): (?P<value>.+?)\r?\n", req.header)) + session_id = headers['X-Transmission-Session-Id'] + req.c.setopt(pycurl.HTTPHEADER, ["X-Transmission-Session-Id: %s" % session_id]) + try: + response = self.load(transmission_rpc_url, + post=json.dumps({'arguments': {'filename': url}, + 'method' : 'torrent-add', + 'tag' : client_request_id}), + req=req) + + except Exception, e: + self.log_error(e) + return try: res = json.loads(response) @@ -82,4 +77,4 @@ class TransmissionRPC(Addon): self.log_debug("Result: %s" % res['result']) except Exception, e: - self.log_error(e, trace=True) + self.log_error(e) diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index 24b05ba22..b2f5c9648 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -361,7 +361,7 @@ class UpdateManager(Addon): os.remove(filename) except OSError, e: - self.log_warning(_("Error removing: %s") % filename, e) + self.log_warning(_("Error removing `%s`") % filename, e) else: id = (type, name) diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharing.py index 75f8323ef..50068fc72 100644 --- a/module/plugins/hooks/XFileSharingPro.py +++ b/module/plugins/hooks/XFileSharing.py @@ -5,8 +5,8 @@ import re from module.plugins.internal.Addon import Addon -class XFileSharingPro(Addon): - __name__ = "XFileSharingPro" +class XFileSharing(Addon): + __name__ = "XFileSharing" __type__ = "hook" __version__ = "0.46" __status__ = "testing" @@ -18,7 +18,7 @@ class XFileSharingPro(Addon): ("hoster_list" , "str" , "Hoster list (comma separated)" , "" ), ("crypter_list" , "str" , "Crypter list (comma separated)", "" )] - __description__ = """Load XFileSharingPro based hosters and crypters which don't need a own plugin to run""" + __description__ = """Load XFileSharing based hosters and crypters which don't need a own plugin to run""" __license__ = "GPLv3" __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] @@ -53,8 +53,8 @@ class XFileSharingPro(Addon): def load_pattern(self): use_builtin_list = self.get_config('use_builtin_list') - for type, plugin in (("hoster", "XFileSharingPro"), - ("crypter", "XFileSharingProFolder")): + for type, plugin in (("hoster", "XFileSharing"), + ("crypter", "XFileSharingFolder")): every_plugin = not self.get_config("use_%s_list" % type) if every_plugin: @@ -99,14 +99,14 @@ class XFileSharingPro(Addon): def deactivate(self): # self.unload_hoster("BasePlugin") - for type, plugin in (("hoster", "XFileSharingPro"), - ("crypter", "XFileSharingProFolder")): + for type, plugin in (("hoster", "XFileSharing"), + ("crypter", "XFileSharingFolder")): self._unload(type, plugin) def unload_hoster(self, hoster): hdict = self.pyload.pluginManager.hosterPlugins[hoster] - if "new_name" in hdict and hdict['new_name'] == "XFileSharingPro": + if "new_name" in hdict and hdict['new_name'] == "XFileSharing": if "module" in hdict: hdict.pop('module', None) @@ -124,5 +124,5 @@ class XFileSharingPro(Addon): # and pyfile.hasStatus("failed") \ # and not self.get_config('use_hoster_list') \ # and self.unload_hoster("BasePlugin"): - # self.log_debug("Unloaded XFileSharingPro from BasePlugin") + # self.log_debug("Unloaded XFileSharing from BasePlugin") # pyfile.setStatus("queued") diff --git a/module/plugins/hoster/GoogledriveCom.py b/module/plugins/hoster/GoogledriveCom.py index 00a540e47..6b49a45a6 100644 --- a/module/plugins/hoster/GoogledriveCom.py +++ b/module/plugins/hoster/GoogledriveCom.py @@ -13,7 +13,7 @@ from module.plugins.internal.utils import html_unescape class GoogledriveCom(SimpleHoster): __name__ = "GoogledriveCom" __type__ = "hoster" - __version__ = "0.15" + __version__ = "0.16" __status__ = "testing" __pattern__ = r'https?://(?:www\.)?(drive|docs)\.google\.com/(file/d/\w+|uc\?.*id=)' @@ -45,7 +45,7 @@ class GoogledriveCom(SimpleHoster): return link = self.fixurl(link, "https://docs.google.com/") - dl = self.is_download(link, redirect=False) + dl = self.isdownload(link, redirect=False) if not dl: self.html = self.load(link) diff --git a/module/plugins/hoster/Http.py b/module/plugins/hoster/Http.py index 4e7ad0316..af82ca0ac 100644 --- a/module/plugins/hoster/Http.py +++ b/module/plugins/hoster/Http.py @@ -3,14 +3,13 @@ import re import urlparse -from module.network.HTTPRequest import BadHeader from module.plugins.internal.Hoster import Hoster, create_getInfo class Http(Hoster): __name__ = "Http" __type__ = "hoster" - __version__ = "0.02" + __version__ = "0.03" __status__ = "testing" __pattern__ = r'(?:jd|pys?)://.+' @@ -30,41 +29,36 @@ class Http(Hoster): url = re.sub(r'^(jd|py)', "http", pyfile.url) netloc = urlparse.urlparse(url).netloc - link = self.is_download(url) + link = self.isdownload(url) if not link: return for _i in xrange(2): - try: - self.download(link, ref=False, disposition=True) + self.download(link, ref=False, disposition=True) - except BadHeader, e: - if e.code in (404, 410): - self.offline() + if self.req.code in (404, 410): + self.offline() - elif e.code in (401, 403): - self.log_debug("Auth required", "Received HTTP status code: %d" % e.code) + elif self.req.code in (401, 403): + self.log_debug("Auth required", "Received HTTP status code: %d" % e.code) - #@TODO: Recheck in 0.4.10 - if self.account: - servers = [x['login'] for x in self.account.getAllAccounts()] - else: - servers = [] + #@TODO: Recheck in 0.4.10 + if self.account: + servers = [x['login'] for x in self.account.getAllAccounts()] + else: + servers = [] - if netloc in servers: - self.log_debug("Logging on to %s" % netloc) - self.req.addAuth(self.account.get_login('password')) + if netloc in servers: + self.log_debug("Logging on to %s" % netloc) + self.req.addAuth(self.account.get_login('password')) - else: - pwd = self.get_password() - if ':' in pwd: - self.req.addAuth(pwd) - else: - self.fail(_("Authorization required")) else: - self.fail(e) - + pwd = self.get_password() + if ':' in pwd: + self.req.addAuth(pwd) + else: + self.fail(_("Authorization required")) else: break diff --git a/module/plugins/hoster/Share4WebCom.py b/module/plugins/hoster/Share4WebCom.py index fa4861a89..f8d8a52d6 100644 --- a/module/plugins/hoster/Share4WebCom.py +++ b/module/plugins/hoster/Share4WebCom.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- -from module.plugins.hoster.UnibytesCom import UnibytesCom -from module.plugins.internal.SimpleHoster import create_getInfo +from module.plugins.hoster.UnibytesCom import UnibytesCom, create_getInfo class Share4WebCom(UnibytesCom): diff --git a/module/plugins/hoster/XFileSharingPro.py b/module/plugins/hoster/XFileSharing.py index 8721aae3a..89b58bb7f 100644 --- a/module/plugins/hoster/XFileSharingPro.py +++ b/module/plugins/hoster/XFileSharing.py @@ -5,8 +5,8 @@ import re from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo -class XFileSharingPro(XFSHoster): - __name__ = "XFileSharingPro" +class XFileSharing(XFSHoster): + __name__ = "XFileSharing" __type__ = "hoster" __version__ = "0.57" __status__ = "testing" @@ -14,7 +14,7 @@ class XFileSharingPro(XFSHoster): __pattern__ = r'https?://(?:www\.)?(?:\w+\.)*(?P<DOMAIN>(?:[\d.]+|[\w\-^_]{3,63}(?:\.[a-zA-Z]{2,}){1,2})(?:\:\d+)?)/(?:embed-)?\w{12}(?:\W|$)' __config__ = [("activated", "bool", "Activated", True)] - __description__ = """XFileSharingPro dummy hoster plugin for hook""" + __description__ = """XFileSharing dummy hoster plugin for hook""" __license__ = "GPLv3" __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] @@ -23,10 +23,8 @@ class XFileSharingPro(XFSHoster): def _log(self, level, plugintype, pluginname, messages): - return super(XFileSharingPro, self)._log(level, - plugintype, - "%s: %s" % (pluginname, self.PLUGIN_NAME), - messages) + messages = (self.PLUGIN_NAME,) + messages + return self.plugin._log(level, plugintype, pluginname, messages) def init(self): @@ -72,4 +70,4 @@ class XFileSharingPro(XFSHoster): self.account = False -getInfo = create_getInfo(XFileSharingPro) +getInfo = create_getInfo(XFileSharing) diff --git a/module/plugins/internal/Captcha.py b/module/plugins/internal/Captcha.py index 5993f0771..e0518f67b 100644 --- a/module/plugins/internal/Captcha.py +++ b/module/plugins/internal/Captcha.py @@ -112,7 +112,7 @@ class Captcha(Plugin): os.remove(tmp_img.name) except OSError, e: - self.log_warning(_("Error removing: %s") % tmp_img.name, e) + self.log_warning(_("Error removing `%s`") % tmp_img.name, e) #self.log_info(_("Captcha result: ") + result) #@TODO: Remove from here? diff --git a/module/plugins/internal/Container.py b/module/plugins/internal/Container.py index 946953db5..ba8b96f3b 100644 --- a/module/plugins/internal/Container.py +++ b/module/plugins/internal/Container.py @@ -78,4 +78,4 @@ class Container(Crypter): try: os.remove(self.pyfile.url) except OSError, e: - self.log_warning(_("Error removing: %s") % self.pyfile.url, e) + self.log_warning(_("Error removing `%s`") % self.pyfile.url, e) diff --git a/module/plugins/internal/Extractor.py b/module/plugins/internal/Extractor.py index 6629b0652..a8002a1d2 100644 --- a/module/plugins/internal/Extractor.py +++ b/module/plugins/internal/Extractor.py @@ -50,7 +50,7 @@ class Extractor(Plugin): @classmethod - def is_archive(cls, filename): + def isarchive(cls, filename): name = os.path.basename(filename).lower() return any(name.endswith(ext) for ext in cls.EXTENSIONS) @@ -74,8 +74,8 @@ class Extractor(Plugin): processed = [] for fname, id, fout in files_ids: - if cls.is_archive(fname): - pname = re.sub(cls.re_multipart, "", fname) if cls.is_multipart(fname) else os.path.splitext(fname)[0] + if cls.isarchive(fname): + pname = re.sub(cls.re_multipart, "", fname) if cls.ismultipart(fname) else os.path.splitext(fname)[0] if pname not in processed: processed.append(pname) targets.append((fname, id, fout)) diff --git a/module/plugins/internal/Hoster.py b/module/plugins/internal/Hoster.py index f042fb257..13d7afad8 100644 --- a/module/plugins/internal/Hoster.py +++ b/module/plugins/internal/Hoster.py @@ -5,7 +5,6 @@ from __future__ import with_statement import os import re -from module.network.HTTPRequest import BadHeader from module.plugins.internal.Base import Base, create_getInfo, parse_fileInfo from module.plugins.internal.Plugin import Fail, Retry from module.plugins.internal.utils import encode, exists, fixurl, fs_join, parse_name @@ -14,7 +13,7 @@ from module.plugins.internal.utils import encode, exists, fixurl, fs_join, parse class Hoster(Base): __name__ = "Hoster" __type__ = "hoster" - __version__ = "0.38" + __version__ = "0.39" __status__ = "testing" __pattern__ = r'^unmatchable$' @@ -102,7 +101,7 @@ class Hoster(Base): raise Fail(e) - def is_download(self, url, resume=None, redirect=True): + def isdownload(self, url, resume=None, redirect=True): link = False maxredirs = 10 @@ -177,7 +176,7 @@ class Hoster(Base): self.log_debug("DOWNLOAD URL " + url, *["%s=%s" % (key, val) for key, val in locals().items() if key not in ("self", "url", "_[1]")]) - dl_url = self.is_download(url, resume) + dl_url = self.isdownload(url, resume) dl_basename = parse_name(self.pyfile.name) self.pyfile.name = dl_basename @@ -185,6 +184,8 @@ class Hoster(Base): if not dl_url: self.error("Invalid download url") + + self.captcha.correct() if self.pyload.config.get("download", "skip_existing"): @@ -226,14 +227,20 @@ class Hoster(Base): cookies=cookies, chunks=chunks, resume=resume, progressNotify=self.pyfile.setProgress, disposition=disposition) - except BadHeader, e: - if e.code in (404, 410): - self.pyfile.setStatus("offline") - raise BadHeader(e) - finally: self.pyfile.size = self.req.size + if self.req.code in (404, 410): + bad_file = fs_join(dl_dirname, newname) + try: + os.remove(bad_file) + + except OSError, e: + self.log_debug(_("Error removing `%s`") % bad_file, e) + + finally: + return "" + #@TODO: Recheck in 0.4.10 if disposition and newname: safename = parse_name(newname.split(' filename*=')[0]) @@ -333,7 +340,7 @@ class Hoster(Base): os.remove(last_download) except OSError, e: - self.log_warning(_("Error removing: %s") % last_download, e) + self.log_warning(_("Error removing `%s`") % last_download, e) else: self.log_info(_("File deleted: ") + self.last_download) diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 1457c6fe5..231fb8810 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -2,6 +2,7 @@ import re +from module.network.RequestFactory import getURL as get_url from module.plugins.internal.Crypter import Crypter, create_getInfo, parse_fileInfo from module.plugins.internal.utils import replace_patterns, set_cookie, set_cookies @@ -9,7 +10,7 @@ from module.plugins.internal.utils import replace_patterns, set_cookie, set_cook class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.71" + __version__ = "0.72" __status__ = "testing" __pattern__ = r'^unmatchable$' @@ -103,15 +104,15 @@ class SimpleCrypter(Crypter): except BadHeader, e: info['error'] = "%d: %s" % (e.code, e.content) - if e.code in (404, 410): - info['status'] = 1 - - elif e.code is 503: - info['status'] = 6 - except Exception: pass + if pyreq.code in (404, 410): + info['status'] = 1 + + elif pyreq.code == 503: + info['status'] = 6 + if html: if cls.OFFLINE_PATTERN and re.search(cls.OFFLINE_PATTERN, html) is not None: info['status'] = 1 diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 8307c6236..8dcabdb6c 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -6,7 +6,6 @@ import os import re import time -from module.network.HTTPRequest import BadHeader from module.network.RequestFactory import getURL as get_url from module.plugins.internal.Hoster import Hoster, create_getInfo, parse_fileInfo from module.plugins.internal.Plugin import Fail @@ -18,7 +17,7 @@ from module.plugins.internal.utils import (encode, fixup, parse_name, parse_size class SimpleHoster(Hoster): __name__ = "SimpleHoster" __type__ = "hoster" - __version__ = "1.99" + __version__ = "2.00" __status__ = "testing" __pattern__ = r'^unmatchable$' @@ -150,15 +149,15 @@ class SimpleHoster(Hoster): except BadHeader, e: info['error'] = "%d: %s" % (e.code, e.content) - if e.code in (404, 410): - info['status'] = 1 - - elif e.code is 503: - info['status'] = 6 - except Exception: pass + if pyreq.code in (404, 410): + info['status'] = 1 + + elif pyreq.code == 503: + info['status'] = 6 + if html: if cls.OFFLINE_PATTERN and re.search(cls.OFFLINE_PATTERN, html) is not None: info['status'] = 1 @@ -428,7 +427,7 @@ class SimpleHoster(Hoster): def handle_direct(self, pyfile): - self.link = self.is_download(pyfile.url) + self.link = self.isdownload(pyfile.url) def handle_multi(self, pyfile): #: Multi-hoster handler diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py index c1ecccf40..835c372ab 100644 --- a/module/plugins/internal/UnRar.py +++ b/module/plugins/internal/UnRar.py @@ -69,7 +69,7 @@ class UnRar(Extractor): @classmethod - def is_multipart(cls, filename): + def ismultipart(cls, filename): return True if cls.re_multipart.search(filename) else False @@ -166,7 +166,7 @@ class UnRar(Extractor): files = [self.filename] #: eventually Multipart Files - files.extend(fs_join(dir, os.path.basename(file)) for file in filter(self.is_multipart, os.listdir(dir)) + files.extend(fs_join(dir, os.path.basename(file)) for file in filter(self.ismultipart, os.listdir(dir)) if re.sub(self.re_multipart, ".rar", name) == re.sub(self.re_multipart, ".rar", file)) return files diff --git a/module/plugins/internal/XFSHoster.py b/module/plugins/internal/XFSHoster.py index 30191a7e7..7e6439ecf 100644 --- a/module/plugins/internal/XFSHoster.py +++ b/module/plugins/internal/XFSHoster.py @@ -104,7 +104,7 @@ class XFSHoster(SimpleHoster): def handle_free(self, pyfile): for i in xrange(1, 6): - self.log_debug("Getting download link #%d" % i) + self.log_debug("Getting download link #%d..." % i) self.check_errors() |