diff options
author | Walter Purcaro <vuolter@gmail.com> | 2015-02-08 02:09:45 +0100 |
---|---|---|
committer | Walter Purcaro <vuolter@gmail.com> | 2015-02-08 02:15:53 +0100 |
commit | b25bc61dd47d8d3c42969bd0f72443b21c4b059e (patch) | |
tree | 6115841c9763289bd400c6171508f397d3526bf5 /module/plugins/hoster | |
parent | [ZippyshareCom] Typo (diff) | |
download | pyload-b25bc61dd47d8d3c42969bd0f72443b21c4b059e.tar.xz |
Spare code cosmetics
Diffstat (limited to 'module/plugins/hoster')
-rw-r--r-- | module/plugins/hoster/AlldebridCom.py | 3 | ||||
-rw-r--r-- | module/plugins/hoster/DailymotionCom.py | 4 | ||||
-rw-r--r-- | module/plugins/hoster/FastixRu.py | 10 | ||||
-rw-r--r-- | module/plugins/hoster/FilepostCom.py | 6 | ||||
-rw-r--r-- | module/plugins/hoster/MegaDebridEu.py | 3 | ||||
-rw-r--r-- | module/plugins/hoster/MyfastfileCom.py | 15 | ||||
-rw-r--r-- | module/plugins/hoster/OverLoadMe.py | 4 | ||||
-rw-r--r-- | module/plugins/hoster/PornhostCom.py | 3 | ||||
-rw-r--r-- | module/plugins/hoster/RPNetBiz.py | 1 | ||||
-rw-r--r-- | module/plugins/hoster/RealdebridCom.py | 3 | ||||
-rw-r--r-- | module/plugins/hoster/SimplyPremiumCom.py | 53 | ||||
-rw-r--r-- | module/plugins/hoster/SimplydebridCom.py | 37 | ||||
-rw-r--r-- | module/plugins/hoster/SoundcloudCom.py | 12 | ||||
-rw-r--r-- | module/plugins/hoster/UnrestrictLi.py | 29 |
14 files changed, 82 insertions, 101 deletions
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() |