From ffd38f027ed103f7b39ec78c6af0d182774950a4 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 19 Oct 2015 04:48:07 +0200 Subject: Spare fixes --- module/plugins/accounts/XFileSharingPro.py | 10 +- module/plugins/crypter/XFileSharingFolder.py | 74 ++++++++++++++ module/plugins/crypter/XFileSharingProFolder.py | 76 -------------- module/plugins/hooks/TransmissionRPC.py | 41 ++++---- module/plugins/hooks/UpdateManager.py | 2 +- module/plugins/hooks/XFileSharing.py | 128 ++++++++++++++++++++++++ module/plugins/hooks/XFileSharingPro.py | 128 ------------------------ module/plugins/hoster/GoogledriveCom.py | 4 +- module/plugins/hoster/Http.py | 46 ++++----- module/plugins/hoster/Share4WebCom.py | 3 +- module/plugins/hoster/XFileSharing.py | 73 ++++++++++++++ module/plugins/hoster/XFileSharingPro.py | 75 -------------- module/plugins/internal/Captcha.py | 2 +- module/plugins/internal/Container.py | 2 +- module/plugins/internal/Extractor.py | 6 +- module/plugins/internal/Hoster.py | 27 +++-- module/plugins/internal/SimpleCrypter.py | 15 +-- module/plugins/internal/SimpleHoster.py | 17 ++-- module/plugins/internal/UnRar.py | 4 +- module/plugins/internal/XFSHoster.py | 2 +- 20 files changed, 363 insertions(+), 372 deletions(-) create mode 100644 module/plugins/crypter/XFileSharingFolder.py delete mode 100644 module/plugins/crypter/XFileSharingProFolder.py create mode 100644 module/plugins/hooks/XFileSharing.py delete mode 100644 module/plugins/hooks/XFileSharingPro.py create mode 100644 module/plugins/hoster/XFileSharing.py delete mode 100644 module/plugins/hoster/XFileSharingPro.py (limited to 'module') 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/XFileSharingFolder.py b/module/plugins/crypter/XFileSharingFolder.py new file mode 100644 index 000000000..0c6befb91 --- /dev/null +++ b/module/plugins/crypter/XFileSharingFolder.py @@ -0,0 +1,74 @@ +# -*- coding: utf-8 -*- + +import re + +from module.plugins.internal.XFSCrypter import XFSCrypter, create_getInfo + + +class XFileSharingFolder(XFSCrypter): + __name__ = "XFileSharingFolder" + __type__ = "crypter" + __version__ = "0.17" + __status__ = "testing" + + __pattern__ = r'https?://(?:www\.)?(?:\w+\.)*(?P(?:[\d.]+|[\w\-^_]{3,63}(?:\.[a-zA-Z]{2,}){1,2})(?:\:\d+)?)/(?:user|folder)s?/\w+' + __config__ = [("activated" , "bool", "Activated" , True), + ("use_subfolder" , "bool", "Save package to subfolder" , True), + ("subfolder_per_pack", "bool", "Create a subfolder for each package", True)] + + __description__ = """XFileSharing dummy folder decrypter plugin for hook""" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + + + def _log(self, level, plugintype, pluginname, messages): + messages = (self.PLUGIN_NAME,) + messages + return self.plugin._log(level, plugintype, pluginname, messages) + + + def init(self): + super(XFileSharingFolder, self).init() + + self.__pattern__ = self.pyload.pluginManager.crypterPlugins[self.classname]['pattern'] + + self.PLUGIN_DOMAIN = re.match(self.__pattern__, self.pyfile.url).group("DOMAIN").lower() + self.PLUGIN_NAME = "".join(part.capitalize() for part in re.split(r'(\.|\d+|-)', self.PLUGIN_DOMAIN) if part != '.') + + + def _setup(self): + account_name = self.classname if not self.account or self.account.PLUGIN_DOMAIN is None else self.PLUGIN_NAME + self.chunk_limit = 1 + self.multiDL = True + + if self.account: + self.req = self.pyload.requestFactory.getRequest(accountname, self.account.user) + self.premium = self.account.premium + self.resume_download = self.premium + else: + self.req = self.pyload.requestFactory.getRequest(account_name) + self.premium = False + self.resume_download = False + + + def load_account(self): + if self.req: + self.req.close() + + if not self.account: + self.account = self.pyload.accountManager.getAccountPlugin(self.PLUGIN_NAME) + + if not self.account: + self.account = self.pyload.accountManager.getAccountPlugin(self.classname) + + if self.account: + if not self.account.PLUGIN_DOMAIN: + self.account.PLUGIN_DOMAIN = self.PLUGIN_DOMAIN + + if not self.account.user: #@TODO: Move to `Account` in 0.4.10 + self.account.user = self.account.select()[0] + + if not self.account.logged: + self.account = False + + +getInfo = create_getInfo(XFileSharingFolder) diff --git a/module/plugins/crypter/XFileSharingProFolder.py b/module/plugins/crypter/XFileSharingProFolder.py deleted file mode 100644 index 527564293..000000000 --- a/module/plugins/crypter/XFileSharingProFolder.py +++ /dev/null @@ -1,76 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from module.plugins.internal.XFSCrypter import XFSCrypter, create_getInfo - - -class XFileSharingProFolder(XFSCrypter): - __name__ = "XFileSharingProFolder" - __type__ = "crypter" - __version__ = "0.17" - __status__ = "testing" - - __pattern__ = r'https?://(?:www\.)?(?:\w+\.)*(?P(?:[\d.]+|[\w\-^_]{3,63}(?:\.[a-zA-Z]{2,}){1,2})(?:\:\d+)?)/(?:user|folder)s?/\w+' - __config__ = [("activated" , "bool", "Activated" , True), - ("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""" - __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) - - - def init(self): - super(XFileSharingProFolder, self).init() - - self.__pattern__ = self.pyload.pluginManager.crypterPlugins[self.classname]['pattern'] - - self.PLUGIN_DOMAIN = re.match(self.__pattern__, self.pyfile.url).group("DOMAIN").lower() - self.PLUGIN_NAME = "".join(part.capitalize() for part in re.split(r'(\.|\d+|-)', self.PLUGIN_DOMAIN) if part != '.') - - - def _setup(self): - account_name = self.classname if not self.account or self.account.PLUGIN_DOMAIN is None else self.PLUGIN_NAME - self.chunk_limit = 1 - self.multiDL = True - - if self.account: - self.req = self.pyload.requestFactory.getRequest(accountname, self.account.user) - self.premium = self.account.premium - self.resume_download = self.premium - else: - self.req = self.pyload.requestFactory.getRequest(account_name) - self.premium = False - self.resume_download = False - - - def load_account(self): - if self.req: - self.req.close() - - if not self.account: - self.account = self.pyload.accountManager.getAccountPlugin(self.PLUGIN_NAME) - - if not self.account: - self.account = self.pyload.accountManager.getAccountPlugin(self.classname) - - if self.account: - if not self.account.PLUGIN_DOMAIN: - self.account.PLUGIN_DOMAIN = self.PLUGIN_DOMAIN - - if not self.account.user: #@TODO: Move to `Account` in 0.4.10 - self.account.user = self.account.select()[0] - - if not self.account.logged: - self.account = False - - -getInfo = create_getInfo(XFileSharingProFolder) 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.+?): (?P.+?)\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.+?): (?P.+?)\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/XFileSharing.py b/module/plugins/hooks/XFileSharing.py new file mode 100644 index 000000000..50068fc72 --- /dev/null +++ b/module/plugins/hooks/XFileSharing.py @@ -0,0 +1,128 @@ +# -*- coding: utf-8 -*- + +import re + +from module.plugins.internal.Addon import Addon + + +class XFileSharing(Addon): + __name__ = "XFileSharing" + __type__ = "hook" + __version__ = "0.46" + __status__ = "testing" + + __config__ = [("activated" , "bool", "Activated" , True ), + ("use_hoster_list" , "bool", "Load listed hosters only" , False), + ("use_crypter_list", "bool", "Load listed crypters only" , False), + ("use_builtin_list", "bool", "Load built-in plugin list" , True ), + ("hoster_list" , "str" , "Hoster list (comma separated)" , "" ), + ("crypter_list" , "str" , "Crypter list (comma separated)", "" )] + + __description__ = """Load XFileSharing based hosters and crypters which don't need a own plugin to run""" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + + + regexp = {'hoster' : (r'https?://(?:www\.)?(?:\w+\.)*(?P(?:[\d.]+|[\w\-^_]{3,63}(?:\.[a-zA-Z]{2,}){1,2})(?:\:\d+)?)/(?:embed-)?\w{12}(?:\W|$)', + r'https?://(?:[^/]+\.)?(?P%s)/(?:embed-)?\w+'), + 'crypter': (r'https?://(?:www\.)?(?:\w+\.)*(?P(?:[\d.]+|[\w\-^_]{3,63}(?:\.[a-zA-Z]{2,}){1,2})(?:\:\d+)?)/(?:user|folder)s?/\w+', + r'https?://(?:[^/]+\.)?(?P%s)/(?:user|folder)s?/\w+')} + + BUILTIN_HOSTERS = [#WORKING HOSTERS: + "ani-stream.com", "backin.net", "cloudsix.me", "eyesfile.ca", + "file4safe.com", "fileband.com", "filedwon.com", "fileparadox.in", + "filevice.com", "hostingbulk.com", "junkyvideo.com", "ravishare.com", + "ryushare.com", "salefiles.com", "sendmyway.com", "sharebeast.com", + "sharesix.com", "thefile.me", "verzend.be", "worldbytez.com", + "xvidstage.com", + #: NOT TESTED: + "101shared.com", "4upfiles.com", "filemaze.ws", "filenuke.com", + "linkzhost.com", "mightyupload.com", "rockdizfile.com", "sharerepo.com", + "shareswift.com", "uploadbaz.com", "uploadc.com", "vidbull.com", + "zalaa.com", "zomgupload.com", + #: NOT WORKING: + "amonshare.com", "banicrazy.info", "boosterking.com", "host4desi.com", + "laoupload.com", "rd-fs.com"] + BUILTIN_CRYPTERS = ["junocloud.me", "rapidfileshare.net"] + + + def activate(self): + self.load_pattern() + + + def load_pattern(self): + use_builtin_list = self.get_config('use_builtin_list') + + for type, plugin in (("hoster", "XFileSharing"), + ("crypter", "XFileSharingFolder")): + every_plugin = not self.get_config("use_%s_list" % type) + + if every_plugin: + self.log_info(_("Handling any %s I can!") % type) + pattern = self.regexp[type][0] + else: + plugins = self.get_config('%s_list' % type) + plugin_set = set(plugins.replace(' ', '').replace('\\', '').replace('|', ',').replace(';', ',').lower().split(',')) + + if use_builtin_list: + plugin_set |= set(x.lower() for x in getattr(self, "BUILTIN_%sS" % type.upper())) + + plugin_set -= set(('', u'')) + + if not plugin_set: + self.log_info(_("No %s to handle") % type) + self._unload(type, plugin) + return + + match_list = '|'.join(sorted(plugin_set)) + + len_match_list = len(plugin_set) + self.log_info(_("Handling %d %s%s: %s") % (len_match_list, + type, + "" if len_match_list == 1 else "s", + match_list.replace('|', ', '))) + + pattern = self.regexp[type][1] % match_list.replace('.', '\.') + + dict = self.pyload.pluginManager.plugins[type][plugin] + dict['pattern'] = pattern + dict['re'] = re.compile(pattern) + + self.log_debug("Loaded %s pattern: %s" % (type, pattern)) + + + def _unload(self, type, plugin): + dict = self.pyload.pluginManager.plugins[type][plugin] + dict['pattern'] = r'^unmatchable$' + dict['re'] = re.compile(dict['pattern']) + + + def deactivate(self): + # self.unload_hoster("BasePlugin") + 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'] == "XFileSharing": + if "module" in hdict: + hdict.pop('module', None) + + if "new_module" in hdict: + hdict.pop('new_module', None) + hdict.pop('new_name', None) + + return True + else: + return False + + + # def download_failed(self, pyfile): + # if pyfile.pluginname == "BasePlugin" \ + # and pyfile.hasStatus("failed") \ + # and not self.get_config('use_hoster_list') \ + # and self.unload_hoster("BasePlugin"): + # self.log_debug("Unloaded XFileSharing from BasePlugin") + # pyfile.setStatus("queued") diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharingPro.py deleted file mode 100644 index 75f8323ef..000000000 --- a/module/plugins/hooks/XFileSharingPro.py +++ /dev/null @@ -1,128 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from module.plugins.internal.Addon import Addon - - -class XFileSharingPro(Addon): - __name__ = "XFileSharingPro" - __type__ = "hook" - __version__ = "0.46" - __status__ = "testing" - - __config__ = [("activated" , "bool", "Activated" , True ), - ("use_hoster_list" , "bool", "Load listed hosters only" , False), - ("use_crypter_list", "bool", "Load listed crypters only" , False), - ("use_builtin_list", "bool", "Load built-in plugin list" , True ), - ("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""" - __license__ = "GPLv3" - __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - - - regexp = {'hoster' : (r'https?://(?:www\.)?(?:\w+\.)*(?P(?:[\d.]+|[\w\-^_]{3,63}(?:\.[a-zA-Z]{2,}){1,2})(?:\:\d+)?)/(?:embed-)?\w{12}(?:\W|$)', - r'https?://(?:[^/]+\.)?(?P%s)/(?:embed-)?\w+'), - 'crypter': (r'https?://(?:www\.)?(?:\w+\.)*(?P(?:[\d.]+|[\w\-^_]{3,63}(?:\.[a-zA-Z]{2,}){1,2})(?:\:\d+)?)/(?:user|folder)s?/\w+', - r'https?://(?:[^/]+\.)?(?P%s)/(?:user|folder)s?/\w+')} - - BUILTIN_HOSTERS = [#WORKING HOSTERS: - "ani-stream.com", "backin.net", "cloudsix.me", "eyesfile.ca", - "file4safe.com", "fileband.com", "filedwon.com", "fileparadox.in", - "filevice.com", "hostingbulk.com", "junkyvideo.com", "ravishare.com", - "ryushare.com", "salefiles.com", "sendmyway.com", "sharebeast.com", - "sharesix.com", "thefile.me", "verzend.be", "worldbytez.com", - "xvidstage.com", - #: NOT TESTED: - "101shared.com", "4upfiles.com", "filemaze.ws", "filenuke.com", - "linkzhost.com", "mightyupload.com", "rockdizfile.com", "sharerepo.com", - "shareswift.com", "uploadbaz.com", "uploadc.com", "vidbull.com", - "zalaa.com", "zomgupload.com", - #: NOT WORKING: - "amonshare.com", "banicrazy.info", "boosterking.com", "host4desi.com", - "laoupload.com", "rd-fs.com"] - BUILTIN_CRYPTERS = ["junocloud.me", "rapidfileshare.net"] - - - def activate(self): - self.load_pattern() - - - def load_pattern(self): - use_builtin_list = self.get_config('use_builtin_list') - - for type, plugin in (("hoster", "XFileSharingPro"), - ("crypter", "XFileSharingProFolder")): - every_plugin = not self.get_config("use_%s_list" % type) - - if every_plugin: - self.log_info(_("Handling any %s I can!") % type) - pattern = self.regexp[type][0] - else: - plugins = self.get_config('%s_list' % type) - plugin_set = set(plugins.replace(' ', '').replace('\\', '').replace('|', ',').replace(';', ',').lower().split(',')) - - if use_builtin_list: - plugin_set |= set(x.lower() for x in getattr(self, "BUILTIN_%sS" % type.upper())) - - plugin_set -= set(('', u'')) - - if not plugin_set: - self.log_info(_("No %s to handle") % type) - self._unload(type, plugin) - return - - match_list = '|'.join(sorted(plugin_set)) - - len_match_list = len(plugin_set) - self.log_info(_("Handling %d %s%s: %s") % (len_match_list, - type, - "" if len_match_list == 1 else "s", - match_list.replace('|', ', '))) - - pattern = self.regexp[type][1] % match_list.replace('.', '\.') - - dict = self.pyload.pluginManager.plugins[type][plugin] - dict['pattern'] = pattern - dict['re'] = re.compile(pattern) - - self.log_debug("Loaded %s pattern: %s" % (type, pattern)) - - - def _unload(self, type, plugin): - dict = self.pyload.pluginManager.plugins[type][plugin] - dict['pattern'] = r'^unmatchable$' - dict['re'] = re.compile(dict['pattern']) - - - def deactivate(self): - # self.unload_hoster("BasePlugin") - for type, plugin in (("hoster", "XFileSharingPro"), - ("crypter", "XFileSharingProFolder")): - 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 "module" in hdict: - hdict.pop('module', None) - - if "new_module" in hdict: - hdict.pop('new_module', None) - hdict.pop('new_name', None) - - return True - else: - return False - - - # def download_failed(self, pyfile): - # if pyfile.pluginname == "BasePlugin" \ - # and pyfile.hasStatus("failed") \ - # and not self.get_config('use_hoster_list') \ - # and self.unload_hoster("BasePlugin"): - # self.log_debug("Unloaded XFileSharingPro 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/XFileSharing.py b/module/plugins/hoster/XFileSharing.py new file mode 100644 index 000000000..89b58bb7f --- /dev/null +++ b/module/plugins/hoster/XFileSharing.py @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- + +import re + +from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo + + +class XFileSharing(XFSHoster): + __name__ = "XFileSharing" + __type__ = "hoster" + __version__ = "0.57" + __status__ = "testing" + + __pattern__ = r'https?://(?:www\.)?(?:\w+\.)*(?P(?:[\d.]+|[\w\-^_]{3,63}(?:\.[a-zA-Z]{2,}){1,2})(?:\:\d+)?)/(?:embed-)?\w{12}(?:\W|$)' + __config__ = [("activated", "bool", "Activated", True)] + + __description__ = """XFileSharing dummy hoster plugin for hook""" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + + + URL_REPLACEMENTS = [("/embed-", "/")] + + + def _log(self, level, plugintype, pluginname, messages): + messages = (self.PLUGIN_NAME,) + messages + return self.plugin._log(level, plugintype, pluginname, messages) + + + def init(self): + self.__pattern__ = self.pyload.pluginManager.hosterPlugins[self.classname]['pattern'] + + self.PLUGIN_DOMAIN = re.match(self.__pattern__, self.pyfile.url).group("DOMAIN").lower() + self.PLUGIN_NAME = "".join(part.capitalize() for part in re.split(r'(\.|\d+|-)', self.PLUGIN_DOMAIN) if part != '.') + + + def _setup(self): + account_name = self.classname if not self.account or self.account.PLUGIN_DOMAIN is None else self.PLUGIN_NAME + self.chunk_limit = 1 + self.multiDL = True + + if self.account: + self.req = self.pyload.requestFactory.getRequest(accountname, self.account.user) + self.premium = self.account.premium + self.resume_download = self.premium + else: + self.req = self.pyload.requestFactory.getRequest(account_name) + self.premium = False + self.resume_download = False + + + def load_account(self): + if self.req: + self.req.close() + + if not self.account: + self.account = self.pyload.accountManager.getAccountPlugin(self.PLUGIN_NAME) + + if not self.account: + self.account = self.pyload.accountManager.getAccountPlugin(self.classname) + + if self.account: + if not self.account.PLUGIN_DOMAIN: + self.account.PLUGIN_DOMAIN = self.PLUGIN_DOMAIN + + if not self.account.user: #@TODO: Move to `Account` in 0.4.10 + self.account.user = self.account.select()[0] + + if not self.account.logged: + self.account = False + + +getInfo = create_getInfo(XFileSharing) diff --git a/module/plugins/hoster/XFileSharingPro.py b/module/plugins/hoster/XFileSharingPro.py deleted file mode 100644 index 8721aae3a..000000000 --- a/module/plugins/hoster/XFileSharingPro.py +++ /dev/null @@ -1,75 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo - - -class XFileSharingPro(XFSHoster): - __name__ = "XFileSharingPro" - __type__ = "hoster" - __version__ = "0.57" - __status__ = "testing" - - __pattern__ = r'https?://(?:www\.)?(?:\w+\.)*(?P(?:[\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""" - __license__ = "GPLv3" - __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - - - URL_REPLACEMENTS = [("/embed-", "/")] - - - def _log(self, level, plugintype, pluginname, messages): - return super(XFileSharingPro, self)._log(level, - plugintype, - "%s: %s" % (pluginname, self.PLUGIN_NAME), - messages) - - - def init(self): - self.__pattern__ = self.pyload.pluginManager.hosterPlugins[self.classname]['pattern'] - - self.PLUGIN_DOMAIN = re.match(self.__pattern__, self.pyfile.url).group("DOMAIN").lower() - self.PLUGIN_NAME = "".join(part.capitalize() for part in re.split(r'(\.|\d+|-)', self.PLUGIN_DOMAIN) if part != '.') - - - def _setup(self): - account_name = self.classname if not self.account or self.account.PLUGIN_DOMAIN is None else self.PLUGIN_NAME - self.chunk_limit = 1 - self.multiDL = True - - if self.account: - self.req = self.pyload.requestFactory.getRequest(accountname, self.account.user) - self.premium = self.account.premium - self.resume_download = self.premium - else: - self.req = self.pyload.requestFactory.getRequest(account_name) - self.premium = False - self.resume_download = False - - - def load_account(self): - if self.req: - self.req.close() - - if not self.account: - self.account = self.pyload.accountManager.getAccountPlugin(self.PLUGIN_NAME) - - if not self.account: - self.account = self.pyload.accountManager.getAccountPlugin(self.classname) - - if self.account: - if not self.account.PLUGIN_DOMAIN: - self.account.PLUGIN_DOMAIN = self.PLUGIN_DOMAIN - - if not self.account.user: #@TODO: Move to `Account` in 0.4.10 - self.account.user = self.account.select()[0] - - if not self.account.logged: - self.account = False - - -getInfo = create_getInfo(XFileSharingPro) 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() -- cgit v1.2.3