diff options
author | Walter Purcaro <vuolter@gmail.com> | 2014-07-20 03:25:14 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@gmail.com> | 2014-07-20 03:25:14 +0200 |
commit | 05d258d98dd8c2faf0b769840fa1e3c4acccdce8 (patch) | |
tree | 20d379639d14a2b69deaa9e0376e33312b5bb994 /module | |
parent | [ShareRapidCom] Fix https://github.com/pyload/pyload/issues/694 (diff) | |
download | pyload-05d258d98dd8c2faf0b769840fa1e3c4acccdce8.tar.xz |
Fix and improve 5060e4c6374a5116d0d8b02528f910f8c5f8bcf9
Diffstat (limited to 'module')
80 files changed, 197 insertions, 214 deletions
diff --git a/module/plugins/accounts/CzshareCom.py b/module/plugins/accounts/CzshareCom.py index 92d0e61e8..3b1989591 100644 --- a/module/plugins/accounts/CzshareCom.py +++ b/module/plugins/accounts/CzshareCom.py @@ -37,7 +37,7 @@ class CzshareCom(Account): html = req.load("http://sdilej.cz/prehled_kreditu/") found = re.search(self.CREDIT_LEFT_PATTERN, html) - if not found: + if found is None: return {"validuntil": 0, "trafficleft": 0} else: credits = float(found.group(1).replace(' ', '').replace(',', '.')) diff --git a/module/plugins/accounts/EuroshareEu.py b/module/plugins/accounts/EuroshareEu.py index f7ff456f9..4123b520f 100644 --- a/module/plugins/accounts/EuroshareEu.py +++ b/module/plugins/accounts/EuroshareEu.py @@ -36,7 +36,7 @@ class EuroshareEu(Account): html = req.load("http://euroshare.eu/customer-zone/settings/") found = re.search('id="input_expire_date" value="(\d+\.\d+\.\d+ \d+:\d+)"', html) - if not found: + if found is None: premium, validuntil = False, -1 else: premium = True diff --git a/module/plugins/accounts/HellshareCz.py b/module/plugins/accounts/HellshareCz.py index bf98dcadb..dfe5b57d8 100644 --- a/module/plugins/accounts/HellshareCz.py +++ b/module/plugins/accounts/HellshareCz.py @@ -38,7 +38,7 @@ class HellshareCz(Account): html = req.load("http://www.hellshare.com/") found = re.search(self.CREDIT_LEFT_PATTERN, html) - if not found: + if found is None: trafficleft = None validuntil = None premium = False diff --git a/module/plugins/crypter/CzshareComFolder.py b/module/plugins/crypter/CzshareComFolder.py index e0c311ba8..76762b69b 100644 --- a/module/plugins/crypter/CzshareComFolder.py +++ b/module/plugins/crypter/CzshareComFolder.py @@ -23,7 +23,7 @@ class CzshareComFolder(Crypter): html = self.load(pyfile.url) found = re.search(self.FOLDER_PATTERN, html, re.DOTALL) - if not found: + if found is None: self.fail("Parse error (FOLDER)") self.urls.extend(re.findall(self.LINK_PATTERN, found.group(1))) diff --git a/module/plugins/crypter/DuckCryptInfo.py b/module/plugins/crypter/DuckCryptInfo.py index aa3a6d2a1..8203f0978 100644 --- a/module/plugins/crypter/DuckCryptInfo.py +++ b/module/plugins/crypter/DuckCryptInfo.py @@ -28,7 +28,7 @@ class DuckCryptInfo(Crypter): # self.logDebug("Sleeping for" % found.group(1)) # self.setWait(int(found.group(1)) ,False) found = re.match(self.__pattern__, url) - if not found: + if found is None: self.fail('Weird error in link') if str(found.group(1)) == "link": self.handleLink(url) diff --git a/module/plugins/crypter/FileserveComFolder.py b/module/plugins/crypter/FileserveComFolder.py index 28d89c75d..4a0d5a416 100644 --- a/module/plugins/crypter/FileserveComFolder.py +++ b/module/plugins/crypter/FileserveComFolder.py @@ -26,7 +26,7 @@ class FileserveComFolder(Crypter): new_links = [] folder = re.search(self.FOLDER_PATTERN, html, re.DOTALL) - if not folder: + if folder is None: self.fail("Parse error (FOLDER)") new_links.extend(re.findall(self.LINK_PATTERN, folder.group(1))) diff --git a/module/plugins/crypter/FreetexthostCom.py b/module/plugins/crypter/FreetexthostCom.py index d03805722..a6fb78d8e 100644 --- a/module/plugins/crypter/FreetexthostCom.py +++ b/module/plugins/crypter/FreetexthostCom.py @@ -33,7 +33,7 @@ class FreetexthostCom(SimpleCrypter): def getLinks(self): m = re.search(r'<div id="contentsinner">\s*(.+)<div class="viewcount">', self.html, re.DOTALL) - if not m: + if m is None: self.fail('Unable to extract links | Plugin may be out-of-date') links = m.group(1) return links.strip().split("<br />\r\n") diff --git a/module/plugins/crypter/HoerbuchIn.py b/module/plugins/crypter/HoerbuchIn.py index b46293bc7..88fc57244 100644 --- a/module/plugins/crypter/HoerbuchIn.py +++ b/module/plugins/crypter/HoerbuchIn.py @@ -39,7 +39,7 @@ class HoerbuchIn(Crypter): def decryptFolder(self, url): m = self.protection.search(url) - if not m: + if m is None: self.fail("Bad URL") url = m.group(0) diff --git a/module/plugins/crypter/LetitbitNetFolder.py b/module/plugins/crypter/LetitbitNetFolder.py index 19e780690..adb2918a6 100644 --- a/module/plugins/crypter/LetitbitNetFolder.py +++ b/module/plugins/crypter/LetitbitNetFolder.py @@ -23,7 +23,7 @@ class LetitbitNetFolder(Crypter): html = self.load(pyfile.url) folder = re.search(self.FOLDER_PATTERN, html, re.DOTALL) - if not folder: + if folder is None: self.fail("Parse error (FOLDER)") self.urls.extend(re.findall(self.LINK_PATTERN, folder.group(0))) diff --git a/module/plugins/crypter/LixIn.py b/module/plugins/crypter/LixIn.py index e609c9da4..a39173903 100644 --- a/module/plugins/crypter/LixIn.py +++ b/module/plugins/crypter/LixIn.py @@ -24,26 +24,26 @@ class LixIn(Crypter): def decrypt(self, pyfile): url = pyfile.url - matches = re.match(self.__pattern__, url) - if not matches: + m = re.match(self.__pattern__, url) + if m is None: self.fail("couldn't identify file id") - id = matches.group("id") + id = m.group("id") self.logDebug("File id is %s" % id) self.html = self.req.load(url, decode=True) - matches = re.search(self.SUBMIT_PATTERN, self.html) - if not matches: + m = re.search(self.SUBMIT_PATTERN, self.html) + if m is None: self.fail("link doesn't seem valid") - matches = re.search(self.CAPTCHA_PATTERN, self.html) - if matches: + m = re.search(self.CAPTCHA_PATTERN, self.html) + if m: for _ in xrange(5): - matches = re.search(self.CAPTCHA_PATTERN, self.html) - if matches: + m = re.search(self.CAPTCHA_PATTERN, self.html) + if m: self.logDebug("trying captcha") - captcharesult = self.decryptCaptcha("http://lix.in/" + matches.group("image")) + captcharesult = self.decryptCaptcha("http://lix.in/" + m.group("image")) self.html = self.req.load(url, decode=True, post={"capt": captcharesult, "submit": "submit", "tiny": id}) else: @@ -51,9 +51,9 @@ class LixIn(Crypter): else: self.html = self.req.load(url, decode=True, post={"submit": "submit", "tiny": id}) - matches = re.search(self.LINK_PATTERN, self.html) - if not matches: + m = re.search(self.LINK_PATTERN, self.html) + if m is None: self.fail("can't find destination url") else: - self.urls = [matches.group("link")] + self.urls = [m.group("link")] self.logDebug("Found link %s, adding to package" % self.urls[0]) diff --git a/module/plugins/crypter/MultiloadCz.py b/module/plugins/crypter/MultiloadCz.py index 0d5fa4c94..f93681be9 100644 --- a/module/plugins/crypter/MultiloadCz.py +++ b/module/plugins/crypter/MultiloadCz.py @@ -26,7 +26,7 @@ class MultiloadCz(Crypter): if re.match(self.__pattern__, pyfile.url).group(1) == "slozka": found = re.search(self.FOLDER_PATTERN, self.html) - if found is not None: + if found: self.urls.extend(found.group(1).split()) else: found = re.findall(self.LINK_PATTERN, self.html) diff --git a/module/plugins/crypter/NCryptIn.py b/module/plugins/crypter/NCryptIn.py index dc2f29519..f9953b994 100644 --- a/module/plugins/crypter/NCryptIn.py +++ b/module/plugins/crypter/NCryptIn.py @@ -100,20 +100,20 @@ class NCryptIn(Crypter): return True def isProtected(self): - form_match = re.search(r'<form.*?name.*?protected.*?>(.*?)</form>', self.cleanedHtml, re.DOTALL) - if form_match: - form_content = form_match.group(1) + form = re.search(r'<form.*?name.*?protected.*?>(.*?)</form>', self.cleanedHtml, re.DOTALL) + if form is not None: + content = form.group(1) for keyword in ("password", "captcha"): - if keyword in form_content: + if keyword in content: self.protection_type = keyword self.logDebug("Links are %s protected" % self.protection_type) return True return False def getPackageInfo(self): - m = re.search(self.NAME_PATTERN, self.html) - if m: - name = folder = m.group('N').strip() + found = re.search(self.NAME_PATTERN, self.html) + if found: + name = folder = found.group('N').strip() self.logDebug("Found name [%s] and folder [%s] in package info" % (name, folder)) else: name = self.package.name diff --git a/module/plugins/crypter/QuickshareCzFolder.py b/module/plugins/crypter/QuickshareCzFolder.py index b8db5d88c..e138b6f17 100644 --- a/module/plugins/crypter/QuickshareCzFolder.py +++ b/module/plugins/crypter/QuickshareCzFolder.py @@ -23,7 +23,7 @@ class QuickshareCzFolder(Crypter): html = self.load(pyfile.url) found = re.search(self.FOLDER_PATTERN, html, re.DOTALL) - if not found: + if found is None: self.fail("Parse error (FOLDER)") self.urls.extend(re.findall(self.LINK_PATTERN, found.group(1))) diff --git a/module/plugins/crypter/ShareLinksBiz.py b/module/plugins/crypter/ShareLinksBiz.py index 13327dd2b..b56f90e15 100644 --- a/module/plugins/crypter/ShareLinksBiz.py +++ b/module/plugins/crypter/ShareLinksBiz.py @@ -113,7 +113,7 @@ class ShareLinksBiz(Crypter): # Resolve captcha href = self._resolveCoords(coords, captchaMap) - if not href: + if href is None: self.logDebug("Invalid captcha resolving, retrying") self.invalidCaptcha() self.setWait(5, False) diff --git a/module/plugins/crypter/UlozToFolder.py b/module/plugins/crypter/UlozToFolder.py index f9ddd3c84..43dbb4807 100644 --- a/module/plugins/crypter/UlozToFolder.py +++ b/module/plugins/crypter/UlozToFolder.py @@ -27,7 +27,7 @@ class UlozToFolder(Crypter): for i in xrange(1, 100): self.logInfo("Fetching links from page %i" % i) found = re.search(self.FOLDER_PATTERN, html, re.DOTALL) - if not found: + if found is None: self.fail("Parse error (FOLDER)") new_links.extend(re.findall(self.LINK_PATTERN, found.group(1))) diff --git a/module/plugins/crypter/YoutubeBatch.py b/module/plugins/crypter/YoutubeBatch.py index dfac9140f..216fbb670 100644 --- a/module/plugins/crypter/YoutubeBatch.py +++ b/module/plugins/crypter/YoutubeBatch.py @@ -100,9 +100,9 @@ class YoutubeBatch(Crypter): return list(self._getVideosId(p_id)) def decrypt(self, pyfile): - match = re.match(self.__pattern__, pyfile.url) - m_id = match.group("ID") - m_type = match.group("TYPE") + m = re.match(self.__pattern__, pyfile.url) + m_id = m.group("ID") + m_type = m.group("TYPE") if m_type == "user": self.logDebug("Url recognized as Channel") diff --git a/module/plugins/hooks/DownloadScheduler.py b/module/plugins/hooks/DownloadScheduler.py index dbc1019e3..070c0634e 100644 --- a/module/plugins/hooks/DownloadScheduler.py +++ b/module/plugins/hooks/DownloadScheduler.py @@ -43,7 +43,7 @@ class DownloadScheduler(Hook): self.updateSchedule() def updateSchedule(self, schedule=None): - if not schedule: + if schedule is None: schedule = self.getConfig("timetable") schedule = re.findall("(\d{1,2}):(\d{2})[\s]*(-?\d+)", diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py index 9a9bab9b4..a29874469 100644 --- a/module/plugins/hooks/IRCInterface.py +++ b/module/plugins/hooks/IRCInterface.py @@ -59,12 +59,9 @@ class IRCInterface(Thread, Hook): self.api = core.api # todo, only use api def coreReady(self): - self.new_package = {} - self.abort = False - - self.links_added = 0 self.more = [] + self.new_package = {} self.start() diff --git a/module/plugins/hooks/LinkdecrypterCom.py b/module/plugins/hooks/LinkdecrypterCom.py index d6acac4a9..4e08372fe 100644 --- a/module/plugins/hooks/LinkdecrypterCom.py +++ b/module/plugins/hooks/LinkdecrypterCom.py @@ -43,7 +43,7 @@ class LinkdecrypterCom(Hook): def loadPatterns(self): page = getURL("http://linkdecrypter.com/") m = re.search(r'<b>Supported\(\d+\)</b>: <i>([^+<]*)', page) - if not m: + if m is None: self.logError(_("Crypter list not found")) return diff --git a/module/plugins/hoster/BayfilesCom.py b/module/plugins/hoster/BayfilesCom.py index a79f5c750..449bb890e 100644 --- a/module/plugins/hoster/BayfilesCom.py +++ b/module/plugins/hoster/BayfilesCom.py @@ -47,7 +47,7 @@ class BayfilesCom(SimpleHoster): # Get download token found = re.search(self.VARS_PATTERN, self.html) - if not found: + if found is None: self.parseError('VARS') vfid, delay = found.groups() @@ -68,13 +68,13 @@ class BayfilesCom(SimpleHoster): # Get final link and download found = re.search(self.FREE_LINK_PATTERN, self.html) - if not found: + if found is None: self.parseError("Free link") self.startDownload(found.group(1)) def handlePremium(self): found = re.search(self.PREMIUM_LINK_PATTERN, self.html) - if not found: + if found is None: self.parseError("Premium link") self.startDownload(found.group(1)) diff --git a/module/plugins/hoster/BezvadataCz.py b/module/plugins/hoster/BezvadataCz.py index 27959bfc1..d1c0fd87e 100644 --- a/module/plugins/hoster/BezvadataCz.py +++ b/module/plugins/hoster/BezvadataCz.py @@ -38,7 +38,7 @@ class BezvadataCz(SimpleHoster): def handleFree(self): #download button found = re.search(r'<a class="stahnoutSoubor".*?href="(.*?)"', self.html) - if not found: + if found is None: self.parseError("page1 URL") url = "http://bezvadata.cz%s" % found.group(1) @@ -51,7 +51,7 @@ class BezvadataCz(SimpleHoster): self.parseError("FreeForm") found = re.search(r'<img src="data:image/png;base64,(.*?)"', self.html) - if not found: + if found is None: self.parseError("captcha img") #captcha image is contained in html page as base64encoded data but decryptCaptcha() expects image url @@ -73,7 +73,7 @@ class BezvadataCz(SimpleHoster): self.html = self.load("http://bezvadata.cz%s" % action, post=inputs) self.checkErrors() found = re.search(r'<a class="stahnoutSoubor2" href="(.*?)">', self.html) - if not found: + if found is None: self.parseError("page2 URL") url = "http://bezvadata.cz%s" % found.group(1) self.logDebug("DL URL %s" % url) diff --git a/module/plugins/hoster/CrockoCom.py b/module/plugins/hoster/CrockoCom.py index 286d5ca2f..489baaeb4 100644 --- a/module/plugins/hoster/CrockoCom.py +++ b/module/plugins/hoster/CrockoCom.py @@ -42,12 +42,12 @@ class CrockoCom(SimpleHoster): break found = re.search(self.CAPTCHA_KEY_PATTERN, self.html) - if not found: + if found is None: self.parseError('Captcha KEY') captcha_key = found.group(1) found = re.search(self.FORM_PATTERN, self.html, re.DOTALL) - if not found: + if found is None: self.parseError('ACTION') action, form = found.groups() inputs = dict(re.findall(self.FORM_INPUT_PATTERN, form)) diff --git a/module/plugins/hoster/CzshareCom.py b/module/plugins/hoster/CzshareCom.py index 7866a771e..f66f1b5a2 100644 --- a/module/plugins/hoster/CzshareCom.py +++ b/module/plugins/hoster/CzshareCom.py @@ -52,11 +52,11 @@ class CzshareCom(SimpleHoster): def checkTrafficLeft(self): # check if user logged in found = re.search(self.USER_CREDIT_PATTERN, self.html) - if not found: + if found is None: self.account.relogin(self.user) self.html = self.load(self.pyfile.url, cookies=True, decode=True) found = re.search(self.USER_CREDIT_PATTERN, self.html) - if not found: + if found is None: return False # check user credit @@ -89,7 +89,7 @@ class CzshareCom(SimpleHoster): def handleFree(self): # get free url found = re.search(self.FREE_URL_PATTERN, self.html) - if not found: + if found is None: self.parseError('Free URL') parsed_url = "http://sdilej.cz" + found.group(1) self.logDebug("PARSED_URL:" + parsed_url) @@ -128,7 +128,7 @@ class CzshareCom(SimpleHoster): # download the file, destination is determined by pyLoad self.logDebug("WAIT URL", self.req.lastEffectiveURL) found = re.search("free_wait.php\?server=(.*?)&(.*)", self.req.lastEffectiveURL) - if not found: + if found is None: self.parseError('Download URL') url = "http://%s/download.php?%s" % (found.group(1), found.group(2)) diff --git a/module/plugins/hoster/DateiTo.py b/module/plugins/hoster/DateiTo.py index 906e5634a..160e8aaf5 100644 --- a/module/plugins/hoster/DateiTo.py +++ b/module/plugins/hoster/DateiTo.py @@ -57,7 +57,7 @@ class DateiTo(SimpleHoster): break found = re.search(self.DATA_PATTERN, self.html) - if not found: + if found is None: self.parseError('data') url = 'http://datei.to/' + found.group(1) data = dict(x.split('=') for x in found.group(2).split('&')) diff --git a/module/plugins/hoster/DepositfilesCom.py b/module/plugins/hoster/DepositfilesCom.py index 9089aecff..5274f0f16 100644 --- a/module/plugins/hoster/DepositfilesCom.py +++ b/module/plugins/hoster/DepositfilesCom.py @@ -53,7 +53,7 @@ class DepositfilesCom(SimpleHoster): self.setWait(int(wait.group(1))) found = re.search(r"var fid = '(\w+)';", self.html) - if not found: + if found is None: self.retry(wait_time=5) params = {'fid': found.group(1)} self.logDebug("FID: %s" % params['fid']) diff --git a/module/plugins/hoster/DlFreeFr.py b/module/plugins/hoster/DlFreeFr.py index f0a8aa933..7bebb62b5 100644 --- a/module/plugins/hoster/DlFreeFr.py +++ b/module/plugins/hoster/DlFreeFr.py @@ -16,9 +16,10 @@ class CustomBrowser(Browser): def load(self, *args, **kwargs): post = kwargs.get("post") - if not post: - if len(args) > 2: - post = args[2] + + if post is None and len(args) > 2: + post = args[2] + if post: self.http.c.setopt(pycurl.FOLLOWLOCATION, 0) self.http.c.setopt(pycurl.POST, 1) @@ -27,6 +28,7 @@ class CustomBrowser(Browser): self.http.c.setopt(pycurl.FOLLOWLOCATION, 1) self.http.c.setopt(pycurl.POST, 0) self.http.c.setopt(pycurl.CUSTOMREQUEST, "GET") + return Browser.load(self, *args, **kwargs) diff --git a/module/plugins/hoster/EdiskCz.py b/module/plugins/hoster/EdiskCz.py index fae85d2b6..c753e64a1 100644 --- a/module/plugins/hoster/EdiskCz.py +++ b/module/plugins/hoster/EdiskCz.py @@ -44,7 +44,7 @@ class EdiskCz(SimpleHoster): self.logDebug('URL:' + url) found = re.search(self.ACTION_PATTERN, url) - if not found: + if found is None: self.parseError("ACTION") action = found.group(1) diff --git a/module/plugins/hoster/EgoFilesCom.py b/module/plugins/hoster/EgoFilesCom.py index 2a7c3c508..f4fdda5a3 100644 --- a/module/plugins/hoster/EgoFilesCom.py +++ b/module/plugins/hoster/EgoFilesCom.py @@ -67,7 +67,7 @@ class EgoFilesCom(SimpleHoster): 'recaptcha_response_field': response} self.html = self.load(self.pyfile.url, post=post_data, decode=True) m = re.search(self.LINK_PATTERN, self.html) - if not m: + if m is None: self.logInfo('Wrong captcha') self.invalidCaptcha() elif hasattr(m, 'group'): @@ -91,7 +91,7 @@ class EgoFilesCom(SimpleHoster): self.html = self.load(self.pyfile.url, decode=True) self.getFileInfo() m = re.search(r'<a href="(?P<link>[^"]+)">Download ></a>', self.html) - if not m: + if m is None: self.parseError('Unable to detect direct download url') else: self.logDebug('DIRECT URL from html: ' + m.group('link')) diff --git a/module/plugins/hoster/EuroshareEu.py b/module/plugins/hoster/EuroshareEu.py index a2a13ebf7..3ec319129 100644 --- a/module/plugins/hoster/EuroshareEu.py +++ b/module/plugins/hoster/EuroshareEu.py @@ -62,7 +62,7 @@ class EuroshareEu(SimpleHoster): self.longWait(5 * 60, 12) found = re.search(self.FREE_URL_PATTERN, self.html) - if not found: + if found is None: self.parseError("Parse error (URL)") parsed_url = "http://euroshare.eu%s" % found.group(1) self.logDebug("URL", parsed_url) diff --git a/module/plugins/hoster/ExtabitCom.py b/module/plugins/hoster/ExtabitCom.py index b5fb9608e..fac7922db 100644 --- a/module/plugins/hoster/ExtabitCom.py +++ b/module/plugins/hoster/ExtabitCom.py @@ -79,7 +79,7 @@ class ExtabitCom(SimpleHoster): self.html = self.load("http://extabit.com/file/%s%s" % (fileID, response['href'])) m = re.search(self.LINK_PATTERN, self.html) - if not m: + if m is None: self.parseError('Download URL') url = m.group(1) self.logDebug("Download URL: " + url) diff --git a/module/plugins/hoster/FilecloudIo.py b/module/plugins/hoster/FilecloudIo.py index 5d2d4b3c0..fadbdeb1d 100644 --- a/module/plugins/hoster/FilecloudIo.py +++ b/module/plugins/hoster/FilecloudIo.py @@ -51,7 +51,7 @@ class FilecloudIo(SimpleHoster): data = {"ukey": self.file_info['ID']} found = re.search(self.AB1_PATTERN, self.html) - if not found: + if found is None: self.parseError("__AB1") data['__ab1'] = found.group(1) @@ -99,7 +99,7 @@ class FilecloudIo(SimpleHoster): if response['dl']: self.html = self.load('http://filecloud.io/download.html') found = re.search(self.LINK_PATTERN % self.file_info['ID'], self.html) - if not found: + if found is None: self.parseError("Download URL") download_url = found.group(1) self.logDebug("Download URL: %s" % download_url) diff --git a/module/plugins/hoster/FilefactoryCom.py b/module/plugins/hoster/FilefactoryCom.py index bcef5a5db..0874e1410 100644 --- a/module/plugins/hoster/FilefactoryCom.py +++ b/module/plugins/hoster/FilefactoryCom.py @@ -66,7 +66,7 @@ class FilefactoryCom(SimpleHoster): else: # This section could be completely useless now # Load the page that contains the direct link url = re.search(r"document\.location\.host \+\s*'(.+)';", self.html) - if not url: + if url is None: self.parseError('Unable to detect free link') url = 'http://www.filefactory.com' + url.group(1) self.html = self.load(url, decode=True) diff --git a/module/plugins/hoster/FilepostCom.py b/module/plugins/hoster/FilepostCom.py index 351576b29..e024df6df 100644 --- a/module/plugins/hoster/FilepostCom.py +++ b/module/plugins/hoster/FilepostCom.py @@ -50,12 +50,12 @@ class FilepostCom(SimpleHoster): file_id = re.match(self.__pattern__, self.pyfile.url).group(1) found = re.search(self.FLP_TOKEN_PATTERN, self.html) - if not found: + if found is None: self.parseError("Token") flp_token = found.group(1) found = re.search(self.RECAPTCHA_KEY_PATTERN, self.html) - if not found: + if found is None: self.parseError("Captcha key") captcha_key = found.group(1) diff --git a/module/plugins/hoster/FilerNet.py b/module/plugins/hoster/FilerNet.py index 72396fac6..91805ca40 100644 --- a/module/plugins/hoster/FilerNet.py +++ b/module/plugins/hoster/FilerNet.py @@ -109,7 +109,7 @@ class FilerNet(SimpleHoster): else: # Direct Download OFF html = self.load(self.pyfile.url) m = re.search(self.LINK_PATTERN, html) - if not m: + if m is None: self.parseError("Unable to detect direct link, try to enable 'Direct download' in your user settings") dl = 'http://filer.net' + m.group(1) diff --git a/module/plugins/hoster/FilesMailRu.py b/module/plugins/hoster/FilesMailRu.py index 34998726d..eda3a1714 100644 --- a/module/plugins/hoster/FilesMailRu.py +++ b/module/plugins/hoster/FilesMailRu.py @@ -72,14 +72,11 @@ class FilesMailRu(Hoster): def getFileUrl(self): """gives you the URL to the file. Extracted from the Files.mail.ru HTML-page stored in self.html""" - file_url = re.search(self.url_pattern, self.html).group(0).split('<a href="')[1].split('" onclick="return Act')[ - 0] - return file_url + return re.search(self.url_pattern, self.html).group(0).split('<a href="')[1].split('" onclick="return Act')[0] def getFileName(self): """gives you the Name for each file. Also extracted from the HTML-Page""" - file_name = re.search(self.url_pattern, self.html).group(0).split(', event)">')[1].split('</a>')[0] - return file_name + return re.search(self.url_pattern, self.html).group(0).split(', event)">')[1].split('</a>')[0] def myPostProcess(self): # searches the file for HTMl-Code. Sometimes the Redirect diff --git a/module/plugins/hoster/FileserveCom.py b/module/plugins/hoster/FileserveCom.py index ac12a7892..97c931ee4 100644 --- a/module/plugins/hoster/FileserveCom.py +++ b/module/plugins/hoster/FileserveCom.py @@ -152,7 +152,7 @@ class FileserveCom(Hoster): if self.__name__ == "FilejungleCom": found = re.search(r'"waitTime":(\d+)', response) - if not found: + if found is None: self.fail("Cannot get wait time") wait_time = int(found.group(1)) else: diff --git a/module/plugins/hoster/FileshareInUa.py b/module/plugins/hoster/FileshareInUa.py index 52e084b9c..7c8c6f8ff 100644 --- a/module/plugins/hoster/FileshareInUa.py +++ b/module/plugins/hoster/FileshareInUa.py @@ -31,12 +31,12 @@ class FileshareInUa(Hoster): pyfile.name = self._getName() - self.link = self._getLink() + link = self._getLink() - if not self.link.startswith('http://'): - self.link = "http://fileshare.in.ua" + self.link + if not link.startswith('http://'): + link = "http://fileshare.in.ua" + link - self.download(self.link) + self.download(link) def _checkOnline(self): if re.search(self.PATTERN_OFFLINE, self.html): @@ -46,7 +46,7 @@ class FileshareInUa(Hoster): def _getName(self): name = re.search(self.PATTERN_FILENAME, self.html) - if not name: + if name is None: self.fail("%s: Plugin broken." % self.__name__) return name.group(1) @@ -66,7 +66,7 @@ def getInfo(urls): else: name = re.search(FileshareInUa.PATTERN_FILENAME, html) - if not name: + if name is None: result.append((url, 0, 1, url)) continue diff --git a/module/plugins/hoster/FlyFilesNet.py b/module/plugins/hoster/FlyFilesNet.py index 3e0466a41..1d7ba4fcc 100644 --- a/module/plugins/hoster/FlyFilesNet.py +++ b/module/plugins/hoster/FlyFilesNet.py @@ -17,8 +17,8 @@ class FlyFilesNet(SimpleHoster): FILE_NAME_PATTERN = r'flyfiles\.net/.*/(.*)' def process(self, pyfile): - pyfile.name = re.search(self.FILE_NAME_PATTERN, pyfile.url).group(1) - pyfile.name = urllib.unquote_plus(pyfile.name) + name = re.search(self.FILE_NAME_PATTERN, pyfile.url).group(1) + pyfile.name = urllib.unquote_plus(name) session = re.search(self.SESSION_PATTERN, pyfile.url).group(1) diff --git a/module/plugins/hoster/FourSharedCom.py b/module/plugins/hoster/FourSharedCom.py index 93d784d63..85354db37 100644 --- a/module/plugins/hoster/FourSharedCom.py +++ b/module/plugins/hoster/FourSharedCom.py @@ -39,7 +39,7 @@ class FourSharedCom(SimpleHoster): self.html = self.load(link) found = re.search(self.DOWNLOAD_URL_PATTERN, self.html) - if not found: + if found is None: self.parseError('Download link') link = found.group(1) diff --git a/module/plugins/hoster/FreevideoCz.py b/module/plugins/hoster/FreevideoCz.py index 94c17760b..ffad94418 100644 --- a/module/plugins/hoster/FreevideoCz.py +++ b/module/plugins/hoster/FreevideoCz.py @@ -59,7 +59,7 @@ class FreevideoCz(Hoster): self.offline() found = re.search(self.LINK_PATTERN, self.html) - if not found: + if found is None: self.fail("Parse error (URL)") download_url = found.group(1) diff --git a/module/plugins/hoster/FshareVn.py b/module/plugins/hoster/FshareVn.py index 75b37b4c3..ec76d85b8 100644 --- a/module/plugins/hoster/FshareVn.py +++ b/module/plugins/hoster/FshareVn.py @@ -82,7 +82,7 @@ class FshareVn(SimpleHoster): self.setWait(int(found.group(1)) if found else 30) found = re.search(self.LINK_PATTERN, self.html) - if not found: + if found is None: self.parseError('FREE DL URL') self.url = found.group(1) self.logDebug("FREE DL URL: %s" % self.url) diff --git a/module/plugins/hoster/GamefrontCom.py b/module/plugins/hoster/GamefrontCom.py index 112451636..8e0f8565f 100644 --- a/module/plugins/hoster/GamefrontCom.py +++ b/module/plugins/hoster/GamefrontCom.py @@ -32,12 +32,12 @@ class GamefrontCom(Hoster): pyfile.name = self._getName() - self.link = self._getLink() + link = self._getLink() - if not self.link.startswith('http://'): - self.link = "http://www.gamefront.com/" + self.link + if not link.startswith('http://'): + link = "http://www.gamefront.com/" + link - self.download(self.link) + self.download(link) def _checkOnline(self): if re.search(self.PATTERN_OFFLINE, self.html): @@ -47,7 +47,7 @@ class GamefrontCom(Hoster): def _getName(self): name = re.search(self.PATTERN_FILENAME, self.html) - if not name: + if name is None: self.fail("%s: Plugin broken." % self.__name__) return name.group(1) @@ -55,9 +55,7 @@ class GamefrontCom(Hoster): def _getLink(self): self.html2 = self.load("http://www.gamefront.com/" + re.search("(files/service/thankyou\\?id=[A-Za-z0-9]+)", self.html).group(1)) - self.link = re.search("<a href=\"(http://media[0-9]+\.gamefront.com/.*)\">click here</a>", self.html2) - - return self.link.group(1).replace("&", "&") + return re.search("<a href=\"(http://media[0-9]+\.gamefront.com/.*)\">click here</a>", self.html2).group(1).replace("&", "&") def getInfo(urls): @@ -70,15 +68,13 @@ def getInfo(urls): result.append((url, 0, 1, url)) else: name = re.search(GamefrontCom.PATTERN_FILENAME, html) - - if not name: + if name is None: result.append((url, 0, 1, url)) - continue - - name = name.group(1) - size = re.search(GamefrontCom.PATTERN_FILESIZE, html) - size = parseFileSize(size.group(1)) + else: + name = name.group(1) + size = re.search(GamefrontCom.PATTERN_FILESIZE, html) + size = parseFileSize(size.group(1)) - result.append((name, size, 3, url)) + result.append((name, size, 3, url)) yield result diff --git a/module/plugins/hoster/HellshareCz.py b/module/plugins/hoster/HellshareCz.py index 17996e33a..e4b508930 100644 --- a/module/plugins/hoster/HellshareCz.py +++ b/module/plugins/hoster/HellshareCz.py @@ -47,7 +47,7 @@ class HellshareCz(SimpleHoster): self.fail("Not enough traffic left for user %s." % self.user) found = re.search(self.SHOW_WINDOW_PATTERN, self.html) - if not found: + if found is None: self.parseError('SHOW WINDOW') self.url = "http://www.hellshare.com" + found.group(1) self.logDebug("DOWNLOAD URL: " + self.url) diff --git a/module/plugins/hoster/Keep2shareCC.py b/module/plugins/hoster/Keep2shareCC.py index 74dc05b89..12df08743 100644 --- a/module/plugins/hoster/Keep2shareCC.py +++ b/module/plugins/hoster/Keep2shareCC.py @@ -78,7 +78,7 @@ class Keep2shareCC(SimpleHoster): self.retry() m = re.search(self.LINK_PATTERN, self.html) - if not m: + if m is None: self.parseError("Unable to detect direct link") self.startDownload(m.group(1)) diff --git a/module/plugins/hoster/LoadTo.py b/module/plugins/hoster/LoadTo.py index 6cf633636..780e42ac2 100644 --- a/module/plugins/hoster/LoadTo.py +++ b/module/plugins/hoster/LoadTo.py @@ -56,7 +56,7 @@ class LoadTo(SimpleHoster): # Search for Download URL m = re.search(self.LINK_PATTERN, self.html) - if not m: + if m is None: self.parseError("Unable to detect download URL") download_url = m.group(1) @@ -68,7 +68,7 @@ class LoadTo(SimpleHoster): # Load.to is using solvemedia captchas since ~july 2014: found = re.search(self.SOLVEMEDIA_PATTERN, self.html) - if not found: + if found is None: self.download(download_url) else: captcha_key = found.group(1) diff --git a/module/plugins/hoster/LomafileCom.py b/module/plugins/hoster/LomafileCom.py index 5ce41264b..9f05d952e 100644 --- a/module/plugins/hoster/LomafileCom.py +++ b/module/plugins/hoster/LomafileCom.py @@ -42,7 +42,7 @@ class LomafileCom(SimpleHoster): "down_direct": "1"}) download_url = re.search(r'http://[\d\.]+:\d+/d/\w+/[\w\.]+', self.html) - if not download_url: + if download_url is None: self.invalidCaptcha() self.logDebug("Invalid captcha.") else: diff --git a/module/plugins/hoster/MediafireCom.py b/module/plugins/hoster/MediafireCom.py index 22fdd59c1..914030f1f 100644 --- a/module/plugins/hoster/MediafireCom.py +++ b/module/plugins/hoster/MediafireCom.py @@ -114,7 +114,7 @@ class MediafireCom(SimpleHoster): self.fail("No or incorrect password") found = re.search(r'kNO = r"(http://.*?)";', self.html) - if not found: + if found is None: self.parseError("Download URL") download_url = found.group(1) self.logDebug("DOWNLOAD LINK:", download_url) diff --git a/module/plugins/hoster/MegasharesCom.py b/module/plugins/hoster/MegasharesCom.py index 2fde7c0d3..e4d9aff8b 100644 --- a/module/plugins/hoster/MegasharesCom.py +++ b/module/plugins/hoster/MegasharesCom.py @@ -88,7 +88,7 @@ class MegasharesCom(SimpleHoster): # Check traffic left on passport found = re.search(self.PASSPORT_LEFT_PATTERN, self.html) - if not found: + if found is None: self.fail('Passport not found') self.logInfo("Download passport: %s" % found.group(1)) data_left = float(found.group(2)) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[found.group(3)] @@ -105,7 +105,7 @@ class MegasharesCom(SimpleHoster): # Find download link; found = re.search(self.LINK_PATTERN % (1 if premium else 2), self.html) msg = '%s download URL' % ('Premium' if premium else 'Free') - if not found: + if found is None: self.parseError(msg) download_url = found.group(1) diff --git a/module/plugins/hoster/NarodRu.py b/module/plugins/hoster/NarodRu.py index b3ca2c3a9..d2f5e5856 100644 --- a/module/plugins/hoster/NarodRu.py +++ b/module/plugins/hoster/NarodRu.py @@ -44,7 +44,7 @@ class NarodRu(SimpleHoster): for _ in xrange(5): self.html = self.load('http://narod.ru/disk/getcapchaxml/?rnd=%d' % int(random() * 777)) found = re.search(self.CAPTCHA_PATTERN, self.html) - if not found: + if found is None: self.parseError('Captcha') post_data = {"action": "sendcapcha"} captcha_url, post_data['key'] = found.groups() diff --git a/module/plugins/hoster/NetloadIn.py b/module/plugins/hoster/NetloadIn.py index 5431ebb9a..2baeed5da 100644 --- a/module/plugins/hoster/NetloadIn.py +++ b/module/plugins/hoster/NetloadIn.py @@ -24,7 +24,7 @@ def getInfo(urls): api = getURL(apiurl + ids, decode=True) - if not api or len(api) < 10: + if api is None or len(api) < 10: print "Netload prefetch: failed " return if api.find("unknown_auth") >= 0: diff --git a/module/plugins/hoster/NowDownloadEu.py b/module/plugins/hoster/NowDownloadEu.py index d5cd7f1c6..20153d356 100644 --- a/module/plugins/hoster/NowDownloadEu.py +++ b/module/plugins/hoster/NowDownloadEu.py @@ -47,7 +47,7 @@ class NowDownloadEu(SimpleHoster): def handleFree(self): tokenlink = re.search(self.TOKEN_PATTERN, self.html) continuelink = re.search(self.CONTINUE_PATTERN, self.html) - if not tokenlink or not continuelink: + if tokenlink is None or continuelink is None: self.fail('Plugin out of Date') found = re.search(self.WAIT_PATTERN, self.html) @@ -63,7 +63,7 @@ class NowDownloadEu(SimpleHoster): self.html = self.load(baseurl + str(continuelink.group(1))) url = re.search(self.LINK_PATTERN, self.html) - if not url: + if url is None: self.fail('Download Link not Found (Plugin out of Date?)') self.logDebug('Download link: ' + str(url.group(1))) self.download(str(url.group(1))) diff --git a/module/plugins/hoster/OboomCom.py b/module/plugins/hoster/OboomCom.py index 2176f1cd5..b6eeba3c8 100644 --- a/module/plugins/hoster/OboomCom.py +++ b/module/plugins/hoster/OboomCom.py @@ -23,7 +23,7 @@ class OboomCom(Hoster): def loadUrl(self, url, get=None): - if not get: + if get is None: get = dict() return json_loads(self.load(url, get, decode=True)) diff --git a/module/plugins/hoster/PornhostCom.py b/module/plugins/hoster/PornhostCom.py index 18032519c..6b53dc623 100644 --- a/module/plugins/hoster/PornhostCom.py +++ b/module/plugins/hoster/PornhostCom.py @@ -32,29 +32,27 @@ class PornhostCom(Hoster): if not self.html: self.download_html() - file_url = re.search(r'download this file</label>.*?<a href="(.*?)"', self.html) - if not file_url: - file_url = re.search(r'"(http://dl[0-9]+\.pornhost\.com/files/.*?/.*?/.*?/.*?/.*?/.*?\..*?)"', self.html) - if not file_url: - file_url = re.search(r'width: 894px; height: 675px">.*?<img src="(.*?)"', self.html) - if not file_url: - file_url = re.search(r'"http://file[0-9]+\.pornhost\.com/[0-9]+/.*?"', - self.html) # TODO: fix this one since it doesn't match + url = re.search(r'download this file</label>.*?<a href="(.*?)"', self.html) + if url is None: + url = re.search(r'"(http://dl[0-9]+\.pornhost\.com/files/.*?/.*?/.*?/.*?/.*?/.*?\..*?)"', self.html) + if url is None: + url = re.search(r'width: 894px; height: 675px">.*?<img src="(.*?)"', self.html) + if url is None: + url = re.search(r'"http://file[0-9]+\.pornhost\.com/[0-9]+/.*?"', + self.html) # TODO: fix this one since it doesn't match - file_url = file_url.group(1).strip() - - return file_url + return url.group(1).strip() def get_file_name(self): if not self.html: self.download_html() name = re.search(r'<title>pornhost\.com - free file hosting with a twist - gallery(.*?)</title>', self.html) - if not name: + if name is None: name = re.search(r'id="url" value="http://www\.pornhost\.com/(.*?)/"', self.html) - if not name: + if name is None: name = re.search(r'<title>pornhost\.com - free file hosting with a twist -(.*?)</title>', self.html) - if not name: + if name is None: name = re.search(r'"http://file[0-9]+\.pornhost\.com/.*?/(.*?)"', self.html) name = name.group(1).strip() + ".flv" diff --git a/module/plugins/hoster/PornhubCom.py b/module/plugins/hoster/PornhubCom.py index 2fc08cfd3..9cb14c1f6 100644 --- a/module/plugins/hoster/PornhubCom.py +++ b/module/plugins/hoster/PornhubCom.py @@ -51,17 +51,15 @@ class PornhubCom(Hoster): content = new_content - file_url = re.search(r'flv_url.*(http.*?)##post_roll', content).group(1) - - return file_url + return re.search(r'flv_url.*(http.*?)##post_roll', content).group(1) def get_file_name(self): if not self.html: self.download_html() - match = re.search(r'<title[^>]+>([^<]+) - ', self.html) - if match: - name = match.group(1) + found = re.search(r'<title[^>]+>([^<]+) - ', self.html) + if found: + name = found.group(1) else: matches = re.findall('<h1>(.*?)</h1>', self.html) if len(matches) > 1: diff --git a/module/plugins/hoster/PromptfileCom.py b/module/plugins/hoster/PromptfileCom.py index ac3af3753..ce3f3e0e0 100644 --- a/module/plugins/hoster/PromptfileCom.py +++ b/module/plugins/hoster/PromptfileCom.py @@ -37,7 +37,7 @@ class PromptfileCom(SimpleHoster): def handleFree(self): # STAGE 1: get link to continue m = re.search(self.CHASH_PATTERN, self.html) - if not m: + if m is None: self.parseError("Unable to detect chash") chash = m.group(1) self.logDebug("read chash %s" % chash) @@ -46,7 +46,7 @@ class PromptfileCom(SimpleHoster): # STAGE 2: get the direct link m = re.search(self.LINK_PATTERN, self.html, re.MULTILINE | re.DOTALL) - if not m: + if m is None: self.parseError("Unable to detect direct link") direct = m.group(1) self.logDebug("found direct link: " + direct) diff --git a/module/plugins/hoster/QuickshareCz.py b/module/plugins/hoster/QuickshareCz.py index 35506c5da..9fd189829 100644 --- a/module/plugins/hoster/QuickshareCz.py +++ b/module/plugins/hoster/QuickshareCz.py @@ -75,7 +75,7 @@ class QuickshareCz(SimpleHoster): self.req.http.c.setopt(FOLLOWLOCATION, 1) found = re.search("Location\s*:\s*(.*)", self.header, re.I) - if not found: + if found is None: self.fail('File not found') download_url = found.group(1) self.logDebug("FREE URL2:" + download_url) diff --git a/module/plugins/hoster/RapidgatorNet.py b/module/plugins/hoster/RapidgatorNet.py index f87405675..c593a52dc 100644 --- a/module/plugins/hoster/RapidgatorNet.py +++ b/module/plugins/hoster/RapidgatorNet.py @@ -180,7 +180,7 @@ class RapidgatorNet(SimpleHoster): wait_time = int(found.group(1)) * {"hour": 60, "min": 1}[found.group(2)] else: found = re.search(self.DOWNLOAD_LIMIT_ERROR_PATTERN, self.html) - if not found: + if found is None: return elif found.group(1) == "daily": self.logWarning("You have reached your daily downloads limit for today") diff --git a/module/plugins/hoster/RedtubeCom.py b/module/plugins/hoster/RedtubeCom.py index 465803a1c..d9cb6489a 100644 --- a/module/plugins/hoster/RedtubeCom.py +++ b/module/plugins/hoster/RedtubeCom.py @@ -40,8 +40,7 @@ class RedtubeCom(Hoster): if not self.html: self.download_html() - name = re.search('<title>(.*?)- RedTube - Free Porn Videos</title>', self.html).group(1).strip() + ".flv" - return name + return re.search('<title>(.*?)- RedTube - Free Porn Videos</title>', self.html).group(1).strip() + ".flv" def file_exists(self): """ returns True or False diff --git a/module/plugins/hoster/RgHostNet.py b/module/plugins/hoster/RgHostNet.py index fafa6f2f8..0762e3bd0 100644 --- a/module/plugins/hoster/RgHostNet.py +++ b/module/plugins/hoster/RgHostNet.py @@ -19,7 +19,7 @@ class RgHostNet(SimpleHoster): def handleFree(self): found = re.search(self.LINK_PATTERN, self.html) - if not found: + if found is None: self.parseError("Unable to detect the direct link") download_link = found.group(1) self.download(download_link, disposition=True) diff --git a/module/plugins/hoster/RyushareCom.py b/module/plugins/hoster/RyushareCom.py index a26827401..31dd489b8 100644 --- a/module/plugins/hoster/RyushareCom.py +++ b/module/plugins/hoster/RyushareCom.py @@ -42,10 +42,10 @@ class RyushareCom(XFileSharingPro): self.setWait(1 * 60 * 60, True) retry = True - match = re.search(self.WAIT_PATTERN, self.html) - if match: - m = match.groupdict(0) - waittime = int(m['hour']) * 60 * 60 + int(m['min']) * 60 + int(m['sec']) + found = re.search(self.WAIT_PATTERN, self.html) + if found: + wait = found.groupdict(0) + waittime = int(wait['hour']) * 60 * 60 + int(wait['min']) * 60 + int(wait['sec']) self.setWait(waittime, True) retry = True @@ -54,11 +54,11 @@ class RyushareCom(XFileSharingPro): self.retry() for _ in xrange(5): - m = re.search(self.SOLVEMEDIA_PATTERN, self.html) - if not m: + found = re.search(self.SOLVEMEDIA_PATTERN, self.html) + if found is None: self.parseError("Error parsing captcha") - captchaKey = m.group(1) + captchaKey = found.group(1) captcha = SolveMedia(self) challenge, response = captcha.challenge(captchaKey) @@ -76,8 +76,7 @@ class RyushareCom(XFileSharingPro): self.fail("You have entered 5 invalid captcha codes") if "Click here to download" in self.html: - m = re.search(r'<a href="([^"]+)">Click here to download</a>', self.html) - return m.group(1) + return re.search(r'<a href="([^"]+)">Click here to download</a>', self.html).group(1) getInfo = create_getInfo(RyushareCom) diff --git a/module/plugins/hoster/ShareonlineBiz.py b/module/plugins/hoster/ShareonlineBiz.py index 0e0676626..246d265c5 100644 --- a/module/plugins/hoster/ShareonlineBiz.py +++ b/module/plugins/hoster/ShareonlineBiz.py @@ -171,7 +171,7 @@ class ShareonlineBiz(Hoster): def checkErrors(self): found = re.search(r"/failure/(.*?)/1", self.req.lastEffectiveURL) - if not found: + if found is None: return err = found.group(1) diff --git a/module/plugins/hoster/SockshareCom.py b/module/plugins/hoster/SockshareCom.py index bc3d5a7b4..9818875c8 100644 --- a/module/plugins/hoster/SockshareCom.py +++ b/module/plugins/hoster/SockshareCom.py @@ -72,7 +72,7 @@ class SockshareCom(SimpleHoster): if link: self.html = self.load("http://www.sockshare.com" + link.group(1)) link = re.search(r'media:content url="(http://.*?)"', self.html) - if not link: + if link is None: link = re.search(r'\"(http://media\\-b\\d+\\.sockshare\\.com/download/\\d+/.*?)\"', self.html) else: self.parseError('Unable to detect a download link') diff --git a/module/plugins/hoster/SoundcloudCom.py b/module/plugins/hoster/SoundcloudCom.py index a1ec1378a..f4a81059b 100644 --- a/module/plugins/hoster/SoundcloudCom.py +++ b/module/plugins/hoster/SoundcloudCom.py @@ -19,24 +19,24 @@ class SoundcloudCom(Hoster): # 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) - match = re.search(r'<div class="haudio.*?large.*?" data-sc-track="(?P<ID>[0-9]*)"', page) + found = re.search(r'<div class="haudio.*?large.*?" data-sc-track="(?P<ID>[0-9]*)"', page) songId = clientId = "" - if match: - songId = match.group("ID") + if found: + songId = found.group("ID") if len(songId) <= 0: self.logError("Could not find song id") self.offline() else: - match = re.search(r'"clientID":"(?P<CID>.*?)"', page) - if match: - clientId = match.group("CID") + found = re.search(r'"clientID":"(?P<CID>.*?)"', page) + if found: + clientId = found.group("CID") if len(clientId) <= 0: clientId = "b45b1aa10f1ac2941910a7f0d10f8e28" - match = re.search(r'<em itemprop="name">\s(?P<TITLE>.*?)\s</em>', page) - if match: - pyfile.name = match.group("TITLE") + ".mp3" + found = re.search(r'<em itemprop="name">\s(?P<TITLE>.*?)\s</em>', page) + if found: + pyfile.name = found.group("TITLE") + ".mp3" else: pyfile.name = re.match(self.__pattern__, pyfile.url).group("SID") + ".mp3" diff --git a/module/plugins/hoster/StreamCz.py b/module/plugins/hoster/StreamCz.py index 1b2439d98..9e5b6233f 100644 --- a/module/plugins/hoster/StreamCz.py +++ b/module/plugins/hoster/StreamCz.py @@ -59,7 +59,7 @@ class StreamCz(Hoster): self.offline() found = re.search(self.CDN_PATTERN, self.html) - if not found: + if found is None: self.fail("Parse error (CDN)") cdn = found.groupdict() self.logDebug(cdn) @@ -71,7 +71,7 @@ class StreamCz(Hoster): self.fail("Stream URL not found") found = re.search(self.FILE_NAME_PATTERN, self.html) - if not found: + if found is None: self.fail("Parse error (NAME)") pyfile.name = "%s-%s.%s.mp4" % (found.group(2), found.group(1), cdnkey[-2:]) diff --git a/module/plugins/hoster/TurbobitNet.py b/module/plugins/hoster/TurbobitNet.py index 4649c3143..cb0166ef8 100644 --- a/module/plugins/hoster/TurbobitNet.py +++ b/module/plugins/hoster/TurbobitNet.py @@ -87,7 +87,7 @@ class TurbobitNet(SimpleHoster): captcha_key) else: found = re.search(self.CAPTCHA_SRC_PATTERN, self.html) - if not found: + if found is None: self.parseError('captcha') captcha_url = found.group(1) inputs['captcha_response'] = self.decryptCaptcha(captcha_url) @@ -169,7 +169,7 @@ class TurbobitNet(SimpleHoster): def downloadFile(self): found = re.search(self.LINK_PATTERN, self.html) - if not found: + if found is None: self.parseError("download link") self.url = "http://turbobit.net" + found.group('url') self.logDebug(self.url) diff --git a/module/plugins/hoster/TwoSharedCom.py b/module/plugins/hoster/TwoSharedCom.py index 74a9dbe08..d50248c4d 100644 --- a/module/plugins/hoster/TwoSharedCom.py +++ b/module/plugins/hoster/TwoSharedCom.py @@ -26,7 +26,7 @@ class TwoSharedCom(SimpleHoster): def handleFree(self): found = re.search(self.LINK_PATTERN, self.html) - if not found: + if found is None: self.parseError('Download link') link = found.group(1) self.logDebug("Download URL %s" % link) diff --git a/module/plugins/hoster/UlozTo.py b/module/plugins/hoster/UlozTo.py index a3da22fe4..53494afb7 100644 --- a/module/plugins/hoster/UlozTo.py +++ b/module/plugins/hoster/UlozTo.py @@ -62,7 +62,7 @@ class UlozTo(SimpleHoster): self.logInfo("Adult content confirmation needed. Proceeding..") found = re.search(self.TOKEN_PATTERN, self.html) - if not found: + if found is None: self.parseError('TOKEN') token = found.group(1) @@ -133,7 +133,7 @@ class UlozTo(SimpleHoster): def findDownloadURL(self, premium=False): msg = "%s link" % ("Premium" if premium else "Free") found = re.search(self.PREMIUM_URL_PATTERN if premium else self.FREE_URL_PATTERN, self.html) - if not found: + if found is None: self.parseError(msg) parsed_url = "http://www.ulozto.net" + found.group(1) self.logDebug("%s: %s" % (msg, parsed_url)) diff --git a/module/plugins/hoster/UloziskoSk.py b/module/plugins/hoster/UloziskoSk.py index 055083af2..f2d5ce227 100644 --- a/module/plugins/hoster/UloziskoSk.py +++ b/module/plugins/hoster/UloziskoSk.py @@ -51,19 +51,19 @@ class UloziskoSk(SimpleHoster): def handleFree(self): found = re.search(self.LINK_PATTERN, self.html) - if not found: + if found is None: self.parseError('URL') parsed_url = 'http://www.ulozisko.sk' + found.group(1) found = re.search(self.ID_PATTERN, self.html) - if not found: + if found is None: self.parseError('ID') id = found.group(1) self.logDebug('URL:' + parsed_url + ' ID:' + id) found = re.search(self.CAPTCHA_PATTERN, self.html) - if not found: + if found is None: self.parseError('CAPTCHA') captcha_url = 'http://www.ulozisko.sk' + found.group(1) diff --git a/module/plugins/hoster/UploadedTo.py b/module/plugins/hoster/UploadedTo.py index bfe28f158..2c39a5cf4 100644 --- a/module/plugins/hoster/UploadedTo.py +++ b/module/plugins/hoster/UploadedTo.py @@ -164,7 +164,7 @@ class UploadedTo(Hoster): #Indirect download self.html = self.load("http://uploaded.net/file/%s" % self.fileID) found = re.search(r'<div class="tfree".*\s*<form method="post" action="(.*?)"', self.html) - if not found: + if found is None: self.fail("Download URL not found. Try to enable direct downloads.") url = found.group(1) print "Premium URL: " + url @@ -178,7 +178,7 @@ class UploadedTo(Hoster): self.retry(max_tries=24, wait_time=5 * 60) found = re.search(r"Current waiting period: <span>(\d+)</span> seconds", self.html) - if not found: + if found is None: self.fail("File not downloadable for free users") self.setWait(int(found.group(1))) diff --git a/module/plugins/hoster/UploadheroCom.py b/module/plugins/hoster/UploadheroCom.py index b481f6b2f..c7850f81a 100644 --- a/module/plugins/hoster/UploadheroCom.py +++ b/module/plugins/hoster/UploadheroCom.py @@ -49,7 +49,7 @@ class UploadheroCom(SimpleHoster): self.checkErrors() found = re.search(self.CAPTCHA_PATTERN, self.html) - if not found: + if found is None: self.parseError("Captcha URL") captcha_url = "http://uploadhero.co" + found.group(1) diff --git a/module/plugins/hoster/UpstoreNet.py b/module/plugins/hoster/UpstoreNet.py index adda573bc..99aa25b48 100644 --- a/module/plugins/hoster/UpstoreNet.py +++ b/module/plugins/hoster/UpstoreNet.py @@ -25,7 +25,7 @@ class UpstoreNet(SimpleHoster): def handleFree(self): # STAGE 1: get link to continue m = re.search(self.CHASH_PATTERN, self.html) - if not m: + if m is None: self.parseError("could not detect hash") chash = m.group(1) self.logDebug("read hash " + chash) @@ -42,7 +42,7 @@ class UpstoreNet(SimpleHoster): # try the captcha 5 times for i in xrange(5): m = re.search(self.WAIT_PATTERN, self.html) - if not m: + if m is None: self.parseError("could not find wait pattern") wait_time = m.group(1) @@ -61,7 +61,7 @@ class UpstoreNet(SimpleHoster): if m: break - if not m: + if m is None: self.parseError("could not detect direct link") direct = m.group(1) diff --git a/module/plugins/hoster/VeehdCom.py b/module/plugins/hoster/VeehdCom.py index fd804d3f9..33fa76d47 100644 --- a/module/plugins/hoster/VeehdCom.py +++ b/module/plugins/hoster/VeehdCom.py @@ -47,10 +47,11 @@ class VeehdCom(Hoster): if not self.html: self.download_html() - match = re.search(r'<title[^>]*>([^<]+) on Veehd</title>', self.html) - if not match: + found = re.search(r'<title[^>]*>([^<]+) on Veehd</title>', self.html) + if found is None: self.fail("video title not found") - name = match.group(1) + + name = found.group(1) # replace unwanted characters in filename if self.getConfig('filename_spaces'): @@ -58,9 +59,7 @@ class VeehdCom(Hoster): else: pattern = '[^0-9A-Za-z\.]+' - name = re.sub(pattern, self.getConfig('replacement_char'), - name) - return name + '.avi' + return re.sub(pattern, self.getConfig('replacement_char'), name) + '.avi' def get_file_url(self): """ returns the absolute downloadable filepath @@ -68,10 +67,9 @@ class VeehdCom(Hoster): if not self.html: self.download_html() - match = re.search(r'<embed type="video/divx" src="(http://([^/]*\.)?veehd\.com/dl/[^"]+)"', + found = re.search(r'<embed type="video/divx" src="(http://([^/]*\.)?veehd\.com/dl/[^"]+)"', self.html) - if not match: + if found is None: self.fail("embedded video url not found") - file_url = match.group(1) - return file_url + return found.group(1) diff --git a/module/plugins/hoster/WebshareCz.py b/module/plugins/hoster/WebshareCz.py index 53dc3b95c..64691ad69 100644 --- a/module/plugins/hoster/WebshareCz.py +++ b/module/plugins/hoster/WebshareCz.py @@ -48,7 +48,7 @@ class WebshareCz(SimpleHoster): api_data = self.load('https://webshare.cz/api/file_link/', post={'ident': self.fid}) self.logDebug("API data: " + api_data) m = re.search('<link>(.+)</link>', api_data) - if not m: + if m is None: self.parseError('Unable to detect direct link') direct = m.group(1) self.logDebug("Direct link: " + direct) diff --git a/module/plugins/hoster/XFileSharingPro.py b/module/plugins/hoster/XFileSharingPro.py index 896858cbc..d945ea758 100644 --- a/module/plugins/hoster/XFileSharingPro.py +++ b/module/plugins/hoster/XFileSharingPro.py @@ -159,7 +159,7 @@ class XFileSharingPro(SimpleHoster): def handlePremium(self): self.html = self.load(self.pyfile.url, post=self.getPostParameters()) found = re.search(self.LINK_PATTERN, self.html) - if not found: + if found is None: self.parseError('DIRECT LINK') self.startDownload(found.group(1)) @@ -191,7 +191,7 @@ class XFileSharingPro(SimpleHoster): #get easybytez.com link for uploaded file found = re.search(self.OVR_LINK_PATTERN, self.html) - if not found: + if found is None: self.parseError('DIRECT LINK (OVR)') self.pyfile.url = found.group(1) header = self.load(self.pyfile.url, just_header=True) diff --git a/module/plugins/hoster/XHamsterCom.py b/module/plugins/hoster/XHamsterCom.py index d11520cd5..9c93d4ee1 100644 --- a/module/plugins/hoster/XHamsterCom.py +++ b/module/plugins/hoster/XHamsterCom.py @@ -66,7 +66,7 @@ class XHamsterCom(Hoster): if self.desired_fmt == ".mp4": file_url = re.search(r"<a href=\"" + srv_url + "(.+?)\"", self.html) - if not file_url: + if file_url is None: self.fail("Parse error (file_url)") file_url = file_url.group(1) long_url = srv_url + file_url @@ -90,21 +90,21 @@ class XHamsterCom(Hoster): if not self.html: self.download_html() - file_name_pattern = r"<title>(.*?) - xHamster\.com</title>" - file_name = re.search(file_name_pattern, self.html) - if not file_name: - file_name_pattern = r"<h1 >(.*)</h1>" - file_name = re.search(file_name_pattern, self.html) - if not file_name: - file_name_pattern = r"http://[www.]+xhamster\.com/movies/.*/(.*?)\.html?" - file_name = re.match(file_name_pattern, self.pyfile.url) - if not file_name: - file_name_pattern = r"<div id=\"element_str_id\" style=\"display:none;\">(.*)</div>" - file_name = re.search(file_name_pattern, self.html) - if not file_name: + pattern = r"<title>(.*?) - xHamster\.com</title>" + name = re.search(pattern, self.html) + if name is None: + pattern = r"<h1 >(.*)</h1>" + name = re.search(pattern, self.html) + if name is None: + pattern = r"http://[www.]+xhamster\.com/movies/.*/(.*?)\.html?" + name = re.match(file_name_pattern, self.pyfile.url) + if name is None: + pattern = r"<div id=\"element_str_id\" style=\"display:none;\">(.*)</div>" + name = re.search(pattern, self.html) + if name is None: return "Unknown" - return file_name.group(1) + return name.group(1) def file_exists(self): """ returns True or False diff --git a/module/plugins/hoster/YibaishiwuCom.py b/module/plugins/hoster/YibaishiwuCom.py index a7cd924bf..278758053 100644 --- a/module/plugins/hoster/YibaishiwuCom.py +++ b/module/plugins/hoster/YibaishiwuCom.py @@ -38,7 +38,7 @@ class YibaishiwuCom(SimpleHoster): def handleFree(self): found = re.search(self.LINK_PATTERN, self.html) - if not found: + if found is None: self.parseError("AJAX URL") url = found.group(1) self.logDebug(('FREEUSER' if found.group(2) == 'download' else 'GUEST') + ' URL', url) diff --git a/module/plugins/hoster/YoupornCom.py b/module/plugins/hoster/YoupornCom.py index d5ba1f5d0..f8f782f1c 100644 --- a/module/plugins/hoster/YoupornCom.py +++ b/module/plugins/hoster/YoupornCom.py @@ -32,8 +32,7 @@ class YoupornCom(Hoster): if not self.html: self.download_html() - file_url = re.search(r'(http://download\.youporn\.com/download/\d+\?save=1)">', self.html).group(1) - return file_url + return re.search(r'(http://download\.youporn\.com/download/\d+\?save=1)">', self.html).group(1) def get_file_name(self): if not self.html: diff --git a/module/plugins/hoster/YoutubeCom.py b/module/plugins/hoster/YoutubeCom.py index eb260298b..d9dc5e0ef 100644 --- a/module/plugins/hoster/YoutubeCom.py +++ b/module/plugins/hoster/YoutubeCom.py @@ -154,7 +154,7 @@ class YoutubeCom(Hoster): ffmpeg = which("ffmpeg") if ffmpeg and time: m, s = time.groups()[1:] - if not m: + if m is None: m = "0" pyfile.name += " (starting at %s:%s)" % (m, s) diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index 8ccc32010..ea168246a 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -48,7 +48,7 @@ class ZippyshareCom(SimpleHoster): # checksum = eval(re.search("((\d*)\s\%\s(\d*)\s\+\s(\d*)\s\%\s(\d*))", self.html).group(0)) m = re.search(r"((?P<a>\d*)\s%\s(?P<b>\d*)\s\+\s(?P<c>\d*)\s%\s(?P<k>\d*))", self.html) - if not m: + if m is None: self.parseError("Unable to detect values to calculate direct link") a = int(m.group("a")) b = int(m.group("b")) diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index 6586256f7..d325d7928 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -29,7 +29,7 @@ class ReCaptcha: def detect_key(self, html): m = re.search(self.RECAPTCHA_KEY_PATTERN, html) - if not m: + if m is None: m = re.search(self.RECAPTCHA_KEY_AJAX_PATTERN, html) if m: self.recaptcha_key = m.group('key') @@ -38,9 +38,9 @@ class ReCaptcha: return None def challenge(self, key=None): - if not key and self.recaptcha_key: + if key is None and self.recaptcha_key: key = self.recaptcha_key - elif not (key or self.recaptcha_key): + else: raise TypeError("ReCaptcha key not found") js = self.plugin.req.load("http://www.google.com/recaptcha/api/challenge", get={"k": key}, cookies=True) |