diff options
author | Walter Purcaro <vuolter@gmail.com> | 2014-04-11 12:19:22 +0200 |
---|---|---|
committer | Stefano <l.stickell@yahoo.it> | 2014-04-21 17:20:46 +0200 |
commit | 87733d5d1d3698a5f7e2708e1620173706ee1e37 (patch) | |
tree | 32f26ac0aa1364bc4cac64c985586023ca28be5b | |
parent | Remove bad whitespaces (diff) | |
download | pyload-87733d5d1d3698a5f7e2708e1620173706ee1e37.tar.xz |
Use re.match for __pattern__ matches instead re.search
Merges vuolter/pyload@9117005
(cherry picked from commit 8c18c14ab56541aeae9123ee3b558b70aeabfd09)
28 files changed, 30 insertions, 30 deletions
diff --git a/pyload/plugins/crypter/DuckCryptInfo.py b/pyload/plugins/crypter/DuckCryptInfo.py index 680ddf222..a35343c1d 100644 --- a/pyload/plugins/crypter/DuckCryptInfo.py +++ b/pyload/plugins/crypter/DuckCryptInfo.py @@ -24,7 +24,7 @@ class DuckCryptInfo(Crypter): #if found: # self.logDebug("Sleeping for" % found.group(1)) # self.setWait(int(found.group(1)) ,False) - found = re.search(self.__pattern__, url) + found = re.match(self.__pattern__, url) if not found: self.fail('Weird error in link') if str(found.group(1)) == "link": @@ -35,7 +35,7 @@ class DuckCryptInfo(Crypter): def handleFolder(self, found): src = self.load("http://duckcrypt.info/ajax/auth.php?hash=" + str(found.group(2))) - found = re.search(self.__pattern__, src) + found = re.match(self.__pattern__, src) self.logDebug("Redirectet to " + str(found.group(0))) src = self.load(str(found.group(0))) soup = BeautifulSoup(src) diff --git a/pyload/plugins/crypter/FilefactoryComFolder.py b/pyload/plugins/crypter/FilefactoryComFolder.py index 6a1ffea2c..ed4ffebb6 100644 --- a/pyload/plugins/crypter/FilefactoryComFolder.py +++ b/pyload/plugins/crypter/FilefactoryComFolder.py @@ -19,7 +19,7 @@ class FilefactoryComFolder(Crypter): NEXT_PAGE_PATTERN = r'<li class="current">.*?</li>\s*<li class=""><a href="([^"]+)">' def decrypt(self, pyfile): - url_base = re.search(self.__pattern__, self.pyfile.url).group(1) + url_base = re.match(self.__pattern__, self.pyfile.url).group(1) html = self.load(url_base) new_links = [] diff --git a/pyload/plugins/crypter/LixIn.py b/pyload/plugins/crypter/LixIn.py index 84f340d44..ef02c5060 100644 --- a/pyload/plugins/crypter/LixIn.py +++ b/pyload/plugins/crypter/LixIn.py @@ -22,7 +22,7 @@ class LixIn(Crypter): def decrypt(self, pyfile): url = pyfile.url - matches = re.search(self.__pattern__, url) + matches = re.match(self.__pattern__, url) if not matches: self.fail("couldn't identify file id") diff --git a/pyload/plugins/crypter/MultiloadCz.py b/pyload/plugins/crypter/MultiloadCz.py index 22dff1c8a..4800bf309 100644 --- a/pyload/plugins/crypter/MultiloadCz.py +++ b/pyload/plugins/crypter/MultiloadCz.py @@ -22,7 +22,7 @@ class MultiloadCz(Crypter): self.html = self.load(self.pyfile.url, decode=True) new_links = [] - if re.search(self.__pattern__, self.pyfile.url).group(1) == "slozka": + if re.match(self.__pattern__, self.pyfile.url).group(1) == "slozka": found = re.search(self.FOLDER_PATTERN, self.html) if found is not None: new_links.extend(found.group(1).split()) diff --git a/pyload/plugins/crypter/MultiuploadCom.py b/pyload/plugins/crypter/MultiuploadCom.py index f060d9472..e3013fe0d 100644 --- a/pyload/plugins/crypter/MultiuploadCom.py +++ b/pyload/plugins/crypter/MultiuploadCom.py @@ -26,7 +26,7 @@ class MultiuploadCom(Crypter): ml_url = found.group(1) if found else None json_list = json_loads(self.load("http://multiupload.com/progress/", get={ - "d": re.search(self.__pattern__, pyfile.url).group(1), + "d": re.match(self.__pattern__, pyfile.url).group(1), "r": str(int(time() * 1000)) })) new_links = [] diff --git a/pyload/plugins/crypter/NCryptIn.py b/pyload/plugins/crypter/NCryptIn.py index 53f4dad19..c6e26bdad 100644 --- a/pyload/plugins/crypter/NCryptIn.py +++ b/pyload/plugins/crypter/NCryptIn.py @@ -74,7 +74,7 @@ class NCryptIn(Crypter): self.packages = [(package_name, package_links, folder_name)] def isSingleLink(self): - link_type = re.search(self.__pattern__, self.pyfile.url).group('type') + link_type = re.match(self.__pattern__, self.pyfile.url).group('type') return link_type in ('link', 'frame') def requestFolderHome(self): diff --git a/pyload/plugins/crypter/SafelinkingNet.py b/pyload/plugins/crypter/SafelinkingNet.py index e0a3e14af..aaf1622c6 100644 --- a/pyload/plugins/crypter/SafelinkingNet.py +++ b/pyload/plugins/crypter/SafelinkingNet.py @@ -22,7 +22,7 @@ class SafelinkingNet(Crypter): def decrypt(self, pyfile): url = pyfile.url - if re.search(self.__pattern__, url).group(1) == "d": + if re.match(self.__pattern__, url).group(1) == "d": self.req.http.c.setopt(FOLLOWLOCATION, 0) self.load(url) m = re.search("^Location: (.+)$", self.req.http.header, re.MULTILINE) diff --git a/pyload/plugins/crypter/ShareLinksBiz.py b/pyload/plugins/crypter/ShareLinksBiz.py index c48ef6e64..0c0ab3851 100644 --- a/pyload/plugins/crypter/ShareLinksBiz.py +++ b/pyload/plugins/crypter/ShareLinksBiz.py @@ -63,7 +63,7 @@ class ShareLinksBiz(Crypter): url = pyfile.url if 's2l.biz' in url: url = self.load(url, just_header=True)['location'] - self.baseUrl = re.search(self.__pattern__, url).group(1) + self.baseUrl = re.match(self.__pattern__, url).group(1) self.fileId = re.match(self.__pattern__, url).group('id') self.package = pyfile.package() diff --git a/pyload/plugins/hoster/BasePlugin.py b/pyload/plugins/hoster/BasePlugin.py index 2b8f7c848..375896580 100644 --- a/pyload/plugins/hoster/BasePlugin.py +++ b/pyload/plugins/hoster/BasePlugin.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- from urlparse import urlparse -from re import search +from re import match, search from urllib import unquote from pyload.plugins.Request import ResponseException @@ -83,7 +83,7 @@ class BasePlugin(Hoster): if 'location' in header: self.logDebug("Location: " + header['location']) - base = search(r'https?://[^/]+', url).group(0) + base = match(r'https?://[^/]+', url).group(0) if header['location'].startswith("http"): url = unquote(header['location']) elif header['location'].startswith("/"): diff --git a/pyload/plugins/hoster/BitshareCom.py b/pyload/plugins/hoster/BitshareCom.py index 2cbbc895f..d5d93fc7d 100644 --- a/pyload/plugins/hoster/BitshareCom.py +++ b/pyload/plugins/hoster/BitshareCom.py @@ -54,7 +54,7 @@ class BitshareCom(SimpleHoster): self.retry() # File name - m = re.search(self.__pattern__, self.pyfile.url) + m = re.match(self.__pattern__, self.pyfile.url) name1 = m.group('name') if m else None m = re.search(self.FILE_INFO_PATTERN, self.html) name2 = m.group('N') if m else None diff --git a/pyload/plugins/hoster/DdlstorageCom.py b/pyload/plugins/hoster/DdlstorageCom.py index 82072aadb..d62b725e7 100644 --- a/pyload/plugins/hoster/DdlstorageCom.py +++ b/pyload/plugins/hoster/DdlstorageCom.py @@ -52,7 +52,7 @@ class DdlstorageCom(XFileSharingPro): super(DdlstorageCom, self).prepare() def getAPIData(self): - file_id = re.search(self.__pattern__, self.pyfile.url).group('ID') + file_id = re.match(self.__pattern__, self.pyfile.url).group('ID') data = {'client_id': 53472, 'file_code': file_id} if self.user: diff --git a/pyload/plugins/hoster/FilepostCom.py b/pyload/plugins/hoster/FilepostCom.py index 191da7849..48b0ce311 100644 --- a/pyload/plugins/hoster/FilepostCom.py +++ b/pyload/plugins/hoster/FilepostCom.py @@ -46,7 +46,7 @@ class FilepostCom(SimpleHoster): def handleFree(self): # Find token and captcha key - file_id = re.search(self.__pattern__, self.pyfile.url).group(1) + file_id = re.match(self.__pattern__, self.pyfile.url).group(1) found = re.search(self.FLP_TOKEN_PATTERN, self.html) if not found: diff --git a/pyload/plugins/hoster/FileserveCom.py b/pyload/plugins/hoster/FileserveCom.py index 30471d69f..ea2f02914 100644 --- a/pyload/plugins/hoster/FileserveCom.py +++ b/pyload/plugins/hoster/FileserveCom.py @@ -67,7 +67,7 @@ class FileserveCom(Hoster): def setup(self): self.resumeDownload = self.multiDL = self.premium - self.file_id = re.search(self.__pattern__, self.pyfile.url).group('id') + self.file_id = re.match(self.__pattern__, self.pyfile.url).group('id') self.url = "%s%s" % (self.URLS[0], self.file_id) self.logDebug("File ID: %s URL: %s" % (self.file_id, self.url)) diff --git a/pyload/plugins/hoster/FreevideoCz.py b/pyload/plugins/hoster/FreevideoCz.py index 8d33050e6..c8ee90de1 100644 --- a/pyload/plugins/hoster/FreevideoCz.py +++ b/pyload/plugins/hoster/FreevideoCz.py @@ -62,6 +62,6 @@ class FreevideoCz(Hoster): self.fail("Parse error (URL)") download_url = found.group(1) - pyfile.name = re.search(self.__pattern__, pyfile.url).group(1) + ".mp4" + pyfile.name = re.match(self.__pattern__, pyfile.url).group(1) + ".mp4" self.download(download_url) diff --git a/pyload/plugins/hoster/HellshareCz.py b/pyload/plugins/hoster/HellshareCz.py index 6b8701d1f..c9408ed3f 100644 --- a/pyload/plugins/hoster/HellshareCz.py +++ b/pyload/plugins/hoster/HellshareCz.py @@ -41,7 +41,7 @@ class HellshareCz(SimpleHoster): def process(self, pyfile): if not self.account: self.fail("User not logged in") - pyfile.url = re.search(self.__pattern__, pyfile.url).group(1) + pyfile.url = re.match(self.__pattern__, pyfile.url).group(1) self.html = self.load(pyfile.url, decode=True) self.getFileInfo() if not self.checkTrafficLeft(): diff --git a/pyload/plugins/hoster/IfileIt.py b/pyload/plugins/hoster/IfileIt.py index 16f2ce576..16b9bb2d1 100644 --- a/pyload/plugins/hoster/IfileIt.py +++ b/pyload/plugins/hoster/IfileIt.py @@ -40,7 +40,7 @@ class IfileIt(SimpleHoster): TEMP_OFFLINE_PATTERN = r'<span class="msg_red">Downloading of this file is temporarily disabled</span>' def handleFree(self): - ukey = re.search(self.__pattern__, self.pyfile.url).group(1) + ukey = re.match(self.__pattern__, self.pyfile.url).group(1) json_url = 'http://ifile.it/new_download-request.json' post_data = {"ukey": ukey, "ab": "0"} diff --git a/pyload/plugins/hoster/IfolderRu.py b/pyload/plugins/hoster/IfolderRu.py index d128f427b..58c32af05 100644 --- a/pyload/plugins/hoster/IfolderRu.py +++ b/pyload/plugins/hoster/IfolderRu.py @@ -45,7 +45,7 @@ class IfolderRu(SimpleHoster): self.chunkLimit = 1 def process(self, pyfile): - file_id = re.search(self.__pattern__, pyfile.url).group('ID') + file_id = re.match(self.__pattern__, pyfile.url).group('ID') self.html = self.load("http://rusfolder.com/%s" % file_id, cookies=True, decode=True) self.getFileInfo() diff --git a/pyload/plugins/hoster/JumbofilesCom.py b/pyload/plugins/hoster/JumbofilesCom.py index b976c2aa1..9e97304b3 100644 --- a/pyload/plugins/hoster/JumbofilesCom.py +++ b/pyload/plugins/hoster/JumbofilesCom.py @@ -20,7 +20,7 @@ class JumbofilesCom(SimpleHoster): self.resumeDownload = self.multiDL = True def handleFree(self): - ukey = re.search(self.__pattern__, self.pyfile.url).group(1) + ukey = re.match(self.__pattern__, self.pyfile.url).group(1) post_data = {"id": ukey, "op": "download3", "rand": ""} html = self.load(self.pyfile.url, post=post_data, decode=True) url = re.search(self.DIRECT_LINK_PATTERN, html).group(1) diff --git a/pyload/plugins/hoster/LuckyShareNet.py b/pyload/plugins/hoster/LuckyShareNet.py index 1257656e7..ab9c3478f 100644 --- a/pyload/plugins/hoster/LuckyShareNet.py +++ b/pyload/plugins/hoster/LuckyShareNet.py @@ -37,7 +37,7 @@ class LuckyShareNet(SimpleHoster): # TODO: There should be a filesize limit for free downloads # TODO: Some files could not be downloaded in free mode def handleFree(self): - file_id = re.search(self.__pattern__, self.pyfile.url).group('ID') + file_id = re.match(self.__pattern__, self.pyfile.url).group('ID') self.logDebug('File ID: ' + file_id) rep = self.load(r"http://luckyshare.net/download/request/type/time/file/" + file_id, decode=True) self.logDebug('JSON: ' + rep) diff --git a/pyload/plugins/hoster/MegaNz.py b/pyload/plugins/hoster/MegaNz.py index 0d5e84f2f..bcdfecb5e 100644 --- a/pyload/plugins/hoster/MegaNz.py +++ b/pyload/plugins/hoster/MegaNz.py @@ -96,7 +96,7 @@ class MegaNz(Hoster): key = None # match is guaranteed because plugin was chosen to handle url - node = re.search(self.__pattern__, pyfile.url).group(2) + node = re.match(self.__pattern__, pyfile.url).group(2) if "!" in node: node, key = node.split("!") diff --git a/pyload/plugins/hoster/MegacrypterCom.py b/pyload/plugins/hoster/MegacrypterCom.py index 6dae50848..55342f88f 100644 --- a/pyload/plugins/hoster/MegacrypterCom.py +++ b/pyload/plugins/hoster/MegacrypterCom.py @@ -26,7 +26,7 @@ class MegacrypterCom(MegaNz): def process(self, pyfile): # match is guaranteed because plugin was chosen to handle url - node = re.search(self.__pattern__, pyfile.url).group(1) + node = re.match(self.__pattern__, pyfile.url).group(1) # get Mega.co.nz link info info = self.callApi(link=node, m="info") diff --git a/pyload/plugins/hoster/OneFichierCom.py b/pyload/plugins/hoster/OneFichierCom.py index e16793cf7..856f4e5ec 100644 --- a/pyload/plugins/hoster/OneFichierCom.py +++ b/pyload/plugins/hoster/OneFichierCom.py @@ -29,7 +29,7 @@ class OneFichierCom(SimpleHoster): RETRY_TIME = 15*60 #Default retry time in seconds (if detected parallel download) def process(self, pyfile): - found = re.search(self.__pattern__, pyfile.url) + found = re.match(self.__pattern__, pyfile.url) file_id = found.group(2) url = "http://%s.%s/en/" % (found.group(2), found.group(3)) self.html = self.load(url, decode=True) diff --git a/pyload/plugins/hoster/RapidshareCom.py b/pyload/plugins/hoster/RapidshareCom.py index e9735832b..71bab630e 100644 --- a/pyload/plugins/hoster/RapidshareCom.py +++ b/pyload/plugins/hoster/RapidshareCom.py @@ -78,7 +78,7 @@ class RapidshareCom(Hoster): self.prepare() def prepare(self): - m = re.search(self.__pattern__, self.url) + m = re.match(self.__pattern__, self.url) if m.group("name"): self.id = m.group("id") diff --git a/pyload/plugins/hoster/WebshareCz.py b/pyload/plugins/hoster/WebshareCz.py index c06bce016..c2648710b 100644 --- a/pyload/plugins/hoster/WebshareCz.py +++ b/pyload/plugins/hoster/WebshareCz.py @@ -58,7 +58,7 @@ class WebshareCz(SimpleHoster): def getFileInfo(self): self.logDebug("URL: %s" % self.pyfile.url) - self.fid = re.search(self.__pattern__, self.pyfile.url).group('ID') + self.fid = re.match(self.__pattern__, self.pyfile.url).group('ID') self.load(self.pyfile.url) api_data = self.load('https://webshare.cz/api/file_info/', post={'ident': self.fid}) diff --git a/pyload/plugins/hoster/XFileSharingPro.py b/pyload/plugins/hoster/XFileSharingPro.py index 3859d954e..80d24fa85 100644 --- a/pyload/plugins/hoster/XFileSharingPro.py +++ b/pyload/plugins/hoster/XFileSharingPro.py @@ -101,7 +101,7 @@ class XFileSharingPro(SimpleHoster): def prepare(self): """ Initialize important variables """ if not hasattr(self, "HOSTER_NAME"): - self.HOSTER_NAME = re.search(self.__pattern__, self.pyfile.url).group(1) + self.HOSTER_NAME = re.match(self.__pattern__, self.pyfile.url).group(1) if not hasattr(self, "DIRECT_LINK_PATTERN"): self.DIRECT_LINK_PATTERN = r'(http://([^/]*?%s|\d+\.\d+\.\d+\.\d+)(:\d+)?(/d/|(?:/files)?/\d+/\w+/)[^"\'<]+)' % self.HOSTER_NAME diff --git a/pyload/plugins/hoster/XHamsterCom.py b/pyload/plugins/hoster/XHamsterCom.py index ce1c5231e..ac15aef8a 100644 --- a/pyload/plugins/hoster/XHamsterCom.py +++ b/pyload/plugins/hoster/XHamsterCom.py @@ -98,7 +98,7 @@ class XHamsterCom(Hoster): file_name = re.search(file_name_pattern, self.html) if file_name is None: file_name_pattern = r"http://[www.]+xhamster\.com/movies/.*/(.*?)\.html?" - file_name = re.search(file_name_pattern, self.pyfile.url) + file_name = re.match(file_name_pattern, self.pyfile.url) if file_name is None: file_name_pattern = r"<div id=\"element_str_id\" style=\"display:none;\">(.*)</div>" file_name = re.search(file_name_pattern, self.html) diff --git a/pyload/plugins/hoster/XVideosCom.py b/pyload/plugins/hoster/XVideosCom.py index 902f627a8..0b925fd95 100644 --- a/pyload/plugins/hoster/XVideosCom.py +++ b/pyload/plugins/hoster/XVideosCom.py @@ -16,6 +16,6 @@ class XVideosCom(Hoster): site = self.load(pyfile.url) pyfile.name = "%s (%s).flv" % ( re.search(r"<h2>([^<]+)<span", site).group(1), - re.search(self.__pattern__, pyfile.url).group(1), + re.match(self.__pattern__, pyfile.url).group(1), ) self.download(urllib.unquote(re.search(r"flv_url=([^&]+)&", site).group(1))) diff --git a/pyload/plugins/hoster/Xdcc.py b/pyload/plugins/hoster/Xdcc.py index 5a5422cef..8e34977bb 100644 --- a/pyload/plugins/hoster/Xdcc.py +++ b/pyload/plugins/hoster/Xdcc.py @@ -82,7 +82,7 @@ class Xdcc(Hoster): if not exists(location): makedirs(location) - m = re.search(r'xdcc://(.*?)/#?(.*?)/(.*?)/#?(\d+)/?', url) + m = re.match(r'xdcc://(.*?)/#?(.*?)/(.*?)/#?(\d+)/?', url) server = m.group(1) chan = m.group(2) bot = m.group(3) |