diff options
34 files changed, 120 insertions, 144 deletions
diff --git a/module/plugins/accounts/YibaishiwuCom.py b/module/plugins/accounts/YibaishiwuCom.py index 863588495..33602a2fe 100644 --- a/module/plugins/accounts/YibaishiwuCom.py +++ b/module/plugins/accounts/YibaishiwuCom.py @@ -23,7 +23,7 @@ class YibaishiwuCom(Account): html = req.load("http://115.com/", decode=True) m = re.search(self.ACCOUNT_INFO_PATTERN, html, re.S) - premium = True if (m and 'is_vip: 1' in m.group(1)) else False + premium = True if m and 'is_vip: 1' in m.group(1) else False validuntil = trafficleft = (-1 if m else 0) return dict({"validuntil": validuntil, "trafficleft": trafficleft, "premium": premium}) diff --git a/module/plugins/crypter/DailymotionBatch.py b/module/plugins/crypter/DailymotionBatch.py index 8d4cb64df..82b80ab2f 100644 --- a/module/plugins/crypter/DailymotionBatch.py +++ b/module/plugins/crypter/DailymotionBatch.py @@ -24,9 +24,9 @@ class DailymotionBatch(Crypter): def api_response(self, ref, req=None): - url = urljoin("https://api.dailymotion.com/", ref) - page = self.load(url, get=req) - return json_loads(page) + url = urljoin("https://api.dailymotion.com/", ref) + html = self.load(url, get=req) + return json_loads(html) def getPlaylistInfo(self, id): diff --git a/module/plugins/crypter/FilecryptCc.py b/module/plugins/crypter/FilecryptCc.py index 6773ce9b6..d15d2ae4b 100644 --- a/module/plugins/crypter/FilecryptCc.py +++ b/module/plugins/crypter/FilecryptCc.py @@ -174,7 +174,7 @@ class FilecryptCc(Crypter): text = obj.decrypt(crypted.decode('base64')) # Extract links - links = filter(lambda x: x != "", - text.replace("\x00", "").replace("\r", "").split("\n")) + text = text.replace("\x00", "").replace("\r", "") + links = filter(bool, text.split('\n')) return links diff --git a/module/plugins/crypter/LinkCryptWs.py b/module/plugins/crypter/LinkCryptWs.py index 098f2542f..018ed90ba 100644 --- a/module/plugins/crypter/LinkCryptWs.py +++ b/module/plugins/crypter/LinkCryptWs.py @@ -314,8 +314,7 @@ class LinkCryptWs(Crypter): # Extract links text = text.replace("\x00", "").replace("\r", "") - links = text.split("\n") - links = filter(lambda x: x != "", links) + links = filter(bool, text.split('\n')) # Log and return self.logDebug("Package has %d links" % len(links)) diff --git a/module/plugins/crypter/NCryptIn.py b/module/plugins/crypter/NCryptIn.py index ecb913586..20e7c72e2 100644 --- a/module/plugins/crypter/NCryptIn.py +++ b/module/plugins/crypter/NCryptIn.py @@ -303,8 +303,7 @@ class NCryptIn(Crypter): # Extract links text = text.replace("\x00", "").replace("\r", "") - links = text.split("\n") - links = filter(lambda x: x != "", links) + links = filter(bool, text.split('\n')) # Log and return self.logDebug("Block has %d links" % len(links)) diff --git a/module/plugins/crypter/RelinkUs.py b/module/plugins/crypter/RelinkUs.py index 860dff06b..c50481af0 100644 --- a/module/plugins/crypter/RelinkUs.py +++ b/module/plugins/crypter/RelinkUs.py @@ -286,8 +286,7 @@ class RelinkUs(Crypter): # Extract links text = text.replace("\x00", "").replace("\r", "") - links = text.split("\n") - links = filter(lambda x: x != "", links) + links = filter(bool, text.split('\n')) # Log and return self.logDebug("Package has %d links" % len(links)) diff --git a/module/plugins/crypter/ShareLinksBiz.py b/module/plugins/crypter/ShareLinksBiz.py index d79735d42..00a037b2e 100644 --- a/module/plugins/crypter/ShareLinksBiz.py +++ b/module/plugins/crypter/ShareLinksBiz.py @@ -272,8 +272,7 @@ class ShareLinksBiz(Crypter): # Extract links text = text.replace("\x00", "").replace("\r", "") - links = text.split("\n") - links = filter(lambda x: x != "", links) + links = filter(bool, text.split('\n')) # Log and return self.logDebug("Block has %d links" % len(links)) diff --git a/module/plugins/crypter/YoutubeBatch.py b/module/plugins/crypter/YoutubeBatch.py index 73ebf5fb3..40b4eedd2 100644 --- a/module/plugins/crypter/YoutubeBatch.py +++ b/module/plugins/crypter/YoutubeBatch.py @@ -31,9 +31,9 @@ class YoutubeBatch(Crypter): def api_response(self, ref, req): req.update({"key": self.API_KEY}) - url = urljoin("https://www.googleapis.com/youtube/v3/", ref) - page = self.load(url, get=req) - return json_loads(page) + url = urljoin("https://www.googleapis.com/youtube/v3/", ref) + html = self.load(url, get=req) + return json_loads(html) def getChannel(self, user): diff --git a/module/plugins/hooks/AlldebridCom.py b/module/plugins/hooks/AlldebridCom.py index dddd97c0c..fd89571eb 100644 --- a/module/plugins/hooks/AlldebridCom.py +++ b/module/plugins/hooks/AlldebridCom.py @@ -24,6 +24,6 @@ class AlldebridCom(MultiHook): def getHosters(self): https = "https" if self.getConfig("ssl") else "http" - page = self.getURL(https + "://www.alldebrid.com/api.php", get={'action': "get_host"}).replace("\"", "").strip() + html = self.getURL(https + "://www.alldebrid.com/api.php", get={'action': "get_host"}).replace("\"", "").strip() - return [x.strip() for x in page.split(",") if x.strip()] + return [x.strip() for x in html.split(",") if x.strip()] diff --git a/module/plugins/hooks/Captcha9Kw.py b/module/plugins/hooks/Captcha9Kw.py index 1031ef224..544965b0f 100644 --- a/module/plugins/hooks/Captcha9Kw.py +++ b/module/plugins/hooks/Captcha9Kw.py @@ -206,9 +206,9 @@ class Captcha9Kw(Hook): for d in details: hosteroption = d.split("=") - if (len(hosteroption) > 1 - and hosteroption[0].lower() == 'timeout' - and hosteroption[1].isdigit()): + if len(hosteroption) > 1 \ + and hosteroption[0].lower() == 'timeout' \ + and hosteroption[1].isdigit(): timeout = int(hosteroption[1]) break diff --git a/module/plugins/hooks/EasybytezCom.py b/module/plugins/hooks/EasybytezCom.py index e08127514..85c616054 100644 --- a/module/plugins/hooks/EasybytezCom.py +++ b/module/plugins/hooks/EasybytezCom.py @@ -27,6 +27,6 @@ class EasybytezCom(MultiHook): user, data = self.account.selectAccount() req = self.account.getAccountRequest(user) - page = req.load("http://www.easybytez.com") + html = req.load("http://www.easybytez.com") - return re.search(r'</textarea>\s*Supported sites:(.*)', page).group(1).split(',') + return re.search(r'</textarea>\s*Supported sites:(.*)', html).group(1).split(',') diff --git a/module/plugins/hooks/FastixRu.py b/module/plugins/hooks/FastixRu.py index 25126fbd3..6373da8d9 100644 --- a/module/plugins/hooks/FastixRu.py +++ b/module/plugins/hooks/FastixRu.py @@ -23,9 +23,9 @@ class FastixRu(MultiHook): def getHosters(self): - page = self.getURL("http://fastix.ru/api_v2", + html = self.getURL("http://fastix.ru/api_v2", get={'apikey': "5182964c3f8f9a7f0b00000a_kelmFB4n1IrnCDYuIFn2y", 'sub' : "allowed_sources"}) - host_list = json_loads(page) + host_list = json_loads(html) host_list = host_list['allow'] return host_list diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py index 98fa1d030..623f2d1bf 100644 --- a/module/plugins/hooks/IRCInterface.py +++ b/module/plugins/hooks/IRCInterface.py @@ -79,10 +79,10 @@ class IRCInterface(Thread, Hook): task.handler.append(self) task.setWaiting(60) - page = getURL("http://www.freeimagehosting.net/upload.php", + html = getURL("http://www.freeimagehosting.net/upload.php", post={"attached": (FORM_FILE, task.captchaFile)}, multipart=True) - url = re.search(r"\[img\]([^\[]+)\[/img\]\[/url\]", page).group(1) + url = re.search(r"\[img\]([^\[]+)\[/img\]\[/url\]", html).group(1) self.response(_("New Captcha Request: %s") % url) self.response(_("Answer with 'c %s text on the captcha'") % task.id) diff --git a/module/plugins/hooks/MultishareCz.py b/module/plugins/hooks/MultishareCz.py index 8349e0de8..d02f4f8e3 100644 --- a/module/plugins/hooks/MultishareCz.py +++ b/module/plugins/hooks/MultishareCz.py @@ -27,5 +27,5 @@ class MultishareCz(MultiHook): def getHosters(self): - page = self.getURL("http://www.multishare.cz/monitoring/") - return re.findall(self.HOSTER_PATTERN, page) + html = self.getURL("http://www.multishare.cz/monitoring/") + return re.findall(self.HOSTER_PATTERN, html) diff --git a/module/plugins/hooks/OverLoadMe.py b/module/plugins/hooks/OverLoadMe.py index 1872f8ccb..b15ce2766 100644 --- a/module/plugins/hooks/OverLoadMe.py +++ b/module/plugins/hooks/OverLoadMe.py @@ -24,8 +24,8 @@ class OverLoadMe(MultiHook): def getHosters(self): https = "https" if self.getConfig("ssl") else "http" - page = self.getURL(https + "://api.over-load.me/hoster.php", + html = self.getURL(https + "://api.over-load.me/hoster.php", get={'auth': "0001-cb1f24dadb3aa487bda5afd3b76298935329be7700cd7-5329be77-00cf-1ca0135f"}).replace("\"", "").strip() - self.logDebug("Hosterlist", page) + self.logDebug("Hosterlist", html) - return [x.strip() for x in page.split(",") if x.strip()] + return [x.strip() for x in html.split(",") if x.strip()] diff --git a/module/plugins/hooks/PremiumTo.py b/module/plugins/hooks/PremiumTo.py index 844ecc89d..b629b111e 100644 --- a/module/plugins/hooks/PremiumTo.py +++ b/module/plugins/hooks/PremiumTo.py @@ -24,6 +24,6 @@ class PremiumTo(MultiHook): def getHosters(self): - page = self.getURL("http://premium.to/api/hosters.php", + html = self.getURL("http://premium.to/api/hosters.php", get={'username': self.account.username, 'password': self.account.password}) - return [x.strip() for x in page.replace("\"", "").split(";")] + return [x.strip() for x in html.replace("\"", "").split(";")] diff --git a/module/plugins/hooks/RealdebridCom.py b/module/plugins/hooks/RealdebridCom.py index cff97c2f9..d9c9407dd 100644 --- a/module/plugins/hooks/RealdebridCom.py +++ b/module/plugins/hooks/RealdebridCom.py @@ -24,6 +24,6 @@ class RealdebridCom(MultiHook): def getHosters(self): https = "https" if self.getConfig("ssl") else "http" - page = self.getURL(https + "://real-debrid.com/api/hosters.php").replace("\"", "").strip() + html = self.getURL(https + "://real-debrid.com/api/hosters.php").replace("\"", "").strip() - return [x.strip() for x in page.split(",") if x.strip()] + return [x.strip() for x in html.split(",") if x.strip()] diff --git a/module/plugins/hooks/RehostTo.py b/module/plugins/hooks/RehostTo.py index ddb8b3eb0..845601c3f 100644 --- a/module/plugins/hooks/RehostTo.py +++ b/module/plugins/hooks/RehostTo.py @@ -23,7 +23,7 @@ class RehostTo(MultiHook): def getHosters(self): user, data = self.account.selectAccount() - page = self.getURL("http://rehost.to/api.php", + html = self.getURL("http://rehost.to/api.php", get={'cmd' : "get_supported_och_dl", 'long_ses': self.account.getAccountInfo(user)['session']}) - return [x.strip() for x in page.replace("\"", "").split(",")] + return [x.strip() for x in html.replace("\"", "").split(",")] diff --git a/module/plugins/hooks/SimplydebridCom.py b/module/plugins/hooks/SimplydebridCom.py index 10c613fb5..4d27f5ae4 100644 --- a/module/plugins/hooks/SimplydebridCom.py +++ b/module/plugins/hooks/SimplydebridCom.py @@ -22,5 +22,5 @@ class SimplydebridCom(MultiHook): def getHosters(self): - page = self.getURL("http://simply-debrid.com/api.php", get={'list': 1}) - return [x.strip() for x in page.rstrip(';').replace("\"", "").split(";")] + html = self.getURL("http://simply-debrid.com/api.php", get={'list': 1}) + return [x.strip() for x in html.rstrip(';').replace("\"", "").split(";")] diff --git a/module/plugins/hoster/AlldebridCom.py b/module/plugins/hoster/AlldebridCom.py index 1fcb4d784..427eb42f0 100644 --- a/module/plugins/hoster/AlldebridCom.py +++ b/module/plugins/hoster/AlldebridCom.py @@ -63,9 +63,6 @@ class AlldebridCom(MultiHoster): else: self.link = self.link.replace("https://", "http://") - if self.link != pyfile.url: - self.logDebug("New URL: %s" % self.link) - if pyfile.name.startswith("http") or pyfile.name.startswith("Unknown"): #only use when name wasnt already set pyfile.name = self.getFilename(self.link) diff --git a/module/plugins/hoster/DailymotionCom.py b/module/plugins/hoster/DailymotionCom.py index cf75af3d2..02df9dde7 100644 --- a/module/plugins/hoster/DailymotionCom.py +++ b/module/plugins/hoster/DailymotionCom.py @@ -16,8 +16,8 @@ def getInfo(urls): for url in urls: id = regex.match(url).group('ID') - page = getURL(apiurl % id, get=request) - info = json_loads(page) + html = getURL(apiurl % id, get=request) + info = json_loads(html) name = info['title'] + ".mp4" if "title" in info else url diff --git a/module/plugins/hoster/FastixRu.py b/module/plugins/hoster/FastixRu.py index 9a38f5a72..d534101d8 100644 --- a/module/plugins/hoster/FastixRu.py +++ b/module/plugins/hoster/FastixRu.py @@ -39,20 +39,18 @@ class FastixRu(MultiHoster): api_key = self.account.getAccountData(self.user) api_key = api_key['api'] - page = self.load("http://fastix.ru/api_v2/", + self.html = self.load("http://fastix.ru/api_v2/", get={'apikey': api_key, 'sub': "getdirectlink", 'link': pyfile.url}) - data = json_loads(page) + + data = json_loads(self.html) self.logDebug("Json data", data) - if "error\":true" in page: + if "error\":true" in self.html: self.offline() else: self.link = data['downloadlink'] - if self.link != pyfile.url: - self.logDebug("New URL: %s" % self.link) - if pyfile.name.startswith("http") or pyfile.name.startswith("Unknown"): #only use when name wasnt already set pyfile.name = self.getFilename(self.link) diff --git a/module/plugins/hoster/FilepostCom.py b/module/plugins/hoster/FilepostCom.py index 25def94e8..21ebbc55e 100644 --- a/module/plugins/hoster/FilepostCom.py +++ b/module/plugins/hoster/FilepostCom.py @@ -112,9 +112,9 @@ class FilepostCom(SimpleHoster): self.retry(wait_time=res['js']['params']['next_download']) # ~? self.retry(wait_time=js_answer['params']['next_download']) - elif ('Wrong file password' in res['js']['error'] - or 'You entered a wrong CAPTCHA code' in res['js']['error'] - or 'CAPTCHA Code nicht korrekt' in res['js']['error']): + elif 'Wrong file password' in res['js']['error'] \ + or 'You entered a wrong CAPTCHA code' in res['js']['error'] \ + or 'CAPTCHA Code nicht korrekt' in res['js']['error']: return None elif 'CAPTCHA' in res['js']['error']: diff --git a/module/plugins/hoster/MegaDebridEu.py b/module/plugins/hoster/MegaDebridEu.py index 8bbc733e0..b42362800 100644 --- a/module/plugins/hoster/MegaDebridEu.py +++ b/module/plugins/hoster/MegaDebridEu.py @@ -35,10 +35,9 @@ class MegaDebridEu(MultiHoster): self.exitOnFail("Unable to connect to Mega-debrid.eu") self.link = self.debridLink(pyfile.url) - self.logDebug("New URL: " + self.link) filename = self.getFilename(self.link) - if filename != "": + if filename: pyfile.name = filename diff --git a/module/plugins/hoster/MyfastfileCom.py b/module/plugins/hoster/MyfastfileCom.py index 5ea2639f1..dd6294ff1 100644 --- a/module/plugins/hoster/MyfastfileCom.py +++ b/module/plugins/hoster/MyfastfileCom.py @@ -23,19 +23,16 @@ class MyfastfileCom(MultiHoster): def handlePremium(self, pyfile): - self.logDebug("Original URL: %s" % pyfile.url) - - page = self.load('http://myfastfile.com/api.php', + self.html = self.load('http://myfastfile.com/api.php', get={'user': self.user, 'pass': self.account.getAccountData(self.user)['password'], 'link': pyfile.url}) - self.logDebug("JSON data: " + page) - page = json_loads(page) - if page['status'] != 'ok': + self.logDebug("JSON data: " + self.html) + + self.html = json_loads(self.html) + if self.html['status'] != 'ok': self.fail(_("Unable to unrestrict link")) - self.link = page['link'] - if self.link != pyfile.url: - self.logDebug("Unrestricted URL: " + self.link) + self.link = self.html['link'] getInfo = create_getInfo(MyfastfileCom) diff --git a/module/plugins/hoster/OverLoadMe.py b/module/plugins/hoster/OverLoadMe.py index d4f4c0135..67563ca3d 100644 --- a/module/plugins/hoster/OverLoadMe.py +++ b/module/plugins/hoster/OverLoadMe.py @@ -46,6 +46,7 @@ class OverLoadMe(MultiHoster): 'link': pyfile.url}) data = json_loads(page) + self.logDebug(data) if data['error'] == 1: @@ -59,9 +60,6 @@ class OverLoadMe(MultiHoster): http_repl = ["http://", "https://"] self.link = data['downloadlink'].replace(*http_repl if self.getConfig("ssl") else *http_repl[::-1]) - if self.link != pyfile.url: - self.logDebug("New URL: %s" % self.link) - if pyfile.name.startswith("http") or pyfile.name.startswith("Unknown") or pyfile.name.endswith('..'): # only use when name wasn't already set pyfile.name = self.getFilename(self.link) diff --git a/module/plugins/hoster/PornhostCom.py b/module/plugins/hoster/PornhostCom.py index 71342f3e0..0c3b84a9d 100644 --- a/module/plugins/hoster/PornhostCom.py +++ b/module/plugins/hoster/PornhostCom.py @@ -73,8 +73,7 @@ class PornhostCom(Hoster): if not self.html: self.download_html() - if (re.search(r'gallery not found', self.html) is not None or - re.search(r'You will be redirected to', self.html) is not None): + if re.search(r'gallery not found|You will be redirected to', self.html): return False else: return True diff --git a/module/plugins/hoster/RPNetBiz.py b/module/plugins/hoster/RPNetBiz.py index 13c2f8776..8ab8cb7c4 100644 --- a/module/plugins/hoster/RPNetBiz.py +++ b/module/plugins/hoster/RPNetBiz.py @@ -25,7 +25,6 @@ class RPNetBiz(MultiHoster): def handlePremium(self, pyfile): user, data = self.account.selectAccount() - self.logDebug("Original URL: %s" % pyfile.url) # Get the download link res = self.load("https://premium.rpnet.biz/client_api.php", get={"username": user, diff --git a/module/plugins/hoster/RealdebridCom.py b/module/plugins/hoster/RealdebridCom.py index bf9fda293..d0010b3bd 100644 --- a/module/plugins/hoster/RealdebridCom.py +++ b/module/plugins/hoster/RealdebridCom.py @@ -63,9 +63,6 @@ class RealdebridCom(MultiHoster): else: self.link = self.link.replace("https://", "http://") - if self.link != pyfile.url: - self.logDebug("New URL: %s" % self.link) - if pyfile.name.startswith("http") or pyfile.name.startswith("Unknown") or pyfile.name.endswith('..'): #only use when name wasnt already set pyfile.name = self.getFilename(self.link) diff --git a/module/plugins/hoster/SimplyPremiumCom.py b/module/plugins/hoster/SimplyPremiumCom.py index 39e8a6aeb..a87e7533f 100644 --- a/module/plugins/hoster/SimplyPremiumCom.py +++ b/module/plugins/hoster/SimplyPremiumCom.py @@ -24,53 +24,58 @@ class SimplyPremiumCom(MultiHoster): self.chunkLimit = 16 - def handlePremium(self, pyfile): - for i in xrange(5): - page = self.load("http://www.simply-premium.com/premium.php", get={'info': "", 'link': self.pyfile.url}) - self.logDebug("JSON data: " + page) - if page != '': - break - else: - self.logInfo(_("Unable to get API data, waiting 1 minute and retry")) - self.retry(5, 60, "Unable to get API data") - - if '<valid>0</valid>' in page or ( - "You are not allowed to download from this host" in page and self.premium): + def checkErrors(self): + if '<valid>0</valid>' in self.html or ( + "You are not allowed to download from this host" in self.html and self.premium): self.account.relogin(self.user) self.retry() - elif "NOTFOUND" in page: + elif "NOTFOUND" in self.html: self.offline() - elif "downloadlimit" in page: + elif "downloadlimit" in self.html: self.logWarning(_("Reached maximum connctions")) - self.retry(5, 60, "Reached maximum connctions") + self.retry(5, 60, _("Reached maximum connctions")) - elif "trafficlimit" in page: + elif "trafficlimit" in self.html: self.logWarning(_("Reached daily limit for this host")) self.retry(wait_time=secondsToMidnight(gmt=2), reason="Daily limit for this host reached") - elif "hostererror" in page: + elif "hostererror" in self.html: self.logWarning(_("Hoster temporarily unavailable, waiting 1 minute and retry")) - self.retry(5, 60, "Hoster is temporarily unavailable") + self.retry(5, 60, _("Hoster is temporarily unavailable")) + + + def handlePremium(self, pyfile): + for i in xrange(5): + self.html = self.load("http://www.simply-premium.com/premium.php", get={'info': "", 'link': self.pyfile.url}) + + if self.html: + self.logDebug("JSON data: " + self.html) + break + else: + self.logInfo(_("Unable to get API data, waiting 1 minute and retry")) + self.retry(5, 60, _("Unable to get API data")) + + self.checkErrors() try: - self.pyfile.name = re.search(r'<name>([^<]+)</name>', page).group(1) + self.pyfile.name = re.search(r'<name>([^<]+)</name>', self.html).group(1) + except AttributeError: self.pyfile.name = "" try: - self.pyfile.size = re.search(r'<size>(\d+)</size>', page).group(1) + self.pyfile.size = re.search(r'<size>(\d+)</size>', self.html).group(1) + except AttributeError: self.pyfile.size = 0 try: - self.link = re.search(r'<download>([^<]+)</download>', page).group(1) + self.link = re.search(r'<download>([^<]+)</download>', self.html).group(1) + except AttributeError: self.link = 'http://www.simply-premium.com/premium.php?link=' + self.pyfile.url - if self.link != self.pyfile.url: - self.logDebug("New URL: " + self.link) - getInfo = create_getInfo(SimplyPremiumCom) diff --git a/module/plugins/hoster/SimplydebridCom.py b/module/plugins/hoster/SimplydebridCom.py index a26bc5751..24811d6aa 100644 --- a/module/plugins/hoster/SimplydebridCom.py +++ b/module/plugins/hoster/SimplydebridCom.py @@ -2,7 +2,7 @@ import re -from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo +from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo, replace_patterns class SimplydebridCom(MultiHoster): @@ -19,35 +19,28 @@ class SimplydebridCom(MultiHoster): def handlePremium(self, pyfile): #fix the links for simply-debrid.com! - self.link = pyfile.url - self.link = self.link.replace("clz.to", "cloudzer.net/file") - self.link = self.link.replace("http://share-online", "http://www.share-online") - self.link = self.link.replace("ul.to", "uploaded.net/file") - self.link = self.link.replace("uploaded.com", "uploaded.net") - self.link = self.link.replace("filerio.com", "filerio.in") - self.link = self.link.replace("lumfile.com", "lumfile.se") - - if('fileparadox' in self.link): + self.link = replace_patterns(pyfile.url, [("clz.to", "cloudzer.net/file") + ("http://share-online", "http://www.share-online") + ("ul.to", "uploaded.net/file") + ("uploaded.com", "uploaded.net") + ("filerio.com", "filerio.in") + ("lumfile.com", "lumfile.se")] + + if 'fileparadox' in self.link: self.link = self.link.replace("http://", "https://") - if re.match(self.__pattern__, self.link): - self.link = self.link + self.html = self.load("http://simply-debrid.com/api.php", get={'dl': self.link}) + if 'tiger Link' in self.html or 'Invalid Link' in self.html or ('API' in self.html and 'ERROR' in self.html): + self.error(_("Unable to unrestrict link")) - self.logDebug("New URL: %s" % self.link) + self.link = self.html - if not re.match(self.__pattern__, self.link): - page = self.load("http://simply-debrid.com/api.php", get={'dl': self.link}) - if 'tiger Link' in page or 'Invalid Link' in page or ('API' in page and 'ERROR' in page): - self.fail(_("Unable to unrestrict link")) - self.link = page - - self.setWait(5) - self.wait() + self.wait(5) def checkFile(self): if self.checkDownload({"error": "No address associated with hostname"}): - self.retry(24, 3 * 60, "Bad file downloaded") + self.retry(24, 3 * 60, _("Bad file downloaded")) return super(SimplydebridCom, self).checkFile() diff --git a/module/plugins/hoster/SoundcloudCom.py b/module/plugins/hoster/SoundcloudCom.py index 3eb546604..c7c9c3880 100644 --- a/module/plugins/hoster/SoundcloudCom.py +++ b/module/plugins/hoster/SoundcloudCom.py @@ -21,8 +21,8 @@ class SoundcloudCom(Hoster): def process(self, pyfile): # default UserAgent of HTTPRequest fails for this hoster so we use this one self.req.http.c.setopt(pycurl.USERAGENT, 'Mozilla/5.0') - page = self.load(pyfile.url) - m = re.search(r'<div class="haudio.*?large.*?" data-sc-track="(?P<ID>\d*)"', page) + self.html = self.load(pyfile.url) + m = re.search(r'<div class="haudio.*?large.*?" data-sc-track="(?P<ID>\d*)"', self.html) songId = clientId = "" if m: songId = m.group('ID') @@ -30,27 +30,27 @@ class SoundcloudCom(Hoster): self.logError(_("Could not find song id")) self.offline() else: - m = re.search(r'"clientID":"(?P<CID>.*?)"', page) + m = re.search(r'"clientID":"(?P<CID>.*?)"', self.html) if m: clientId = m.group('CID') if len(clientId) <= 0: clientId = "b45b1aa10f1ac2941910a7f0d10f8e28" - m = re.search(r'<em itemprop="name">\s(?P<TITLE>.*?)\s</em>', page) + m = re.search(r'<em itemprop="name">\s(?P<TITLE>.*?)\s</em>', self.html) if m: pyfile.name = m.group('TITLE') + ".mp3" else: pyfile.name = re.match(self.__pattern__, pyfile.url).group('SID') + ".mp3" # url to retrieve the actual song url - page = self.load("https://api.sndcdn.com/i1/tracks/%s/streams" % songId, get={"client_id": clientId}) + self.html = self.load("https://api.sndcdn.com/i1/tracks/%s/streams" % songId, get={"client_id": clientId}) # getting streams # for now we choose the first stream found in all cases # it could be improved if relevant for this hoster streams = [ (result.group('QUALITY'), result.group('URL')) - for result in re.finditer(r'"(?P<QUALITY>.*?)":"(?P<URL>.*?)"', page) + for result in re.finditer(r'"(?P<QUALITY>.*?)":"(?P<URL>.*?)"', self.html) ] self.logDebug("Found Streams", streams) self.logDebug("Downloading", streams[0][0], streams[0][1]) diff --git a/module/plugins/hoster/UnrestrictLi.py b/module/plugins/hoster/UnrestrictLi.py index e87f9b97f..99fe01257 100644 --- a/module/plugins/hoster/UnrestrictLi.py +++ b/module/plugins/hoster/UnrestrictLi.py @@ -29,40 +29,39 @@ class UnrestrictLi(MultiHoster): def handleFree(self, pyfile): for _i in xrange(5): - page = self.load('https://unrestrict.li/unrestrict.php', + self.html = self.load('https://unrestrict.li/unrestrict.php', post={'link': pyfile.url, 'domain': 'long'}) - self.logDebug("JSON data: " + page) - if page != '': + + self.logDebug("JSON data: " + self.html) + + if self.html: break else: self.logInfo(_("Unable to get API data, waiting 1 minute and retry")) self.retry(5, 60, "Unable to get API data") - if 'Expired session' in page or ("You are not allowed to " - "download from this host" in page and self.premium): + if 'Expired session' in self.html \ + or ("You are not allowed to download from this host" in self.html and self.premium): self.account.relogin(self.user) self.retry() - elif "File offline" in page: + elif "File offline" in self.html: self.offline() - elif "You are not allowed to download from this host" in page: + elif "You are not allowed to download from this host" in self.html: self.fail(_("You are not allowed to download from this host")) - elif "You have reached your daily limit for this host" in page: + elif "You have reached your daily limit for this host" in self.html: self.logWarning(_("Reached daily limit for this host")) self.retry(5, secondsToMidnight(gmt=2), "Daily limit for this host reached") - elif "ERROR_HOSTER_TEMPORARILY_UNAVAILABLE" in page: + elif "ERROR_HOSTER_TEMPORARILY_UNAVAILABLE" in self.html: self.logInfo(_("Hoster temporarily unavailable, waiting 1 minute and retry")) self.retry(5, 60, "Hoster is temporarily unavailable") - page = json_loads(page) - self.link = page.keys()[0] - self.api_data = page[self.link] - - if self.link != pyfile.url: - self.logDebug("New URL: " + self.link) + self.html = json_loads(self.html) + self.link = self.html.keys()[0] + self.api_data = self.html[self.link] if hasattr(self, 'api_data'): self.setNameSize() diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 0ac49de19..ca8fce05f 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -667,8 +667,7 @@ class SimpleHoster(Hoster): self.logInfo(_("Download limit reached, reconnect or wait %s") % time_str) - self.setWait(wait_time, True) - self.wait() + self.wait(wait_time, True) self.retry(max_tries=max_tries, reason=_("Download limit reached")) |