diff options
author | Nitzo <nitzo2001@yahoo.com> | 2016-04-21 00:29:25 +0200 |
---|---|---|
committer | Nitzo <nitzo2001@yahoo.com> | 2016-04-21 00:29:25 +0200 |
commit | 258b7c2f68ca7e0701f8af160f0a7acf3a35431a (patch) | |
tree | c084829fee6d13138d2d6c0b0350e14ed1a10921 /module | |
parent | [ImgurCom] Code cleanup (diff) | |
download | pyload-258b7c2f68ca7e0701f8af160f0a7acf3a35431a.tar.xz |
Fix some incompatibilities with python 2.5
Diffstat (limited to 'module')
-rw-r--r-- | module/plugins/crypter/LinkCryptWs.py | 32 | ||||
-rw-r--r-- | module/plugins/crypter/ShareLinksBiz.py | 82 | ||||
-rw-r--r-- | module/plugins/hoster/OpenloadIo.py | 14 |
3 files changed, 64 insertions, 64 deletions
diff --git a/module/plugins/crypter/LinkCryptWs.py b/module/plugins/crypter/LinkCryptWs.py index 66923b192..a6debecdd 100644 --- a/module/plugins/crypter/LinkCryptWs.py +++ b/module/plugins/crypter/LinkCryptWs.py @@ -13,7 +13,7 @@ from module.plugins.internal.misc import html_unescape, set_cookie class LinkCryptWs(Crypter): __name__ = "LinkCryptWs" __type__ = "crypter" - __version__ = "0.18" + __version__ = "0.19" __status__ = "testing" __pattern__ = r'http://(?:www\.)?linkcrypt\.ws/(dir|container)/(?P<ID>\w+)' @@ -21,10 +21,10 @@ class LinkCryptWs(Crypter): __description__ = """LinkCrypt.ws decrypter plugin""" __license__ = "GPLv3" - __authors__ = [("kagenoshin", "kagenoshin[AT]gmx[DOT]ch"), - ("glukgluk", None), - ("Gummibaer", None), - ("Arno-Nymous", None)] + __authors__ = [("kagenoshin", "kagenoshin[AT]gmx[DOT]ch"), + ("glukgluk", None ), + ("Gummibaer", None ), + ("Arno-Nymous", None )] CRYPTED_KEY = "crypted" @@ -92,7 +92,7 @@ class LinkCryptWs(Crypter): def is_online(self): if "<title>Linkcrypt.ws // Error 404</title>" in self.data: - self.log_debug("Folder doesn't exist anymore") + self.log_debug(_("Folder doesn't exist anymore")) return False else: return True @@ -100,7 +100,7 @@ class LinkCryptWs(Crypter): def is_password_protected(self): if "Authorizing" in self.data: - self.log_debug("Links are password protected") + self.log_debug(_("Links are password protected")) return True else: return False @@ -125,7 +125,7 @@ class LinkCryptWs(Crypter): password = self.get_password() if password: - self.log_debug("Submitting password [{0}] for protected links".format(password)) + self.log_debug(_("Submitting password [%s] for protected links") % password) self.data = self.load(self.pyfile.url, post={'password': password, 'x': "0", 'y': "0"}) else: self.fail(_("Folder is password protected")) @@ -142,7 +142,7 @@ class LinkCryptWs(Crypter): name = self.pyfile.package().name folder = self.pyfile.package().folder - self.log_debug("Defaulting to pyfile name [{0}] and folder [{1}] for package".format(name, folder)) + self.log_debug(_("Defaulting to pyfile name [%s] and folder [%s] for package") % (name, folder)) return name, folder @@ -186,7 +186,7 @@ class LinkCryptWs(Crypter): pattern = r'<form action="http://linkcrypt.ws/out.html"[^>]*?>.*?<input[^>]*?value="(.+?)"[^>]*?name="file"' ids = re.findall(pattern, self.data, re.I | re.S) - self.log_debug("Decrypting {0} Web links".format(len(ids))) + self.log_debug(_("Decrypting %s Web links") % len(ids)) for idx, weblink_id in enumerate(ids): try: @@ -201,7 +201,7 @@ class LinkCryptWs(Crypter): pack_links.append(link2) except Exception, detail: - self.log_debug("Error decrypting Web link {0}, {1}".format(weblink_id, detail)) + self.log_debug(_("Error decrypting Web link %s, %s") % (weblink_id, detail)) return pack_links @@ -225,7 +225,7 @@ class LinkCryptWs(Crypter): pack_links = [] container_type = container_type.lower() - self.log_debug('Search for %s Container links' % container_type.upper()) + self.log_debug(_("Search for %s Container links") % container_type.upper()) if not container_type.isalnum(): #: Check to prevent broken re-pattern (cnl2, rsdf, ccf, dlc, web are all alpha-numeric) self.fail(_("Unknown container type: %s") % container_type) #@TODO: Replace with self.error in 0.4.10 @@ -241,7 +241,7 @@ class LinkCryptWs(Crypter): self.log_debug("clink found") pack_name, folder_name = self.get_package_info() - self.log_debug("Added package with name {0}.{1} and container link {2}".format(pack_name, container_type, clink.group(1))) + self.log_debug(_("Added package with name %s.%s and container link %s") % (pack_name, container_type, clink.group(1))) self.pyload.api.uploadContainer('.'.join([pack_name, container_type]), self.load(clink.group(1))) return "Found it" @@ -285,7 +285,7 @@ class LinkCryptWs(Crypter): vcrypted = re.findall(crypted_re, cnl_section) #: Log and return - self.log_debug("Detected {0} crypted blocks".format(len(vcrypted))) + self.log_debug(_("Detected %s crypted blocks") % len(vcrypted)) return vcrypted, vjk @@ -293,7 +293,7 @@ class LinkCryptWs(Crypter): #: Get key key = binascii.unhexlify(jk) - self.log_debug("JsEngine returns value [{0}]".format(key)) + self.log_debug(_("JsEngine returns value [%s]") % key) #: Decrypt Key = key @@ -306,6 +306,6 @@ class LinkCryptWs(Crypter): links = filter(bool, text.split('\n')) #: Log and return - self.log_debug("Package has {0} links".format(len(links))) + self.log_debug(_("Package has %s links")% len(links)) return links diff --git a/module/plugins/crypter/ShareLinksBiz.py b/module/plugins/crypter/ShareLinksBiz.py index 1968fcf8e..fd9eb4124 100644 --- a/module/plugins/crypter/ShareLinksBiz.py +++ b/module/plugins/crypter/ShareLinksBiz.py @@ -11,7 +11,7 @@ from module.plugins.internal.Crypter import Crypter class ShareLinksBiz(Crypter): __name__ = "ShareLinksBiz" __type__ = "crypter" - __version__ = "1.23" + __version__ = "1.24" __status__ = "testing" __pattern__ = r'http://(?:www\.)?(share-links|s2l)\.biz/(?P<ID>_?\w+)' @@ -21,8 +21,8 @@ class ShareLinksBiz(Crypter): __description__ = """Share-Links.biz decrypter plugin""" __license__ = "GPLv3" - __authors__ = [("fragonib", "fragonib[AT]yahoo[DOT]es"), - ("Arno-Nymous", None)] + __authors__ = [("fragonib", "fragonib[AT]yahoo[DOT]es"), + ("Arno-Nymous", None )] def setup(self): @@ -81,7 +81,7 @@ class ShareLinksBiz(Crypter): self.file_id = re.match(self.__pattern__, url).group('ID') else: - self.log_debug("Could not initialize, URL [%s] does not match pattern [%s]" % (url, self.__pattern__)) + self.log_debug(_("Could not initialize, URL [%s] does not match pattern [%s]") % (url, self.__pattern__)) self.fail(_("Unsupported download link")) self.package = pyfile.package() @@ -89,7 +89,7 @@ class ShareLinksBiz(Crypter): def is_online(self): if "No usable content was found" in self.data: - self.log_debug("File not found") + self.log_debug(_("File not found")) return False else: return True @@ -97,14 +97,14 @@ class ShareLinksBiz(Crypter): def is_password_protected(self): if re.search(r'<form.*?id="passwordForm".*?>', self.data): - self.log_debug("Links are protected") + self.log_debug(_("Links are protected")) return True return False def is_captcha_protected(self): if '<map id="captchamap"' in self.data: - self.log_debug("Links are captcha protected") + self.log_debug(_("Links are captcha protected")) return True return False @@ -117,7 +117,7 @@ class ShareLinksBiz(Crypter): def unlock_password_protection(self): password = self.get_password() - self.log_debug("Submitting password [%s] for protected links" % password) + self.log_debug(_("Submitting password [%s] for protected links") % password) post = {'password': password, 'login': 'Submit form'} url = self.base_url + '/' + self.file_id self.data = self.load(url, post=post) @@ -125,22 +125,22 @@ class ShareLinksBiz(Crypter): def unlock_captcha_protection(self): #: Get captcha map - captchaMap = self._get_captcha_map() - self.log_debug("Captcha map with [%d] positions" % len(captchaMap.keys())) + captcha_map = self._get_captcha_map() + self.log_debug(_("Captcha map with [%d] positions") % len(captcha_map.keys())) #: Request user for captcha coords m = re.search(r'<img src="/captcha.gif\?d=(.+?)&PHPSESSID=(.+?)&legend=1"', self.data) if m is None: - self.log_debug("Captcha url data not found, maybe plugin out of date?") + self.log_debug(_("Captcha url data not found, maybe plugin out of date?")) self.fail(_("Captcha url data not found")) - captchaUrl = self.base_url + '/captcha.gif?d=%s&PHPSESSID=%s' % (m.group(1), m.group(2)) - self.log_debug("Waiting user for correct position") - coords = self.captcha.decrypt(captchaUrl, input_type="gif", output_type='positional') - self.log_debug("Captcha resolved! Coords: {}, {}".format(*coords)) + captcha_url = self.base_url + '/captcha.gif?d=%s&PHPSESSID=%s' % (m.group(1), m.group(2)) + self.log_debug(_("Waiting user for correct position")) + coords = self.captcha.decrypt(captcha_url, input_type="gif", output_type='positional') + self.log_debug(_("Captcha resolved! Coords: *s, %s") % (coords[0], coords[1])) #: Resolve captcha - href = self._resolve_coords(coords, captchaMap) + href = self._resolve_coords(coords, captcha_map) if href is None: self.retry_captcha(wait=5) @@ -157,9 +157,9 @@ class ShareLinksBiz(Crypter): return mapp - def _resolve_coords(self, coords, captchaMap): + def _resolve_coords(self, coords, captcha_map): x, y = coords - for rect, href in captchaMap.items(): + for rect, href in captcha_map.items(): x1, y1, x2, y2 = rect if (x >= x1 and x <= x2) and (y >= y1 and y <= y2): return href @@ -186,13 +186,13 @@ class ShareLinksBiz(Crypter): title = m.group(1).strip() if 'unnamed' not in title: name = folder = title - self.log_debug("Found name [%s] and folder [%s] in package info" % (name, folder)) + self.log_debug(_("Found name [%s] and folder [%s] in package info") % (name, folder)) #: Fallback to defaults if not name or not folder: name = self.package.name folder = self.package.folder - self.log_debug("Package info not found, defaulting to pyfile name [%s] and folder [%s]" % (name, folder)) + self.log_debug(_("Package info not found, defaulting to pyfile name [%s] and folder [%s]") % (name, folder)) #: Return package info return name, folder @@ -200,55 +200,55 @@ class ShareLinksBiz(Crypter): def handle_web_links(self): pack_links = [] - self.log_debug("Handling Web links") + self.log_debug(_("Handling Web links")) #@TODO: Gather paginated web links pattern = r'javascript:_get\(\'(.*?)\', \d+, \'\'\)' ids = re.findall(pattern, self.data) - self.log_debug("Decrypting %d Web links" % len(ids)) + self.log_debug(_("Decrypting %d Web links") % len(ids)) for i, ID in enumerate(ids): try: - self.log_debug("Decrypting Web link %d, [%s]" % (i + 1, ID)) + self.log_debug(_("Decrypting Web link %d, [%s]") % (i + 1, ID)) - dwLink = self.base_url + "/get/lnk/" + ID - res = self.load(dwLink) + dw_link = self.base_url + "/get/lnk/" + ID + res = self.load(dw_link) code = re.search(r'frm/(\d+)', res).group(1) - fwLink = self.base_url + "/get/frm/" + code - res = self.load(fwLink) + fw_link = self.base_url + "/get/frm/" + code + res = self.load(fw_link) jscode = re.search(r'<script language="javascript">\s*eval\((.*)\)\s*</script>', res, re.S).group(1) - jscode = self.js.eval("f = %s" % jscode) + jscode = self.js.eval(_("f = %s") % jscode) jslauncher = "window=''; parent={frames:{Main:{location:{href:''}}},location:''}; %s; parent.frames.Main.location.href" - dlLink = self.js.eval(jslauncher % jscode) + dl_link = self.js.eval(jslauncher % jscode) - self.log_debug("JsEngine returns value [%s] for redirection link" % dlLink) + self.log_debug(_("JsEngine returns value [%s] for redirection link") % dl_link) - pack_links.append(dlLink) + pack_links.append(dl_link) except Exception, detail: - self.log_debug("Error decrypting Web link [%s], %s" % (ID, detail)) + self.log_debug(_("Error decrypting Web link [%s], %s") % (ID, detail)) return pack_links def handle_containers(self): pack_links = [] - self.log_debug("Handling Container links") + self.log_debug(_("Handling Container links")) pattern = r'javascript:_get\(\'(.*?)\', 0, \'(rsdf|ccf|dlc)\'\)' - containersLinks = re.findall(pattern, self.data) - self.log_debug("Decrypting %d Container links" % len(containersLinks)) - for containerLink in containersLinks: - link = "%s/get/%s/%s" % (self.base_url, containerLink[1], containerLink[0]) + containers_links = re.findall(pattern, self.data) + self.log_debug(_("Decrypting %d Container links") % len(containers_links)) + for container_link in containers_links: + link = "%s/get/%s/%s" % (self.base_url, container_link[1], container_link[0]) pack_links.append(link) return pack_links def handle_CNL2(self): pack_links = [] - self.log_debug("Handling CNL2 links") + self.log_debug(_("Handling CNL2 links")) if '/lib/cnl2/ClicknLoad.swf' in self.data: try: @@ -282,8 +282,8 @@ class ShareLinksBiz(Crypter): def _get_links(self, crypted, jk): #: Get key - jreturn = self.js.eval("%s f()" % jk) - self.log_debug("JsEngine returns value [%s]" % jreturn) + jreturn = self.js.eval(_("%s f()") % jk) + self.log_debug(_("JsEngine returns value [%s]") % jreturn) key = binascii.unhexlify(jreturn) #: Decrypt @@ -297,5 +297,5 @@ class ShareLinksBiz(Crypter): links = filter(bool, text.split('\n')) #: Log and return - self.log_debug("Block has %d links" % len(links)) + self.log_debug(_("Block has %d links") % len(links)) return links diff --git a/module/plugins/hoster/OpenloadIo.py b/module/plugins/hoster/OpenloadIo.py index dcd4dddb4..c4824280b 100644 --- a/module/plugins/hoster/OpenloadIo.py +++ b/module/plugins/hoster/OpenloadIo.py @@ -10,7 +10,7 @@ from module.plugins.internal.misc import json class OpenloadIo(SimpleHoster): __name__ = "OpenloadIo" __type__ = "hoster" - __version__ = "0.15" + __version__ = "0.16" __status__ = "testing" __pattern__ = r'https?://(?:www\.)?openload\.(co|io)/(f|embed)/(?P<ID>[\w\-]+)' @@ -28,9 +28,9 @@ class OpenloadIo(SimpleHoster): # The API reference, that this implementation uses is available at https://openload.co/api API_URL = 'https://api.openload.co/1' - _DOWNLOAD_TICKET_URI_PATTERN = '/file/dlticket?file={0}' - _DOWNLOAD_FILE_URI_PATTERN = '/file/dl?file={0}&ticket={1}' - _FILE_INFO_URI_PATTERN = '/file/info?file={0}' + _DOWNLOAD_TICKET_URI_PATTERN = '/file/dlticket?file=%s' + _DOWNLOAD_FILE_URI_PATTERN = '/file/dl?file=%s&ticket=%s' + _FILE_INFO_URI_PATTERN = '/file/info?file=%s' OFFLINE_PATTERN = r'>We are sorry' @@ -43,7 +43,7 @@ class OpenloadIo(SimpleHoster): @classmethod def api_info(cls, url): file_id = re.match(cls.__pattern__, url).group('ID') - info_json = cls._load_json(cls._FILE_INFO_URI_PATTERN.format(file_id)) + info_json = cls._load_json(cls._FILE_INFO_URI_PATTERN % file_id) file_info = info_json['result'][file_id] return {'name': file_info['name'], @@ -59,7 +59,7 @@ class OpenloadIo(SimpleHoster): # If the link is being handled here, then it matches the file_id_pattern, # therefore, we can call [0] safely. file_id = self.info['pattern']['ID'] - ticket_json = self._load_json(self._DOWNLOAD_TICKET_URI_PATTERN.format(file_id)) + ticket_json = self._load_json(self._DOWNLOAD_TICKET_URI_PATTERN % file_id) if ticket_json['status'] == 404: self.offline(ticket_json['msg']) @@ -74,5 +74,5 @@ class OpenloadIo(SimpleHoster): ticket = ticket_json['result']['ticket'] - download_json = self._load_json(self._DOWNLOAD_FILE_URI_PATTERN.format(file_id, ticket)) + download_json = self._load_json(self._DOWNLOAD_FILE_URI_PATTERN % (file_id, ticket)) self.link = download_json['result']['url'] |