diff options
author | Walter Purcaro <vuolter@users.noreply.github.com> | 2016-01-02 16:01:56 +0100 |
---|---|---|
committer | Walter Purcaro <vuolter@users.noreply.github.com> | 2016-01-02 16:01:56 +0100 |
commit | 6c75c0363f496df86e9c744a9a946f86f82715fa (patch) | |
tree | 53e5b7f906e2b9fb1d853d2b0599be7a8c5c7a3d | |
parent | Timeout for http request set to 1 minute + report effective url address in he... (diff) | |
download | pyload-6c75c0363f496df86e9c744a9a946f86f82715fa.tar.xz |
Spare code cosmetics
91 files changed, 178 insertions, 268 deletions
diff --git a/module/plugins/accounts/CzshareCom.py b/module/plugins/accounts/CzshareCom.py index 7b61db9f6..8852b5998 100644 --- a/module/plugins/accounts/CzshareCom.py +++ b/module/plugins/accounts/CzshareCom.py @@ -18,7 +18,7 @@ class CzshareCom(Account): ("stickell", "l.stickell@yahoo.it")] - CREDIT_LEFT_PATTERN = r'<tr class="active">\s*<td>([\d ,]+) (KiB|MiB|GiB)</td>\s*<td>([^<]*)</td>\s*</tr>' + CREDIT_LEFT_PATTERN = r'<tr class="active">\s*<td>([\d ,]+) (KiB|MiB|GiB)</td>\s*<td>(.*?)</td>\s*</tr>' def grab_info(self, user, password, data): diff --git a/module/plugins/accounts/DepositfilesCom.py b/module/plugins/accounts/DepositfilesCom.py index f9f97c1ce..e8e7e44f0 100644 --- a/module/plugins/accounts/DepositfilesCom.py +++ b/module/plugins/accounts/DepositfilesCom.py @@ -21,7 +21,7 @@ class DepositfilesCom(Account): def grab_info(self, user, password, data): html = self.load("https://dfiles.eu/de/gold/") - validuntil = re.search(r"Sie haben Gold Zugang bis: <b>(.*?)</b></div>", html).group(1) + validuntil = re.search(r'Sie haben Gold Zugang bis: <b>(.*?)</b></div>', html).group(1) validuntil = time.mktime(time.strptime(validuntil, "%Y-%m-%d %H:%M:%S")) diff --git a/module/plugins/accounts/FilerNet.py b/module/plugins/accounts/FilerNet.py index c3759d5e3..a8ce870b3 100644 --- a/module/plugins/accounts/FilerNet.py +++ b/module/plugins/accounts/FilerNet.py @@ -19,7 +19,7 @@ class FilerNet(Account): TOKEN_PATTERN = r'name="_csrf_token" value="(.+?)"' WALID_UNTIL_PATTERN = r'Der Premium-Zugang ist gültig bis (.+)\.\s*</td>' - TRAFFIC_PATTERN = r'Traffic</th>\s*<td>([^<]+)</td>' + TRAFFIC_PATTERN = r'Traffic</th>\s*<td>(.+?)</td>' FREE_PATTERN = r'Account Status</th>\s*<td>\s*Free' diff --git a/module/plugins/accounts/FreakshareCom.py b/module/plugins/accounts/FreakshareCom.py index 5f733b56d..61ce99540 100644 --- a/module/plugins/accounts/FreakshareCom.py +++ b/module/plugins/accounts/FreakshareCom.py @@ -32,7 +32,7 @@ class FreakshareCom(Account): pass try: - m = re.search(r'Traffic verbleibend:</td>\s*<td>([^<]+)', html, re.M) + m = re.search(r'Traffic verbleibend:</td>\s*<td>(.+?)', html, re.M) trafficleft = self.parse_traffic(m.group(1)) except Exception: diff --git a/module/plugins/accounts/FshareVn.py b/module/plugins/accounts/FshareVn.py index e75719082..0bbcb0ad2 100644 --- a/module/plugins/accounts/FshareVn.py +++ b/module/plugins/accounts/FshareVn.py @@ -18,7 +18,7 @@ class FshareVn(Account): ("stickell", "l.stickell@yahoo.it")] - VALID_UNTIL_PATTERN = ur'<dt>Thời hạn dùng:</dt>\s*<dd>([^<]+)</dd>' + VALID_UNTIL_PATTERN = ur'<dt>Thời hạn dùng:</dt>\s*<dd>(.+?)</dd>' LIFETIME_PATTERN = ur'<dt>Lần đăng nhập trước:</dt>\s*<dd>.+?</dd>' TRAFFIC_LEFT_PATTERN = ur'<dt>Tổng Dung Lượng Tài Khoản</dt>\s*<dd.*?>([\d.]+) ([kKMG])B</dd>' DIRECT_DOWNLOAD_PATTERN = ur'<input type="checkbox"\s*([^=>]*)[^>]*/>Kích hoạt download trực tiếp</dt>' diff --git a/module/plugins/accounts/HellshareCz.py b/module/plugins/accounts/HellshareCz.py index fa273eeeb..aef8232fd 100644 --- a/module/plugins/accounts/HellshareCz.py +++ b/module/plugins/accounts/HellshareCz.py @@ -59,7 +59,7 @@ class HellshareCz(Account): self.log_debug("Switch lang - URL: %s" % self.req.lastEffectiveURL) json = self.load("%s?do=locRouter-show" % self.req.lastEffectiveURL) - hash = re.search(r"(--[0-9a-f]+\-)", json).group(1) + hash = re.search(r'(--[0-9a-f]+\-)', json).group(1) self.log_debug("Switch lang - HASH: %s" % hash) diff --git a/module/plugins/accounts/SmoozedCom.py b/module/plugins/accounts/SmoozedCom.py index a6b9ba3be..c68f703e5 100644 --- a/module/plugins/accounts/SmoozedCom.py +++ b/module/plugins/accounts/SmoozedCom.py @@ -59,7 +59,7 @@ class SmoozedCom(MultiAccount): 'hosters' : [hoster['name'] for hoster in status['data']['hoster']]} if info['validuntil'] < time.time(): - if float(status['data']['user'].get("user_trial", 0)) > time.time(): + if float(status['data']['user'].get('user_trial', 0)) > time.time(): info['premium'] = True else: info['premium'] = False diff --git a/module/plugins/accounts/TusfilesNet.py b/module/plugins/accounts/TusfilesNet.py index 21498b7b1..ef0e898f2 100644 --- a/module/plugins/accounts/TusfilesNet.py +++ b/module/plugins/accounts/TusfilesNet.py @@ -19,5 +19,5 @@ class TusfilesNet(XFSAccount): PLUGIN_DOMAIN = "tusfiles.net" - VALID_UNTIL_PATTERN = r'<span class="label label-default">([^<]+)</span>' + VALID_UNTIL_PATTERN = r'<span class="label label-default">(.+?)</span>' TRAFFIC_LEFT_PATTERN = r'<td><img src="//www\.tusfiles\.net/i/icon/meter\.png" alt=""/></td>\n<td> (?P<S>[\d.,]+)' diff --git a/module/plugins/captcha/CircleCaptcha.py b/module/plugins/captcha/CircleCaptcha.py index e76cdc756..93bacae32 100644 --- a/module/plugins/captcha/CircleCaptcha.py +++ b/module/plugins/captcha/CircleCaptcha.py @@ -752,12 +752,12 @@ class CircleCaptcha(OCR): #: Delete nearly circle verify = -1 - # if verify is 0: + # if verify == 0: # if self.pyload.debug: # pix[c[0][0], c[0][1]] = 90 #(255, 255, 0) # im.save("output.png", "png") # return c[0][0], c[0][1] - # elif verify is 1: + # elif verify == 1: # if self.pyload.debug: # pix[c[0][0], c[0][1]] = 40 #(255, 0, 0) # im.save("output.png", "png") diff --git a/module/plugins/container/CCF.py b/module/plugins/container/CCF.py index 2cafb2977..fb1df8ba2 100644 --- a/module/plugins/container/CCF.py +++ b/module/plugins/container/CCF.py @@ -37,7 +37,7 @@ class CCF(Container): 'filename': "test.ccf", 'upload' : open(fs_filename, "rb")}).read() - dl_folder = self.pyload.config.get("general", "download_folder") + dl_folder = self.pyload.config.get('general', 'download_folder') dlc_file = fsjoin(dl_folder, "tmp_%s.dlc" % pyfile.name) try: diff --git a/module/plugins/container/RSDF.py b/module/plugins/container/RSDF.py index ec9e89171..942efe712 100644 --- a/module/plugins/container/RSDF.py +++ b/module/plugins/container/RSDF.py @@ -48,7 +48,7 @@ class RSDF(Container): except IOError, e: self.fail(e) - if re.search(r"<title>404 - Not Found</title>", data): + if re.search(r'<title>404 - Not Found</title>', data): pyfile.setStatus("offline") else: diff --git a/module/plugins/crypter/DailymotionComFolder.py b/module/plugins/crypter/DailymotionComFolder.py index 04eb4d939..d64c225fe 100644 --- a/module/plugins/crypter/DailymotionComFolder.py +++ b/module/plugins/crypter/DailymotionComFolder.py @@ -100,6 +100,6 @@ class DailymotionComFolder(Crypter): for p_id, p_name, p_owner in playlists: p_videos = self.get_videos(p_id) - p_folder = fsjoin(self.pyload.config.get("general", "download_folder"), p_owner, p_name) + p_folder = fsjoin(self.pyload.config.get('general', 'download_folder'), p_owner, p_name) self.log_debug("%s video\s found on playlist \"%s\"" % (len(p_videos), p_name)) self.packages.append((p_name, p_videos, p_folder)) #@NOTE: Folder is NOT recognized by pyload 0.4.9! diff --git a/module/plugins/crypter/DataHuFolder.py b/module/plugins/crypter/DataHuFolder.py index 270a41b3c..09c49e516 100644 --- a/module/plugins/crypter/DataHuFolder.py +++ b/module/plugins/crypter/DataHuFolder.py @@ -27,8 +27,8 @@ class DataHuFolder(SimpleCrypter): NAME_PATTERN = ur'<title>(?P<N>.+?) Let\xf6lt\xe9se</title>' - def prepare(self): - super(DataHuFolder, self).prepare() + def _prepare(self): + super(DataHuFolder, self)._prepare() if u'K\xe9rlek add meg a jelsz\xf3t' in self.data: #: Password protected password = self.get_password() diff --git a/module/plugins/crypter/Dereferer.py b/module/plugins/crypter/Dereferer.py index 52898eb62..d539ad08b 100644 --- a/module/plugins/crypter/Dereferer.py +++ b/module/plugins/crypter/Dereferer.py @@ -40,9 +40,5 @@ class Dereferer(SimpleCrypter): self.PLUGIN_NAME = "".join(part.capitalize() for part in re.split(r'\.|\d+|-', self.PLUGIN_DOMAIN) if part != '.') - def preload(self): - pass - - def get_links(self): return [self.info['pattern']['LINK']] diff --git a/module/plugins/crypter/DlProtectCom.py b/module/plugins/crypter/DlProtectCom.py index e09dc9e2e..7c44566eb 100644 --- a/module/plugins/crypter/DlProtectCom.py +++ b/module/plugins/crypter/DlProtectCom.py @@ -82,7 +82,7 @@ class DlProtectCom(SimpleCrypter): def get_links(self): #: Direct link with redirect - if not re.match(r"https?://(?:www\.)?dl-protect\.com/.+", self.req.http.lastEffectiveURL): + if not re.match(r'https?://(?:www\.)?dl-protect\.com/.+', self.req.http.lastEffectiveURL): return [self.req.http.lastEffectiveURL] post_req = {'key' : re.search(r'name="key" value="(.+?)"', self.data).group(1), diff --git a/module/plugins/crypter/Go4UpCom.py b/module/plugins/crypter/Go4UpCom.py index 143d189af..42dbc58bf 100755 --- a/module/plugins/crypter/Go4UpCom.py +++ b/module/plugins/crypter/Go4UpCom.py @@ -34,13 +34,13 @@ class Go4UpCom(SimpleCrypter): def get_links(self): links = [] - preference = self.config.get("preferred_hoster") + preference = self.config.get('preferred_hoster') hosterslink_re = re.search(r'(/download/gethosts/.+?)"', self.data) if hosterslink_re: hosters = self.load(urlparse.urljoin("http://go4up.com/", hosterslink_re.group(1))) for hoster in json.loads(hosters): - if preference != 0 and preference != int(hoster["hostId"]): + if preference not in (0, int(hoster["hostId"])): continue pagelink_re = re.search(self.LINK_PATTERN, hoster["link"]) if pagelink_re: diff --git a/module/plugins/crypter/LinkdecrypterCom.py b/module/plugins/crypter/LinkdecrypterCom.py index b3b0048e1..ce9c7e003 100644 --- a/module/plugins/crypter/LinkdecrypterCom.py +++ b/module/plugins/crypter/LinkdecrypterCom.py @@ -48,7 +48,7 @@ class LinkdecrypterCom(MultiCrypter): captcha_url = 'http://linkdecrypter.com/' + m.group(1) result_type = "positional" if "getPos" in m.group(2) else "textual" - m = re.search(r"<p><i><b>([^<]+)</b></i></p>", self.data) + m = re.search(r'<p><i><b>(.+?)</b></i></p>', self.data) msg = m.group(1) if m else "" self.log_info(_("Captcha protected link"), result_type, msg) diff --git a/module/plugins/crypter/MultiloadCz.py b/module/plugins/crypter/MultiloadCz.py index 657f101d6..594c375f3 100644 --- a/module/plugins/crypter/MultiloadCz.py +++ b/module/plugins/crypter/MultiloadCz.py @@ -25,7 +25,7 @@ class MultiloadCz(Crypter): FOLDER_PATTERN = r'<form action="" method="get"><textarea.*?>([^>]*)</textarea></form>' - LINK_PATTERN = r'<p class="manager-server"><strong>([^<]+)</strong></p><p class="manager-linky"><a href="(.+?)">' + LINK_PATTERN = r'<p class="manager-server"><strong>(.+?)</strong></p><p class="manager-linky"><a href="(.+?)">' def decrypt(self, pyfile): diff --git a/module/plugins/crypter/RelinkUs.py b/module/plugins/crypter/RelinkUs.py index 621c80216..9462bdfce 100644 --- a/module/plugins/crypter/RelinkUs.py +++ b/module/plugins/crypter/RelinkUs.py @@ -221,7 +221,7 @@ class RelinkUs(Crypter): try: dlc = self.load(container_url) dlc_filename = self.fileid + ".dlc" - dlc_filepath = fsjoin(self.pyload.config.get("general", "download_folder"), dlc_filename) + dlc_filepath = fsjoin(self.pyload.config.get('general', 'download_folder'), dlc_filename) with open(dlc_filepath, "wb") as f: f.write(dlc) pack_links.append(dlc_filepath) diff --git a/module/plugins/crypter/ShSt.py b/module/plugins/crypter/ShSt.py index fdb40bd76..ceea0a827 100644 --- a/module/plugins/crypter/ShSt.py +++ b/module/plugins/crypter/ShSt.py @@ -28,6 +28,6 @@ class ShSt(Crypter): #: If we use curl as a user agent, we will get a straight redirect (no waiting!) self.req.http.c.setopt(pycurl.USERAGENT, "curl/7.42.1") #: Fetch the target URL - header = self.load(self.pyfile.url, just_header = True, decode = False) + header = self.load(self.pyfile.url, just_header=True, decode=False) target_url = header.get('location') self.links.append(target_url) diff --git a/module/plugins/crypter/ShareLinksBiz.py b/module/plugins/crypter/ShareLinksBiz.py index 2aa670a7e..cdbb00184 100644 --- a/module/plugins/crypter/ShareLinksBiz.py +++ b/module/plugins/crypter/ShareLinksBiz.py @@ -110,7 +110,7 @@ class ShareLinksBiz(Crypter): def unblock_server(self): - imgs = re.findall(r"(/template/images/.*?\.gif)", self.data) + imgs = re.findall(r'(/template/images/.*?\.gif)', self.data) for img in imgs: self.load(self.base_url + img) diff --git a/module/plugins/crypter/YoutubeComFolder.py b/module/plugins/crypter/YoutubeComFolder.py index dc605ffce..c76c3b5b4 100644 --- a/module/plugins/crypter/YoutubeComFolder.py +++ b/module/plugins/crypter/YoutubeComFolder.py @@ -133,7 +133,7 @@ class YoutubeComFolder(Crypter): for p in playlists: p_name = p['title'] p_videos = self.get_videos_id(p['id']) - p_folder = fsjoin(self.pyload.config.get("general", "download_folder"), p['channelTitle'], p_name) + p_folder = fsjoin(self.pyload.config.get('general', 'download_folder'), p['channelTitle'], p_name) self.log_debug("%s video\s found on playlist \"%s\"" % (len(p_videos), p_name)) if not p_videos: diff --git a/module/plugins/hooks/AntiStandby.py b/module/plugins/hooks/AntiStandby.py index 05f33b397..732405188 100644 --- a/module/plugins/hooks/AntiStandby.py +++ b/module/plugins/hooks/AntiStandby.py @@ -162,7 +162,7 @@ class AntiStandby(Addon): not self.pyload.threadManager.getActiveFiles()): return - dl_folder = self.pyload.config.get("general", "download_folder") + dl_folder = self.pyload.config.get('general', 'download_folder') if (self.max_mtime(dl_folder) - self.mtime) < self.periodical.interval: return diff --git a/module/plugins/hooks/ClickNLoad.py b/module/plugins/hooks/ClickNLoad.py index 4ac6b507f..ac47d8a68 100644 --- a/module/plugins/hooks/ClickNLoad.py +++ b/module/plugins/hooks/ClickNLoad.py @@ -32,14 +32,14 @@ class ClickNLoad(Addon): def activate(self): - if not self.pyload.config.get("webinterface", "activated"): + if not self.pyload.config.get('webinterface', 'activated'): return cnlip = "" if self.config.get('extern') else "127.0.0.1" cnlport = self.config.get('port') - webip = "127.0.0.1" if any(_ip == self.pyload.config.get("webinterface", "host") for _ip in ("0.0.0.0", "")) \ - else self.pyload.config.get("webinterface", "host") - webport = self.pyload.config.get("webinterface", "port") + webip = "127.0.0.1" if any(_ip == self.pyload.config.get('webinterface', 'host') for _ip in ("0.0.0.0", "")) \ + else self.pyload.config.get('webinterface', 'host') + webport = self.pyload.config.get('webinterface', 'port') self.pyload.scheduler.addJob(5, self.proxy, [cnlip, cnlport, webip, webport], threaded=False) @@ -77,7 +77,7 @@ class ClickNLoad(Addon): server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - if self.pyload.config.get("webinterface", "https"): + if self.pyload.config.get('webinterface', 'https'): try: server_socket = ssl.wrap_socket(server_socket) diff --git a/module/plugins/hooks/DownloadScheduler.py b/module/plugins/hooks/DownloadScheduler.py index d4c0356fd..383150fce 100644 --- a/module/plugins/hooks/DownloadScheduler.py +++ b/module/plugins/hooks/DownloadScheduler.py @@ -66,9 +66,9 @@ class DownloadScheduler(Addon): if speed > 0: self.log_info(_("Setting download speed to %d kB/s") % speed) - self.pyload.config.set("download", "limit_speed", 1) - self.pyload.config.set("download", "max_speed", speed) + self.pyload.config.set('download', 'limit_speed', 1) + self.pyload.config.set('download', 'max_speed', speed) else: self.log_info(_("Setting download speed to FULL")) - self.pyload.config.set("download", "limit_speed", 0) - self.pyload.config.set("download", "max_speed", -1) + self.pyload.config.set('download', 'limit_speed', 0) + self.pyload.config.set('download', 'max_speed', -1) diff --git a/module/plugins/hooks/IRC.py b/module/plugins/hooks/IRC.py index 2b7bea5fd..65ae2a356 100644 --- a/module/plugins/hooks/IRC.py +++ b/module/plugins/hooks/IRC.py @@ -80,7 +80,7 @@ class IRC(Thread, Notifier): html = self.load("http://www.freeimagehosting.net/upload.php", post={'attached': (pycurl.FORM_FILE, task.captchaFile)}) - url = re.search(r"\[img\]([^\[]+)\[/img\]\[/url\]", html).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/MultiHome.py b/module/plugins/hooks/MultiHome.py index c8c5f4fa7..a7c35c88f 100644 --- a/module/plugins/hooks/MultiHome.py +++ b/module/plugins/hooks/MultiHome.py @@ -62,8 +62,8 @@ class MultiHome(Addon): self.parse_interfaces(self.config.get('interfaces').split(";")) if not self.interfaces: - self.parse_interfaces([self.pyload.config.get("download", "interface")]) - self.config.set("interfaces", self.to_config()) + self.parse_interfaces([self.pyload.config.get('download', 'interface')]) + self.config.set('interfaces', self.to_config()) def to_config(self): diff --git a/module/plugins/hooks/TransmissionRPC.py b/module/plugins/hooks/TransmissionRPC.py index 0e71941ef..457cb8205 100644 --- a/module/plugins/hooks/TransmissionRPC.py +++ b/module/plugins/hooks/TransmissionRPC.py @@ -54,7 +54,7 @@ class TransmissionRPC(Addon): except Exception, e: if isinstance(e, BadHeader) and e.code == 409: - headers = dict(re.findall(r"(?P<name>.+?): (?P<value>.+?)\r?\n", req.header)) + headers = dict(re.findall(r'(?P<name>.+?): (?P<value>.+?)\r?\n', req.header)) session_id = headers['X-Transmission-Session-Id'] req.c.setopt(pycurl.HTTPHEADER, ["X-Transmission-Session-Id: %s" % session_id]) try: diff --git a/module/plugins/hooks/XFileSharing.py b/module/plugins/hooks/XFileSharing.py index 3de4d02eb..a3d976d34 100644 --- a/module/plugins/hooks/XFileSharing.py +++ b/module/plugins/hooks/XFileSharing.py @@ -60,7 +60,7 @@ class XFileSharing(Addon): def get_pattern(self, type, plugin): - if self.config.get("use_%s_list" % type): + if self.config.get('use_%s_list' % type): plugin_list = self.config.get('%s_list' % type) plugin_list = plugin_list.replace(' ', '').replace('\\', '') plugin_list = plugin_list.replace('|', ',').replace(';', ',') diff --git a/module/plugins/hoster/BezvadataCz.py b/module/plugins/hoster/BezvadataCz.py index 51082a8a1..626673b44 100644 --- a/module/plugins/hoster/BezvadataCz.py +++ b/module/plugins/hoster/BezvadataCz.py @@ -23,8 +23,8 @@ class BezvadataCz(SimpleHoster): __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] - NAME_PATTERN = r'<p><b>Soubor: (?P<N>[^<]+)</b></p>' - SIZE_PATTERN = r'<li><strong>Velikost:</strong> (?P<S>[^<]+)</li>' + NAME_PATTERN = r'<p><b>Soubor: (?P<N>.+?)</b></p>' + SIZE_PATTERN = r'<li><strong>Velikost:</strong> (?P<S>.+?)</li>' OFFLINE_PATTERN = r'<title>BezvaData \| Soubor nenalezen</title>' diff --git a/module/plugins/hoster/CrockoCom.py b/module/plugins/hoster/CrockoCom.py index 2205759e8..eb8da1f9f 100644 --- a/module/plugins/hoster/CrockoCom.py +++ b/module/plugins/hoster/CrockoCom.py @@ -26,7 +26,7 @@ class CrockoCom(SimpleHoster): NAME_PATTERN = r'<span class="fz24">Download:\s*<strong>(?P<N>.*)' - SIZE_PATTERN = r'<span class="tip1"><span class="inner">(?P<S>[^<]+)</span></span>' + SIZE_PATTERN = r'<span class="tip1"><span class="inner">(?P<S>.+?)</span></span>' OFFLINE_PATTERN = r'<h1>Sorry,<br />the page you\'re looking for <br />isn\'t here.</h1>|File not found' CAPTCHA_PATTERN = r"u='(/file_contents/captcha/\w+)';\s*w='(\d+)';" diff --git a/module/plugins/hoster/CzshareCom.py b/module/plugins/hoster/CzshareCom.py index c2a7d3409..42a2ec02b 100644 --- a/module/plugins/hoster/CzshareCom.py +++ b/module/plugins/hoster/CzshareCom.py @@ -27,7 +27,7 @@ class CzshareCom(SimpleHoster): __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] - NAME_PATTERN = r'<div class="tab" id="parameters">\s*<p>\s*Cel. n.zev: <a href=.*?>(?P<N>[^<]+)</a>' + NAME_PATTERN = r'<div class="tab" id="parameters">\s*<p>\s*Cel. n.zev: <a href=.*?>(?P<N>.+?)</a>' SIZE_PATTERN = r'<div class="tab" id="category">(?:\s*<p>[^\n]*</p>)*\s*Velikost:\s*(?P<S>[\d .,]+)(?P<U>[\w^_]+)\s*</div>' OFFLINE_PATTERN = r'<div class="header clearfix">\s*<h2 class="red">' @@ -40,7 +40,7 @@ class CzshareCom(SimpleHoster): FREE_FORM_PATTERN = r'<form action="download\.php" method="post">\s*<img src="captcha\.php" id="captcha" />(.*?)</form>' PREMIUM_FORM_PATTERN = r'<form action="/profi_down\.php" method="post">(.*?)</form>' FORM_INPUT_PATTERN = r'<input[^>]* name="(.+?)" value="(.+?)"[^>]*/>' - MULTIDL_PATTERN = r'<p><font color=\'red\'>Z[^<]*PROFI.</font></p>' + MULTIDL_PATTERN = r'<p><font color=\'red\'>Z.*?PROFI.</font></p>' USER_CREDIT_PATTERN = r'<div class="credit">\s*kredit: <strong>([\d .,]+)(\w+)</strong>\s*</div><!-- .credit -->' @@ -139,8 +139,8 @@ class CzshareCom(SimpleHoster): def check_download(self): #: Check download check = self.scan_download({ - "temp offline" : re.compile(r"^Soubor je do.*asn.* nedostupn.*$"), - 'credit' : re.compile(r"^Nem.*te dostate.*n.* kredit.$"), + "temp offline" : re.compile(r'^Soubor je do.*asn.* nedostupn.*$'), + 'credit' : re.compile(r'^Nem.*te dostate.*n.* kredit.$'), "multi-dl" : re.compile(self.MULTIDL_PATTERN), 'captcha' : "<li>Zadaný ověřovací kód nesouhlasí!</li>" }) diff --git a/module/plugins/hoster/DailymotionCom.py b/module/plugins/hoster/DailymotionCom.py index 119373b08..bef146d84 100644 --- a/module/plugins/hoster/DailymotionCom.py +++ b/module/plugins/hoster/DailymotionCom.py @@ -64,7 +64,7 @@ class DailymotionCom(Hoster): def get_streams(self): streams = [] - for result in re.finditer(r"\"(?P<URL>http:\\/\\/www.dailymotion.com\\/cdn\\/H264-(?P<QF>.*?)\\.*?)\"", + for result in re.finditer(r'\"(?P<URL>http:\\/\\/www.dailymotion.com\\/cdn\\/H264-(?P<QF>.*?)\\.*?)\"', self.data): url = result.group('URL') qf = result.group('QF') diff --git a/module/plugins/hoster/DataportCz.py b/module/plugins/hoster/DataportCz.py index 5c9756b51..2ec4eb6b1 100644 --- a/module/plugins/hoster/DataportCz.py +++ b/module/plugins/hoster/DataportCz.py @@ -21,7 +21,7 @@ class DataportCz(SimpleHoster): __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] - NAME_PATTERN = r'<span itemprop="name">(?P<N>[^<]+)</span>' + NAME_PATTERN = r'<span itemprop="name">(?P<N>.+?)</span>' SIZE_PATTERN = r'<td class="fil">Velikost</td>\s*<td>(?P<S>[^<]+)</td>' OFFLINE_PATTERN = r'<h2>Soubor nebyl nalezen</h2>' diff --git a/module/plugins/hoster/EuroshareEu.py b/module/plugins/hoster/EuroshareEu.py index 2df748cd2..3ef8f89bd 100644 --- a/module/plugins/hoster/EuroshareEu.py +++ b/module/plugins/hoster/EuroshareEu.py @@ -33,7 +33,7 @@ class EuroshareEu(SimpleHoster): DL_LIMIT_PATTERN = r'<h2>Prebieha s.ahovanie</h2>|<p>Naraz je z jednej IP adresy mo.n. s.ahova. iba jeden s.bor' ERROR_PATTERN = r'href="/customer-zone/login/"' - URL_REPLACEMENTS = [(r"(http://[^/]*\.)(sk|cz|hu|pl)/", r"\1eu/")] + URL_REPLACEMENTS = [(r'(http://[^/]*\.)(sk|cz|hu|pl)/', r'\1eu/')] def handle_premium(self, pyfile): diff --git a/module/plugins/hoster/ExtabitCom.py b/module/plugins/hoster/ExtabitCom.py index f854c0e38..e71fb41c1 100644 --- a/module/plugins/hoster/ExtabitCom.py +++ b/module/plugins/hoster/ExtabitCom.py @@ -28,7 +28,7 @@ class ExtabitCom(SimpleHoster): NAME_PATTERN = r'<th>File:</th>\s*<td class="col-fileinfo">\s*<div title="(?P<N>.+?)">' - SIZE_PATTERN = r'<th>Size:</th>\s*<td class="col-fileinfo">(?P<S>[^<]+)</td>' + SIZE_PATTERN = r'<th>Size:</th>\s*<td class="col-fileinfo">(?P<S>.+?)</td>' OFFLINE_PATTERN = r'>File not found<' TEMP_OFFLINE_PATTERN = r'>(File is temporary unavailable|No download mirror)<' @@ -36,10 +36,10 @@ class ExtabitCom(SimpleHoster): def handle_free(self, pyfile): - if r">Only premium users can download this file" in self.data: + if r'>Only premium users can download this file" in self.data: self.fail(_("Only premium users can download this file")) - m = re.search(r"Next free download from your ip will be available in <b>(\d+)\s*minutes", self.data) + m = re.search(r"Next free download from your ip will be available in <b>(\d+)\s*minutes', self.data) if m is not None: self.wait(int(m.group(1)) * 60, True) elif "The daily downloads limit from your IP is exceeded" in self.data: diff --git a/module/plugins/hoster/FilepostCom.py b/module/plugins/hoster/FilepostCom.py index c47684522..0d2e3d81f 100644 --- a/module/plugins/hoster/FilepostCom.py +++ b/module/plugins/hoster/FilepostCom.py @@ -26,7 +26,7 @@ class FilepostCom(SimpleHoster): __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] - INFO_PATTERN = r'<input type="text" id="url" value=\'<a href.*?>(?P<N>[^>]+?) - (?P<S>[\d.,]+) (?P<U>[\w^_]+)</a>\' class="inp_text"/>' + INFO_PATTERN = r'<input type="text" id="url" value=\'<a href.*?>(?P<N>.+?) - (?P<S>[\d.,]+) (?P<U>[\w^_]+)</a>\' class="inp_text"/>' OFFLINE_PATTERN = r'class="error_msg_title"> Invalid or Deleted File. </div>|<div class="file_info file_info_deleted">' PREMIUM_ONLY_PATTERN = r'members only. Please upgrade to premium|a premium membership is required to download this file' diff --git a/module/plugins/hoster/FilesMailRu.py b/module/plugins/hoster/FilesMailRu.py index 04a91fe94..cab8dc68a 100644 --- a/module/plugins/hoster/FilesMailRu.py +++ b/module/plugins/hoster/FilesMailRu.py @@ -7,29 +7,6 @@ from module.plugins.internal.Hoster import Hoster from module.plugins.internal.misc import chunks -def get_info(urls): - result = [] - for chunk in chunks(urls, 10): - for url in chunk: - html = get_url(url) - if r'<div class="errorMessage mb10">' in html: - result.append((url, 0, 1, url)) - elif r'Page cannot be displayed' in html: - result.append((url, 0, 1, url)) - else: - try: - url_pattern = '<a href="(.+?)" onclick="return Act\(this\, \'dlink\'\, event\)">(.+?)</a>' - file_name = re.search(url_pattern, html).group(0).split(', event)">')[1].split('</a>')[0] - result.append((file_name, 0, 2, url)) - - except Exception: - pass - - #: status 1=OFFLINE, 2=OK, 3=UNKNOWN - #: result.append((#name,#size,#status,#url)) - yield result - - class FilesMailRu(Hoster): __name__ = "FilesMailRu" __type__ = "hoster" diff --git a/module/plugins/hoster/FileserveCom.py b/module/plugins/hoster/FileserveCom.py index cb39311bc..933911f4f 100644 --- a/module/plugins/hoster/FileserveCom.py +++ b/module/plugins/hoster/FileserveCom.py @@ -8,26 +8,6 @@ from module.plugins.internal.Hoster import Hoster from module.plugins.internal.misc import json, parse_size, seconds_to_midnight -def get_info(plugin, urls): - html = get_url(plugin.URLS[1], post={'urls': "\n".join(urls)}) - - file_info = [] - for li in re.finditer(plugin.LINKCHECK_TR, html, re.S): - try: - cols = re.findall(plugin.LINKCHECK_TD, li.group(1)) - if cols: - file_info.append(( - cols[1] if cols[1] != '--' else cols[0], - parse_size(cols[2]) if cols[2] != '--' else 0, - 2 if cols[3].startswith('Available') else 1, - cols[0])) - - except Exception, e: - continue - - return file_info - - class FileserveCom(Hoster): __name__ = "FileserveCom" __type__ = "hoster" @@ -49,9 +29,6 @@ class FileserveCom(Hoster): "http://www.fileserve.com/link-checker.php", "http://www.fileserve.com/checkReCaptcha.php"] - LINKCHECK_TR = r'<tr>\s*(<td>http://www\.fileserve\.com/file/.*?)</tr>' - LINKCHECK_TD = r'<td>(?:<.*?>| )*([^<]*)' - CAPTCHA_KEY_PATTERN = r'var reCAPTCHA_publickey=\'(.+?)\'' LONG_WAIT_PATTERN = r'<li class="title">You need to wait (\d+) (\w+) to start another download\.</li>' LINK_EXPIRED_PATTERN = r'Your download link has expired' diff --git a/module/plugins/hoster/FourSharedCom.py b/module/plugins/hoster/FourSharedCom.py index ccfd30f4a..ab8d6ab48 100644 --- a/module/plugins/hoster/FourSharedCom.py +++ b/module/plugins/hoster/FourSharedCom.py @@ -28,7 +28,7 @@ class FourSharedCom(SimpleHoster): SIZE_PATTERN = r'<span title="Size: (?P<S>[\d.,]+) (?P<U>[\w^_]+)">' OFFLINE_PATTERN = r'The file link that you requested is not valid\.|This file was deleted.' - NAME_REPLACEMENTS = [(r"&#(\d+).", lambda m: unichr(int(m.group(1))))] + NAME_REPLACEMENTS = [(r'&#(\d+).', lambda m: unichr(int(m.group(1))))] SIZE_REPLACEMENTS = [(",", "")] DIRECT_LINK = False diff --git a/module/plugins/hoster/FreakshareCom.py b/module/plugins/hoster/FreakshareCom.py index b24dabd28..ddad47699 100644 --- a/module/plugins/hoster/FreakshareCom.py +++ b/module/plugins/hoster/FreakshareCom.py @@ -112,7 +112,7 @@ class FreakshareCom(Hoster): self.download_html() if not self.wantReconnect: - m = re.search(r"<h1\sclass=\"box_heading\"\sstyle=\"text-align:center;\">([^ ]+)", self.data) + m = re.search(r'<h1\sclass=\"box_heading\"\sstyle=\"text-align:center;\">([^ ]+)', self.data) if m is not None: file_name = m.group(1) else: @@ -129,7 +129,7 @@ class FreakshareCom(Hoster): self.download_html() if not self.wantReconnect: - m = re.search(r"<h1\sclass=\"box_heading\"\sstyle=\"text-align:center;\">[^ ]+ - ([^ ]+) (\w\w)yte", self.data) + m = re.search(r'<h1\sclass=\"box_heading\"\sstyle=\"text-align:center;\">[^ ]+ - ([^ ]+) (\w\w)yte', self.data) if m is not None: units = float(m.group(1).replace(",", "")) pow = {'KB': 1, 'MB': 2, 'GB': 3}[m.group(2)] @@ -159,24 +159,24 @@ class FreakshareCom(Hoster): """ if not self.data: self.download_html() - if re.search(r"This file does not exist!", self.data): + if re.search(r'This file does not exist!', self.data): return False else: return True def get_download_options(self): - re_envelope = re.search(r".*?value=\"Free\sDownload\".*?\n*?(.*?<.*?>\n*)*?\n*\s*?</form>", + re_envelope = re.search(r'.*?value=\"Free\sDownload\".*?\n*?(.*?<.*?>\n*)*?\n*\s*?</form>', self.data).group(0) #: Get the whole request - to_sort = re.findall(r"<input\stype=\"hidden\"\svalue=\"(.*?)\"\sname=\"(.*?)\"\s\/>", re_envelope) + to_sort = re.findall(r'<input\stype=\"hidden\"\svalue=\"(.*?)\"\sname=\"(.*?)\"\s\/>', re_envelope) request_options = dict((n, v) for (v, n) in to_sort) herewego = self.load(self.pyfile.url, None, request_options) #: The actual download-Page - to_sort = re.findall(r"<input\stype=\".*?\"\svalue=\"(\S*?)\".*?name=\"(\S*?)\"\s.*?\/>", herewego) + to_sort = re.findall(r'<input\stype=\".*?\"\svalue=\"(\S*?)\".*?name=\"(\S*?)\"\s.*?\/>', herewego) request_options = dict((n, v) for (v, n) in to_sort) - challenge = re.search(r"http://api\.recaptcha\.net/challenge\?k=(\w+)", herewego) + challenge = re.search(r'http://api\.recaptcha\.net/challenge\?k=(\w+)', herewego) if challenge: re_captcha = ReCaptcha(self.pyfile) diff --git a/module/plugins/hoster/FshareVn.py b/module/plugins/hoster/FshareVn.py index 8fa920e07..5a6710470 100644 --- a/module/plugins/hoster/FshareVn.py +++ b/module/plugins/hoster/FshareVn.py @@ -9,14 +9,6 @@ from module.plugins.internal.Base import parse_fileInfo from module.plugins.internal.SimpleHoster import SimpleHoster -def get_info(urls): - for url in urls: - html = get_url("http://www.fshare.vn/check_link.php", - post={'action': "check_link", 'arrlinks': url}) - - yield parse_fileInfo(FshareVn, url, html) - - def double_decode(m): return m.group(1).decode('raw_unicode_escape') @@ -39,7 +31,7 @@ class FshareVn(SimpleHoster): __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] - INFO_PATTERN = r'<p>(?P<N>[^<]+)<\\/p>[\\trn\s]*<p>(?P<S>[\d.,]+)\s*(?P<U>[\w^_]+)<\\/p>' + INFO_PATTERN = r'<p>(?P<N>.+?)<\\/p>[\\trn\s]*<p>(?P<S>[\d.,]+)\s*(?P<U>[\w^_]+)<\\/p>' OFFLINE_PATTERN = r'<div class=\\"f_left file_w\\"|<\\/p>\\t\\t\\t\\t\\r\\n\\t\\t<p><\\/p>\\t\\t\\r\\n\\t\\t<p>0 KB<\\/p>' NAME_REPLACEMENTS = [("(.*)", double_decode)] diff --git a/module/plugins/hoster/Ftp.py b/module/plugins/hoster/Ftp.py index 623879dd8..babf6c2c5 100644 --- a/module/plugins/hoster/Ftp.py +++ b/module/plugins/hoster/Ftp.py @@ -67,10 +67,9 @@ class Ftp(Hoster): self.req.http.c.setopt(pycurl.NOBODY, 0) self.log_debug(self.req.http.header) - m = re.search(r"Content-Length:\s*(\d+)", res) + m = re.search(r'Content-Length:\s*(\d+)', res) if m is not None: pyfile.size = int(m.group(1)) - self.download(pyfile.url) else: diff --git a/module/plugins/hoster/HighWayMe.py b/module/plugins/hoster/HighWayMe.py index 029cb7fdc..cf50d2808 100644 --- a/module/plugins/hoster/HighWayMe.py +++ b/module/plugins/hoster/HighWayMe.py @@ -65,7 +65,7 @@ class HighWayMe(MultiHoster): self.check_errors() try: - self.pyfile.name = re.search(r'<name>([^<]+)</name>', self.data).group(1) + self.pyfile.name = re.search(r'<name>(.+?)</name>', self.data).group(1) except AttributeError: self.pyfile.name = "" @@ -76,4 +76,4 @@ class HighWayMe(MultiHoster): except AttributeError: self.pyfile.size = 0 - self.link = re.search(r'<download>([^<]+)</download>', self.data).group(1) + self.link = re.search(r'<download>(.+?)</download>', self.data).group(1) diff --git a/module/plugins/hoster/Http.py b/module/plugins/hoster/Http.py index 9d03b189b..01748c697 100644 --- a/module/plugins/hoster/Http.py +++ b/module/plugins/hoster/Http.py @@ -15,7 +15,7 @@ class Http(Hoster): __pattern__ = r'(?:jd|pys?)://.+' __config__ = [("activated", "bool", "Activated", True)] - __description__ = """Download from http link""" + __description__ = """Download simple http link""" __license__ = "GPLv3" __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] diff --git a/module/plugins/hoster/HugefilesNet.py b/module/plugins/hoster/HugefilesNet.py index 0c8f1ecc4..85f8b45f2 100644 --- a/module/plugins/hoster/HugefilesNet.py +++ b/module/plugins/hoster/HugefilesNet.py @@ -25,6 +25,6 @@ class HugefilesNet(XFSHoster): PLUGIN_DOMAIN = "hugefiles.net" - SIZE_PATTERN = r'File Size:</span>\s*<span.*?>(?P<S>[^<]+)</span></div>' + SIZE_PATTERN = r'File Size:</span>\s*<span.*?>(?P<S>.+?)</span></div>' FORM_INPUTS_MAP = {'ctype': re.compile(r'\d+')} diff --git a/module/plugins/hoster/IfolderRu.py b/module/plugins/hoster/IfolderRu.py index 919d37b75..8e47c01ed 100644 --- a/module/plugins/hoster/IfolderRu.py +++ b/module/plugins/hoster/IfolderRu.py @@ -25,8 +25,8 @@ class IfolderRu(SimpleHoster): SIZE_REPLACEMENTS = [(u'Кб', 'KB'), (u'Мб', 'MB'), (u'Гб', 'GB')] - NAME_PATTERN = ur'(?:<div><span>)?Название:(?:</span>)? <b>(?P<N>[^<]+)</b><(?:/div|br)>' - SIZE_PATTERN = ur'(?:<div><span>)?Размер:(?:</span>)? <b>(?P<S>[^<]+)</b><(?:/div|br)>' + NAME_PATTERN = ur'(?:<div><span>)?Название:(?:</span>)? <b>(?P<N>.+?)</b><(?:/div|br)>' + SIZE_PATTERN = ur'(?:<div><span>)?Размер:(?:</span>)? <b>(?P<S>.+?)</b><(?:/div|br)>' OFFLINE_PATTERN = ur'<p>Файл номер <b>.*?</b> (не найден|удален) !!!</p>' SESSION_ID_PATTERN = r'<input type="hidden" name="session" value="(.+?)"' diff --git a/module/plugins/hoster/JumbofilesCom.py b/module/plugins/hoster/JumbofilesCom.py index fe3ffb9eb..86d4e9f3f 100644 --- a/module/plugins/hoster/JumbofilesCom.py +++ b/module/plugins/hoster/JumbofilesCom.py @@ -23,7 +23,7 @@ class JumbofilesCom(SimpleHoster): __authors__ = [("godofdream", "soilfiction@gmail.com")] - INFO_PATTERN = r'<TR><TD>(?P<N>[^<]+?)\s*<small>\((?P<S>[\d.,]+)\s*(?P<U>[\w^_]+)' + INFO_PATTERN = r'<TR><TD>(?P<N>.+?)\s*<small>\((?P<S>[\d.,]+)\s*(?P<U>[\w^_]+)' OFFLINE_PATTERN = r'Not Found or Deleted / Disabled due to inactivity or DMCA' LINK_FREE_PATTERN = r'<meta http-equiv="refresh" content="10;url=(.+)">' diff --git a/module/plugins/hoster/Keep2ShareCc.py b/module/plugins/hoster/Keep2ShareCc.py index 43c89176b..a66033590 100644 --- a/module/plugins/hoster/Keep2ShareCc.py +++ b/module/plugins/hoster/Keep2ShareCc.py @@ -29,7 +29,7 @@ class Keep2ShareCc(SimpleHoster): URL_REPLACEMENTS = [(__pattern__ + ".*", "http://keep2s.cc/file/\g<ID>")] NAME_PATTERN = r'File: <span>(?P<N>.+?)</span>' - SIZE_PATTERN = r'Size: (?P<S>[^<]+)</div>' + SIZE_PATTERN = r'Size: (?P<S>.+?)</div>' OFFLINE_PATTERN = r'File not found or deleted|Sorry, this file is blocked or deleted|Error 404' TEMP_OFFLINE_PATTERN = r'Downloading blocked due to' diff --git a/module/plugins/hoster/LetitbitNet.py b/module/plugins/hoster/LetitbitNet.py index 2d3b9da9c..321ced131 100644 --- a/module/plugins/hoster/LetitbitNet.py +++ b/module/plugins/hoster/LetitbitNet.py @@ -16,23 +16,6 @@ from module.plugins.internal.SimpleHoster import SimpleHoster from module.plugins.internal.misc import seconds_to_midnight -def api_response(url): - json_data = ["yw7XQy2v9", ["download/info", {'link': url}]] - api_rep = get_url("http://api.letitbit.net/json", - post={'r': json.dumps(json_data)}) - return json.loads(api_rep) - - -def get_info(urls): - for url in urls: - api_rep = api_response(url) - if api_rep['status'] == "OK": - info = api_rep['data'][0] - yield (info['name'], info['size'], 2, url) - else: - yield (url, 0, 1, url) - - class LetitbitNet(SimpleHoster): __name__ = "LetitbitNet" __type__ = "hoster" @@ -52,7 +35,7 @@ class LetitbitNet(SimpleHoster): ("z00nx", "z00nx0@gmail.com")] - URL_REPLACEMENTS = [(r"(?<=http://)([^/]+)", "letitbit.net")] + URL_REPLACEMENTS = [(r'(?<=http://)([^/]+)', "letitbit.net")] SECONDS_PATTERN = r'seconds\s*=\s*(\d+);' CAPTCHA_CONTROL_FIELD = r'recaptcha_control_field\s=\s\'(.+?)\'' diff --git a/module/plugins/hoster/LuckyShareNet.py b/module/plugins/hoster/LuckyShareNet.py index 1aa5501d5..ad6d0be85 100644 --- a/module/plugins/hoster/LuckyShareNet.py +++ b/module/plugins/hoster/LuckyShareNet.py @@ -32,7 +32,7 @@ class LuckyShareNet(SimpleHoster): def parse_json(self, rep): if 'AJAX Error' in rep: html = self.load(self.pyfile.url) - m = re.search(r"waitingtime = (\d+);", html) + m = re.search(r'waitingtime = (\d+);', html) if m is not None: seconds = int(m.group(1)) self.log_debug("You have to wait %d seconds between free downloads" % seconds) @@ -47,7 +47,7 @@ class LuckyShareNet(SimpleHoster): #@TODO: There should be a filesize limit for free downloads #: Some files could not be downloaded in free mode def handle_free(self, pyfile): - rep = self.load(r"http://luckyshare.net/download/request/type/time/file/" + self.info['pattern']['ID']) + rep = self.load(r'http://luckyshare.net/download/request/type/time/file/' + self.info['pattern']['ID']) self.log_debug("JSON: " + rep) @@ -57,7 +57,7 @@ class LuckyShareNet(SimpleHoster): self.captcha = ReCaptcha(pyfile) response, challenge = self.captcha.challenge() - rep = self.load(r"http://luckyshare.net/download/verify/challenge/%s/response/%s/hash/%s" % + rep = self.load(r'http://luckyshare.net/download/verify/challenge/%s/response/%s/hash/%s' % (challenge, response, json_data['hash'])) self.log_debug("JSON: " + rep) diff --git a/module/plugins/hoster/MegaRapidCz.py b/module/plugins/hoster/MegaRapidCz.py index 3d1b288d6..4ba13c57f 100644 --- a/module/plugins/hoster/MegaRapidCz.py +++ b/module/plugins/hoster/MegaRapidCz.py @@ -10,17 +10,6 @@ from module.plugins.internal.Base import parse_fileInfo from module.plugins.internal.SimpleHoster import SimpleHoster -def get_info(urls): - h = get_request() - h.c.setopt(pycurl.HTTPHEADER, - ["Accept: text/html", - "User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0"]) - - for url in urls: - html = h.load(url) - yield parse_fileInfo(MegaRapidCz, url, html) - - class MegaRapidCz(SimpleHoster): __name__ = "MegaRapidCz" __type__ = "hoster" @@ -42,13 +31,13 @@ class MegaRapidCz(SimpleHoster): ("Walter Purcaro", "vuolter@gmail.com")] - NAME_PATTERN = r'<h1.*?><span.*?>(?:<a.*?>)?(?P<N>[^<]+)' - SIZE_PATTERN = r'<td class="i">Velikost:</td>\s*<td class="h"><strong>\s*(?P<S>[\d.,]+) (?P<U>[\w^_]+)</strong></td>' + NAME_PATTERN = r'<h1.*?><span.*?>(?:<a.*?>)?(?P<N>.+?)' + SIZE_PATTERN = r'<td class="i">Velikost:</td>\s*<td class="h"><strong>\s*(?P<S>[\d.,]+) (?P<U>[\w^_]+)</strong></td>' OFFLINE_PATTERN = ur'Nastala chyba 404|Soubor byl smazán' CHECK_TRAFFIC = True - LINK_PREMIUM_PATTERN = r'<a href="(.+?)" title="Stahnout">([^<]+)</a>' + LINK_PREMIUM_PATTERN = r'<a href="(.+?)" title="Stahnout">(.+?)</a>' ERR_LOGIN_PATTERN = ur'<div class="error_div"><strong>Stahování je přístupné pouze přihlášeným uživatelům' ERR_CREDIT_PATTERN = ur'<div class="error_div"><strong>Stahování zdarma je možné jen přes náš' diff --git a/module/plugins/hoster/MultishareCz.py b/module/plugins/hoster/MultishareCz.py index fca6974f9..36ac8e70b 100644 --- a/module/plugins/hoster/MultishareCz.py +++ b/module/plugins/hoster/MultishareCz.py @@ -29,7 +29,7 @@ class MultishareCz(SimpleHoster): CHECK_TRAFFIC = True LEECH_HOSTER = True - INFO_PATTERN = ur'(?:<li>Název|Soubor): <strong>(?P<N>[^<]+)</strong><(?:/li><li|br)>Velikost: <strong>(?P<S>[^<]+)</strong>' + INFO_PATTERN = ur'(?:<li>Název|Soubor): <strong>(?P<N>.+?)</strong><(?:/li><li|br)>Velikost: <strong>(?P<S>.+?)</strong>' OFFLINE_PATTERN = ur'<h1>Stáhnout soubor</h1><p><strong>Požadovaný soubor neexistuje.</strong></p>' diff --git a/module/plugins/hoster/NarodRu.py b/module/plugins/hoster/NarodRu.py index 4f7c7e321..1f2bcf4b0 100644 --- a/module/plugins/hoster/NarodRu.py +++ b/module/plugins/hoster/NarodRu.py @@ -25,13 +25,13 @@ class NarodRu(SimpleHoster): __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] - NAME_PATTERN = r'<dt class="name">(?:<[^<]*>)*(?P<N>[^<]+)</dt>' - SIZE_PATTERN = r'<dd class="size">(?P<S>\d[^<]*)</dd>' + NAME_PATTERN = r'<dt class="name">(?:<.*?>)*(?P<N>.+?)</dt>' + SIZE_PATTERN = r'<dd class="size">(?P<S>\d.*?)</dd>' OFFLINE_PATTERN = r'<title>404</title>|Файл удален с сервиса|Закончился срок хранения файла\.' SIZE_REPLACEMENTS = [(u'КБ', 'KB'), (u'МБ', 'MB'), (u'ГБ', 'GB')] URL_REPLACEMENTS = [("narod.yandex.ru/", "narod.ru/"), - (r"/start/\d+\.\w+\-narod\.yandex\.ru/(\d{6,15})/\w+/(\w+)", r"/disk/\1/\2")] + (r'/start/\d+\.\w+\-narod\.yandex\.ru/(\d{6,15})/\w+/(\w+)', r'/disk/\1/\2')] CAPTCHA_PATTERN = r'<number url="(.*?)">(\w+)</number>' LINK_FREE_PATTERN = r'<a class="h-link" rel="yandex_bar" href="(.+?)">' diff --git a/module/plugins/hoster/NoPremiumPl.py b/module/plugins/hoster/NoPremiumPl.py index 7a244e745..1f18fe994 100644 --- a/module/plugins/hoster/NoPremiumPl.py +++ b/module/plugins/hoster/NoPremiumPl.py @@ -40,8 +40,8 @@ class NoPremiumPl(MultiHoster): 80: "Too many incorrect login attempts, account blocked for 24h"} - def prepare(self): - super(NoPremiumPl, self).prepare() + def _prepare(self): + super(NoPremiumPl, self)._prepare() data = self.account.get_data() diff --git a/module/plugins/hoster/OneFichierCom.py b/module/plugins/hoster/OneFichierCom.py index ab3ea8708..f26680689 100644 --- a/module/plugins/hoster/OneFichierCom.py +++ b/module/plugins/hoster/OneFichierCom.py @@ -54,7 +54,7 @@ class OneFichierCom(SimpleHoster): redirect = url for i in xrange(10): try: - headers = dict((k.lower(), v) for k,v in re.findall(r"(?P<name>.+?): (?P<value>.+?)\r?\n", get_url(redirect, just_header=True))) + headers = dict((k.lower(), v) for k,v in re.findall(r'(?P<name>.+?): (?P<value>.+?)\r?\n', get_url(redirect, just_header=True))) if 'location' in headers and headers['location']: redirect = headers['location'] else: diff --git a/module/plugins/hoster/OpenloadIo.py b/module/plugins/hoster/OpenloadIo.py index 57a7e72b1..5f57cbe8a 100644 --- a/module/plugins/hoster/OpenloadIo.py +++ b/module/plugins/hoster/OpenloadIo.py @@ -2,7 +2,7 @@ import re -from module.network.RequestFactory import getURL +from module.network.RequestFactory import getURL as get_url from module.plugins.internal.SimpleHoster import SimpleHoster from module.plugins.internal.misc import json @@ -37,7 +37,7 @@ class OpenloadIo(SimpleHoster): @classmethod def _load_json(cls, uri): - return json.loads(getURL(cls.API_URL + uri)) + return json.loads(get_url(cls.API_URL + uri)) @classmethod diff --git a/module/plugins/hoster/PornhubCom.py b/module/plugins/hoster/PornhubCom.py index e93f765ad..2ef2b965b 100644 --- a/module/plugins/hoster/PornhubCom.py +++ b/module/plugins/hoster/PornhubCom.py @@ -67,7 +67,7 @@ class PornhubCom(Hoster): if not self.data: self.download_html() - m = re.search(r'<title.+?>([^<]+) - ', self.data) + m = re.search(r'<title.+?>(.+?) - ', self.data) if m is not None: name = m.group(1) else: diff --git a/module/plugins/hoster/QuickshareCz.py b/module/plugins/hoster/QuickshareCz.py index 49a55c6b1..1041255e6 100644 --- a/module/plugins/hoster/QuickshareCz.py +++ b/module/plugins/hoster/QuickshareCz.py @@ -23,7 +23,7 @@ class QuickshareCz(SimpleHoster): __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] - NAME_PATTERN = r'<th width="145px">Název:</th>\s*<td style="word-wrap:break-word;">(?P<N>[^<]+)</td>' + NAME_PATTERN = r'<th width="145px">Název:</th>\s*<td style="word-wrap:break-word;">(?P<N>.+?)</td>' SIZE_PATTERN = r'<th>Velikost:</th>\s*<td>(?P<S>[\d.,]+) (?P<U>[\w^_]+)</td>' OFFLINE_PATTERN = r'<script type="text/javascript">location\.href=\'/chyba\';</script>' @@ -53,7 +53,7 @@ class QuickshareCz(SimpleHoster): else: self.handle_free(pyfile) - if self.scan_download({'error': re.compile(r"\AChyba!")}, read_size=100): + if self.scan_download({'error': re.compile(r'\AChyba!')}, read_size=100): self.fail(_("File not m or plugin defect")) diff --git a/module/plugins/hoster/RapideoPl.py b/module/plugins/hoster/RapideoPl.py index fc62c4b34..c77e522a8 100644 --- a/module/plugins/hoster/RapideoPl.py +++ b/module/plugins/hoster/RapideoPl.py @@ -40,8 +40,8 @@ class RapideoPl(MultiHoster): 80: "Too many incorrect login attempts, account blocked for 24h"} - def prepare(self): - super(RapideoPl, self).prepare() + def _prepare(self): + super(RapideoPl, self)._prepare() data = self.account.get_data() diff --git a/module/plugins/hoster/SecureUploadEu.py b/module/plugins/hoster/SecureUploadEu.py index 30b5ac84f..4acce2fcc 100644 --- a/module/plugins/hoster/SecureUploadEu.py +++ b/module/plugins/hoster/SecureUploadEu.py @@ -23,4 +23,4 @@ class SecureUploadEu(XFSHoster): PLUGIN_DOMAIN = "secureupload.eu" - INFO_PATTERN = r'<h3>Downloading (?P<N>[^<]+) \((?P<S>[^<]+)\)</h3>' + INFO_PATTERN = r'<h3>Downloading (?P<N>.+?) \((?P<S>.+?)\)</h3>' diff --git a/module/plugins/hoster/SendspaceCom.py b/module/plugins/hoster/SendspaceCom.py index cff63179e..07553980c 100644 --- a/module/plugins/hoster/SendspaceCom.py +++ b/module/plugins/hoster/SendspaceCom.py @@ -23,7 +23,7 @@ class SendspaceCom(SimpleHoster): __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] - NAME_PATTERN = r'<h2 class="bgray">\s*<(?:b|strong)>(?P<N>[^<]+)</' + NAME_PATTERN = r'<h2 class="bgray">\s*<(?:b|strong)>(?P<N>.+?)</' SIZE_PATTERN = r'<div class="file_description reverse margin_center">\s*<b>File Size:</b>\s*(?P<S>[\d.,]+)(?P<U>[\w^_]+)\s*</div>' OFFLINE_PATTERN = r'<div class="msg error" style="cursor: default">Sorry, the file you requested is not available.</div>' diff --git a/module/plugins/hoster/ShareonlineBiz.py b/module/plugins/hoster/ShareonlineBiz.py index b579b5e4b..2110ab086 100644 --- a/module/plugins/hoster/ShareonlineBiz.py +++ b/module/plugins/hoster/ShareonlineBiz.py @@ -104,7 +104,7 @@ class ShareonlineBiz(SimpleHoster): def check_download(self): check = self.scan_download({'cookie': re.compile(r'<div id="dl_failure"'), - 'fail' : re.compile(r"<title>Share-Online")}) + 'fail' : re.compile(r'<title>Share-Online")}) if check == "cookie": self.retry_captcha(5, 60, _("Cookie failure")) @@ -118,7 +118,7 @@ class ShareonlineBiz(SimpleHoster): def handle_premium(self, pyfile): #: Should be working better loading (account) api internally self.api_data = dlinfo = {} - html = self.load("https://api.share-online.biz/account.php", + html = self.load("https://api.share-online.biz/account.php', get={'username': self.account.user, 'password': self.account.get_login('password'), 'act' : "download", @@ -149,7 +149,7 @@ class ShareonlineBiz(SimpleHoster): def check_errors(self): - m = re.search(r"/failure/(.*?)/", self.req.lastEffectiveURL) + m = re.search(r'/failure/(.*?)/', self.req.lastEffectiveURL) if m is None: self.info.pop('error', None) return diff --git a/module/plugins/hoster/ShareplaceCom.py b/module/plugins/hoster/ShareplaceCom.py index 75cd7ecfb..db79dda87 100644 --- a/module/plugins/hoster/ShareplaceCom.py +++ b/module/plugins/hoster/ShareplaceCom.py @@ -84,7 +84,7 @@ class ShareplaceCom(Hoster): if not self.data: self.download_html() - if re.search(r"HTTP Status 404", self.data): + if re.search(r'HTTP Status 404', self.data): return False else: return True diff --git a/module/plugins/hoster/SimplyPremiumCom.py b/module/plugins/hoster/SimplyPremiumCom.py index 835aa357e..895a88eb5 100644 --- a/module/plugins/hoster/SimplyPremiumCom.py +++ b/module/plugins/hoster/SimplyPremiumCom.py @@ -65,7 +65,7 @@ class SimplyPremiumCom(MultiHoster): self.check_errors() try: - self.pyfile.name = re.search(r'<name>([^<]+)</name>', self.data).group(1) + self.pyfile.name = re.search(r'<name>(.+?)</name>', self.data).group(1) except AttributeError: self.pyfile.name = "" @@ -77,7 +77,7 @@ class SimplyPremiumCom(MultiHoster): self.pyfile.size = 0 try: - self.link = re.search(r'<download>([^<]+)</download>', self.data).group(1) + self.link = re.search(r'<download>(.+?)</download>', self.data).group(1) except AttributeError: self.link = 'http://www.simply-premium.com/premium.php?link=' + self.pyfile.url diff --git a/module/plugins/hoster/SmoozedCom.py b/module/plugins/hoster/SmoozedCom.py index c2cc1f987..3c5de1b51 100644 --- a/module/plugins/hoster/SmoozedCom.py +++ b/module/plugins/hoster/SmoozedCom.py @@ -49,7 +49,7 @@ class SmoozedCom(MultiHoster): if data['state'] != "ok": self.fail(data['message']) - if data['data'].get("state", "ok") != "ok": + if data['data'].get('state', 'ok') != "ok": if data['data'] == "Offline": self.offline() else: diff --git a/module/plugins/hoster/StreamCz.py b/module/plugins/hoster/StreamCz.py index 0921b1878..19a288b22 100644 --- a/module/plugins/hoster/StreamCz.py +++ b/module/plugins/hoster/StreamCz.py @@ -2,7 +2,6 @@ import re -from module.network.RequestFactory import getURL as get_url from module.plugins.internal.Hoster import Hoster diff --git a/module/plugins/hoster/UloziskoSk.py b/module/plugins/hoster/UloziskoSk.py index d48b73d58..5a71fdba3 100644 --- a/module/plugins/hoster/UloziskoSk.py +++ b/module/plugins/hoster/UloziskoSk.py @@ -24,7 +24,7 @@ class UloziskoSk(SimpleHoster): __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] - NAME_PATTERN = r'<div class="down1">(?P<N>[^<]+)</div>' + NAME_PATTERN = r'<div class="down1">(?P<N>.+?)</div>' SIZE_PATTERN = ur'Veľkosť súboru: <strong>(?P<S>[\d.,]+) (?P<U>[\w^_]+)</strong><br />' OFFLINE_PATTERN = ur'<span class = "red">Zadaný súbor neexistuje z jedného z nasledujúcich dôvodov:</span>' diff --git a/module/plugins/hoster/UnibytesCom.py b/module/plugins/hoster/UnibytesCom.py index 63c918da3..c9fe08c1e 100644 --- a/module/plugins/hoster/UnibytesCom.py +++ b/module/plugins/hoster/UnibytesCom.py @@ -26,7 +26,7 @@ class UnibytesCom(SimpleHoster): PLUGIN_DOMAIN = "unibytes.com" - INFO_PATTERN = r'<span[^>]*?id="fileName".*?>(?P<N>[^>]+)</span>\s*\((?P<S>\d.*?)\)' + INFO_PATTERN = r'<span[^>]*?id="fileName".*?>(?P<N>.+?)</span>\s*\((?P<S>\d.*?)\)' WAIT_PATTERN = r'Wait for <span id="slowRest">(\d+)</span> sec' LINK_FREE_PATTERN = r'<a href="(.+?)">Download</a>' @@ -42,10 +42,10 @@ class UnibytesCom(SimpleHoster): post=post_data, redirect=False) - m = re.search(r'location:\s*(\S+)', self.req.http.header, re.I) - if m is not None: - self.link = m.group(1) - break + location = self.last_header.get('location') + if location: + self.link = location + return if '>Somebody else is already downloading using your IP-address<' in self.data: self.wait(10 * 60, True) diff --git a/module/plugins/hoster/UploadableCh.py b/module/plugins/hoster/UploadableCh.py index 70ff60eda..ad38af8d9 100644 --- a/module/plugins/hoster/UploadableCh.py +++ b/module/plugins/hoster/UploadableCh.py @@ -32,7 +32,7 @@ class UploadableCh(SimpleHoster): OFFLINE_PATTERN = r'>(File not available|This file is no longer available)' TEMP_OFFLINE_PATTERN = r'<div class="icon_err">' - WAIT_PATTERN = r'>Please wait.+?<' + WAIT_PATTERN = r'>Please wait[^<]+' RECAPTCHA_KEY = "6LdlJuwSAAAAAPJbPIoUhyqOJd7-yrah5Nhim5S3" diff --git a/module/plugins/hoster/VeehdCom.py b/module/plugins/hoster/VeehdCom.py index 9999b9141..2c81c7eea 100644 --- a/module/plugins/hoster/VeehdCom.py +++ b/module/plugins/hoster/VeehdCom.py @@ -54,7 +54,7 @@ class VeehdCom(Hoster): if not self.data: self.download_html() - m = re.search(r'<title.*?>([^<]+) on Veehd</title>', self.data) + m = re.search(r'<title.*?>(.+?) on Veehd</title>', self.data) if m is None: self.error(_("Video title not found")) diff --git a/module/plugins/hoster/VidPlayNet.py b/module/plugins/hoster/VidPlayNet.py index df2f1bdab..1af71d634 100644 --- a/module/plugins/hoster/VidPlayNet.py +++ b/module/plugins/hoster/VidPlayNet.py @@ -26,4 +26,4 @@ class VidPlayNet(XFSHoster): PLUGIN_DOMAIN = "vidplay.net" - NAME_PATTERN = r'<b>Password:</b></div>\s*<h[1-6]>(?P<N>[^<]+)</h[1-6]>' + NAME_PATTERN = r'<b>Password:</b></div>\s*<h[1-6]>(?P<N>.+?)</h[1-6]>' diff --git a/module/plugins/hoster/XDCC.py b/module/plugins/hoster/XDCC.py index 8fdb704d9..405673fa4 100644 --- a/module/plugins/hoster/XDCC.py +++ b/module/plugins/hoster/XDCC.py @@ -187,7 +187,7 @@ class XDCC(Hoster): self.pyfile.name = packname - dl_folder = self.pyload.config.get("general", "download_folder") + dl_folder = self.pyload.config.get('general', 'download_folder') filename = fsjoin(dl_folder, packname) self.log_info(_("Downloading %s from %s:%d") % (packname, ip, port)) diff --git a/module/plugins/hoster/XHamsterCom.py b/module/plugins/hoster/XHamsterCom.py index d4b0c343e..a804ad2c6 100644 --- a/module/plugins/hoster/XHamsterCom.py +++ b/module/plugins/hoster/XHamsterCom.py @@ -77,7 +77,7 @@ class XHamsterCom(Hoster): self.error(_("url_mode not found")) if self.desired_fmt == ".mp4": - file_url = re.search(r"<a href=\"" + srv_url + "(.+?)\"", self.data) + file_url = re.search(r'<a href=\"" + srv_url + "(.+?)\"', self.data) if file_url is None: self.error(_("file_url not found")) @@ -127,7 +127,7 @@ class XHamsterCom(Hoster): """ if not self.data: self.download_html() - if re.search(r"(.*Video not found.*)", self.data): + if re.search(r'(.*Video not found.*)', self.data): return False else: return True diff --git a/module/plugins/hoster/XVideosCom.py b/module/plugins/hoster/XVideosCom.py index 2347c8cfc..d24bda275 100644 --- a/module/plugins/hoster/XVideosCom.py +++ b/module/plugins/hoster/XVideosCom.py @@ -23,7 +23,7 @@ class XVideosCom(Hoster): def process(self, pyfile): site = self.load(pyfile.url) pyfile.name = "%s (%s).flv" % ( - re.search(r"<h2>([^<]+)<span", site).group(1), + re.search(r'<h2>(.+?)<span', site).group(1), re.match(self.__pattern__, pyfile.url).group(1), ) - self.download(urllib.unquote(re.search(r"flv_url=([^&]+)&", site).group(1))) + self.download(urllib.unquote(re.search(r'flv_url=([^&]+)&', site).group(1))) diff --git a/module/plugins/hoster/YoupornCom.py b/module/plugins/hoster/YoupornCom.py index aa07bb2db..490027e5f 100644 --- a/module/plugins/hoster/YoupornCom.py +++ b/module/plugins/hoster/YoupornCom.py @@ -58,7 +58,7 @@ class YoupornCom(Hoster): """ if not self.data: self.download_html() - if re.search(r"(.*invalid video_id.*)", self.data): + if re.search(r'(.*invalid video_id.*)', self.data): return False else: return True diff --git a/module/plugins/hoster/YourfilesTo.py b/module/plugins/hoster/YourfilesTo.py index 719c149a7..87d6c668a 100644 --- a/module/plugins/hoster/YourfilesTo.py +++ b/module/plugins/hoster/YourfilesTo.py @@ -82,7 +82,7 @@ class YourfilesTo(Hoster): if not self.data: self.download_html() - if re.search(r"HTTP Status 404", self.data): + if re.search(r'HTTP Status 404', self.data): return False else: return True diff --git a/module/plugins/hoster/YoutubeCom.py b/module/plugins/hoster/YoutubeCom.py index 81638e1ea..3f625492f 100644 --- a/module/plugins/hoster/YoutubeCom.py +++ b/module/plugins/hoster/YoutubeCom.py @@ -147,7 +147,7 @@ class YoutubeCom(Hoster): pyfile.name = html_unescape(name) - time = re.search(r"t=((\d+)m)?(\d+)s", pyfile.url) + time = re.search(r't=((\d+)m)?(\d+)s', pyfile.url) ffmpeg = which("ffmpeg") if ffmpeg and time: m, s = time.groups()[1:] diff --git a/module/plugins/hoster/ZDF.py b/module/plugins/hoster/ZDF.py index cfc374f6d..0b51d9efa 100644 --- a/module/plugins/hoster/ZDF.py +++ b/module/plugins/hoster/ZDF.py @@ -39,7 +39,7 @@ class ZDF(Hoster): @staticmethod def get_id(url): - return int(re.search(r"\D*(\d{4,})\D*", url).group(1)) + return int(re.search(r'\D*(\d{4,})\D*', url).group(1)) def process(self, pyfile): diff --git a/module/plugins/internal/Hoster.py b/module/plugins/internal/Hoster.py index fbb675281..bd8daded8 100644 --- a/module/plugins/internal/Hoster.py +++ b/module/plugins/internal/Hoster.py @@ -139,14 +139,14 @@ class Hoster(Base): self.pyload.hookManager.dispatchEvent("download_processed", self.pyfile) try: - unfinished = any(fdata['status'] == 3 for fid, fdata in pypack.getChildren().items() - if fid != self.pyfile.id) + unfinished = any(fdata.get('status') == 3 for fid, fdata in pypack.getChildren().items() + if fid is not self.pyfile.id) if unfinished: return self.pyload.hookManager.dispatchEvent("package_processed", pypack) - failed = any(fdata['status'] in (1, 6, 8, 9, 14) + failed = any(fdata.get('status') in (1, 6, 8, 9, 14) for fid, fdata in pypack.getChildren().items()) if not failed: @@ -171,11 +171,9 @@ class Hoster(Base): elif redirect: maxredirs = int(self.pyload.api.getConfigValue("UserAgentSwitcher", "maxredirs", "plugin")) or maxredirs #@TODO: Remove `int` in 0.4.10 - for i in xrange(maxredirs): - self.log_debug("Redirect #%d to: %s" % (i, url)) - - header = self.load(url, just_header=True) + header = self.load(url, just_header=True) + for i in xrange(1, maxredirs): if not redirect or header.get('connection') == "close": resumable = False @@ -190,11 +188,12 @@ class Hoster(Base): resource = location elif code == 301 or resumable: + self.log_debug("Redirect #%d to: %s" % (i, location)) + header = self.load(location, just_header=True) url = location continue else: - mimetype = "" contenttype = header.get('content-type') extension = os.path.splitext(parse_name(url))[-1] @@ -205,6 +204,9 @@ class Hoster(Base): mimetype = mimetypes.guess_type(extension, False)[0] or \ "application/octet-stream" + else: + mimetype = None + if mimetype and (resource or 'html' not in mimetype): resource = url else: @@ -217,7 +219,7 @@ class Hoster(Base): file = encode(filename) #@TODO: Safe-filename check in HTTPDownload in 0.4.10 resume = self.resume_download if resume is None else bool(resume) - dl_chunks = self.pyload.config.get("download", "chunks") + dl_chunks = self.pyload.config.get('download', 'chunks') chunk_limit = chunks or self.chunk_limit or -1 if -1 in (dl_chunks, chunk_limit): @@ -277,7 +279,7 @@ class Hoster(Base): self.pyfile.setStatus("downloading") - dl_folder = self.pyload.config.get("general", "download_folder") + dl_folder = self.pyload.config.get('general', 'download_folder') dl_dirname = safejoin(dl_folder, self.pyfile.package().folder) dl_filename = safejoin(dl_dirname, dl_basename) @@ -479,8 +481,8 @@ class Hoster(Base): :raises Skip: """ - pack_folder = self.pyfile.package().folder if self.pyload.config.get("general", "folder_per_package") else "" - dl_folder = self.pyload.config.get("general", "download_folder") + pack_folder = self.pyfile.package().folder if self.pyload.config.get('general', 'folder_per_package') else "" + dl_folder = self.pyload.config.get('general', 'download_folder') dl_file = fsjoin(dl_folder, pack_folder, self.pyfile.name) if not exists(dl_file): @@ -491,7 +493,7 @@ class Hoster(Base): self.last_download = "" return - if self.pyload.config.get("download", "skip_existing"): + if self.pyload.config.get('download', 'skip_existing'): plugin = self.pyload.db.findDuplicates(self.pyfile.id, pack_folder, self.pyfile.name) msg = plugin[0] if plugin else _("File exists") self.skip(msg) diff --git a/module/plugins/internal/MultiCrypter.py b/module/plugins/internal/MultiCrypter.py index c924ee916..7bca45c61 100644 --- a/module/plugins/internal/MultiCrypter.py +++ b/module/plugins/internal/MultiCrypter.py @@ -20,7 +20,7 @@ class MultiCrypter(SimpleCrypter): def init(self): - self.PLUGIN_NAME = self.pyload.pluginManager.crypterPlugins[self.classname]['name'] + self.PLUGIN_NAME = self.pyload.pluginManager.crypterPlugins.get(self.classname)['name'] def _log(self, level, plugintype, pluginname, messages): diff --git a/module/plugins/internal/MultiHoster.py b/module/plugins/internal/MultiHoster.py index a38230b9d..0adbf8d90 100644 --- a/module/plugins/internal/MultiHoster.py +++ b/module/plugins/internal/MultiHoster.py @@ -32,7 +32,7 @@ class MultiHoster(SimpleHoster): def init(self): - self.PLUGIN_NAME = self.pyload.pluginManager.hosterPlugins[self.classname]['name'] + self.PLUGIN_NAME = self.pyload.pluginManager.hosterPlugins.get(self.classname)['name'] def _log(self, level, plugintype, pluginname, messages): @@ -54,8 +54,8 @@ class MultiHoster(SimpleHoster): super(MultiHoster, self).setup_base() - def prepare(self): - super(MultiHoster, self).prepare() + def _prepare(self): + super(MultiHoster, self)._prepare() if self.DIRECT_LINK is None: self.direct_dl = self.__pattern__ != r'^unmatchable$' and re.match(self.__pattern__, self.pyfile.url) @@ -68,9 +68,9 @@ class MultiHoster(SimpleHoster): super(MultiHoster, self)._process(thread) except Fail, e: - if self.config.get("revertfailed", True) and \ - self.pyload.pluginManager.hosterPlugins[self.classname].get('new_module'): - hdict = self.pyload.pluginManager.hosterPlugins[self.classname] + if self.config.get('revertfailed', True) and \ + self.pyload.pluginManager.hosterPlugins.get(self.classname).get('new_module'): + hdict = self.pyload.pluginManager.hosterPlugins.get(self.classname) tmp_module = hdict['new_module'] tmp_name = hdict['new_name'] @@ -85,7 +85,7 @@ class MultiHoster(SimpleHoster): self.restart(_("Revert to original hoster plugin")) else: - raise Fail(encode(e)) + raise Fail(e) def handle_premium(self, pyfile): diff --git a/module/plugins/internal/Notifier.py b/module/plugins/internal/Notifier.py index e9f1fab74..8c79cf7fa 100644 --- a/module/plugins/internal/Notifier.py +++ b/module/plugins/internal/Notifier.py @@ -136,13 +136,13 @@ class Notifier(Addon): elapsed_time = time.time() - self.last_notify - if elapsed_time < self.config.get("sendinterval", 1): + if elapsed_time < self.config.get('sendinterval', 1): return elif elapsed_time > 60: self.notifications = 0 - elif self.notifications >= self.config.get("sendpermin", 60): + elif self.notifications >= self.config.get('sendpermin', 60): return self.log_debug("Sending notification...") diff --git a/module/plugins/internal/OCR.py b/module/plugins/internal/OCR.py index 274f14d8b..0ffcbb4ec 100644 --- a/module/plugins/internal/OCR.py +++ b/module/plugins/internal/OCR.py @@ -60,7 +60,7 @@ class OCR(Plugin): """ Run a command """ - call = [command] + args + call = (command,) + args self.log_debug("EXECUTE " + " ".join(call)) call = map(encode, call) diff --git a/module/plugins/internal/Plugin.py b/module/plugins/internal/Plugin.py index bbb4e33b8..a8ef9b4f2 100644 --- a/module/plugins/internal/Plugin.py +++ b/module/plugins/internal/Plugin.py @@ -249,12 +249,7 @@ class Plugin(object): os.makedirs(os.path.join("tmp", self.classname)) with open(framefile, "wb") as f: - try: - html = encode(self.last_html) - except Exception: - html = self.last_html - - f.write(html) + f.write(encode(self.last_html)) except IOError, e: self.log_error(e) diff --git a/module/plugins/internal/SevenZip.py b/module/plugins/internal/SevenZip.py index 2ae3c197c..5ad1156fe 100644 --- a/module/plugins/internal/SevenZip.py +++ b/module/plugins/internal/SevenZip.py @@ -123,8 +123,10 @@ class SevenZip(UnRar): args.append("-y") #: Set a password - if kwargs.get('password'): - args.append("-p%s" % kwargs['password']) + password = kwargs.get('password') + + if password: + args.append("-p%s" % password) else: args.append("-p-") diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 98f040bad..5feb96aec 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -96,7 +96,7 @@ class SimpleHoster(Hoster): CHECK_TRAFFIC = False #: Set to True to reload checking traffic left for premium account COOKIES = True #: or False or list of tuples [(domain, name, value)] DIRECT_LINK = True #: Set to True to looking for direct link (as defined in handle_direct method), set to None to do it if self.account is True else False - DISPOSITION = True #: Set to True to use any content-disposition value in http header as file name + DISPOSITION = True #: Set to True to use any content-disposition value found in http header as file name LOGIN_ACCOUNT = False #: Set to True to require account login LOGIN_PREMIUM = False #: Set to True to require premium account login LEECH_HOSTER = False #: Set to True to leech other hoster link (as defined in handle_multi method) @@ -199,7 +199,7 @@ class SimpleHoster(Hoster): self.resume_download = self.premium - def prepare(self): + def _prepare(self): self.link = "" self.direct_dl = False self.leech_dl = False @@ -220,7 +220,7 @@ class SimpleHoster(Hoster): self.LINK_PREMIUM_PATTERN = self.LINK_PATTERN if self.LEECH_HOSTER: - pattern = self.pyload.pluginManager.hosterPlugins[self.classname]['pattern'] + pattern = self.pyload.pluginManager.hosterPlugins.get(self.classname)['pattern'] if self.__pattern__ is not pattern and re.match(self.__pattern__, self.pyfile.url) is None: self.leech_dl = True @@ -228,7 +228,7 @@ class SimpleHoster(Hoster): self.direct_dl = False elif self.DIRECT_LINK is None: - self.direct_dl = bool(self.account) + self.direct_dl = bool(self.premium) else: self.direct_dl = self.DIRECT_LINK @@ -237,7 +237,7 @@ class SimpleHoster(Hoster): self.pyfile.url = replace_patterns(self.pyfile.url, self.URL_REPLACEMENTS) - def preload(self): + def _preload(self): if self.data: return @@ -248,7 +248,7 @@ class SimpleHoster(Hoster): def process(self, pyfile): - self.prepare() + self._prepare() #@TODO: Remove `handle_multi`, use MultiHoster instead if self.leech_dl: @@ -266,7 +266,7 @@ class SimpleHoster(Hoster): self.log_info(_("Direct download link not found")) if not self.link: - self.preload() + self._preload() self.check_errors() if self.info.get('status', 3) != 2: @@ -352,7 +352,7 @@ class SimpleHoster(Hoster): self.log_warning(errmsg) wait_time = parse_time(errmsg) - self.wait(wait_time, reconnect=wait_time > self.config.get("max_wait", 10) * 60) + self.wait(wait_time, reconnect=wait_time > self.config.get('max_wait', 10) * 60) self.restart(_("Download limit exceeded")) if self.HAPPY_HOUR_PATTERN and re.search(self.HAPPY_HOUR_PATTERN, self.data): @@ -381,7 +381,7 @@ class SimpleHoster(Hoster): elif re.search(r'limit|wait|slot', errmsg, re.I): wait_time = parse_time(errmsg) - self.wait(wait_time, reconnect=wait_time > self.config.get("max_wait", 10) * 60) + self.wait(wait_time, reconnect=wait_time > self.config.get('max_wait', 10) * 60) self.restart(_("Download limit exceeded")) elif re.search(r'country|ip|region|nation', errmsg, re.I): @@ -423,7 +423,7 @@ class SimpleHoster(Hoster): waitmsg = m.group(0).strip() wait_time = parse_time(waitmsg) - self.wait(wait_time, reconnect=wait_time > self.config.get("max_wait", 10) * 60) + self.wait(wait_time, reconnect=wait_time > self.config.get('max_wait', 10) * 60) self.log_info(_("No errors found")) self.info.pop('error', None) @@ -437,7 +437,7 @@ class SimpleHoster(Hoster): def handle_direct(self, pyfile): - self.link = pyfile.url if self.isresource(pyfile.url) else None + self.link = self.isresource(pyfile.url) def handle_multi(self, pyfile): #: Multi-hoster handler diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py index d1f180546..07f3b0f23 100644 --- a/module/plugins/internal/UnRar.py +++ b/module/plugins/internal/UnRar.py @@ -212,8 +212,10 @@ class UnRar(Extractor): args.append("-y") #: Set a password - if kwargs.get('password'): - args.append("-p%s" % kwargs['password']) + password = kwargs.get('password') + + if password: + args.append("-p%s" % password) else: args.append("-p-") diff --git a/module/plugins/internal/XFSAccount.py b/module/plugins/internal/XFSAccount.py index f5aa37c81..6866f8b19 100644 --- a/module/plugins/internal/XFSAccount.py +++ b/module/plugins/internal/XFSAccount.py @@ -69,8 +69,9 @@ class XFSAccount(MultiAccount): self._set_xfs_cookie() - def grab_hosters(self, user, password, data): - pass + #@TODO: Implement default grab_hosters routine + # def grab_hosters(self, user, password, data): + # pass def grab_info(self, user, password, data): diff --git a/module/plugins/internal/XFSCrypter.py b/module/plugins/internal/XFSCrypter.py index d80276cfb..5754be1d8 100644 --- a/module/plugins/internal/XFSCrypter.py +++ b/module/plugins/internal/XFSCrypter.py @@ -40,11 +40,11 @@ class XFSCrypter(SimpleCrypter): set_cookie(self.req.cj, *cookie) - def prepare(self): + def _prepare(self): if not self.PLUGIN_DOMAIN: self.fail(_("Missing PLUGIN DOMAIN")) if self.COOKIES: self._set_xfs_cookie() - super(XFSCrypter, self).prepare() + super(XFSCrypter, self)._prepare() diff --git a/module/plugins/internal/XFSHoster.py b/module/plugins/internal/XFSHoster.py index dabf1457a..81347e1ac 100644 --- a/module/plugins/internal/XFSHoster.py +++ b/module/plugins/internal/XFSHoster.py @@ -46,7 +46,7 @@ class XFSHoster(SimpleHoster): HAPPY_HOUR_PATTERN = r'>[Hh]appy hour' ERROR_PATTERN = r'(?:class=["\']err["\'].*?>|<[Cc]enter><b>|>Error</td>|>\(ERROR:)(?:\s*<.+?>\s*)*(.+?)(?:["\']|<|\))' - LINK_LEECH_PATTERN = r'<h2>Download Link</h2>\s*<textarea[^>]*>([^<]+)' + LINK_LEECH_PATTERN = r'<h2>Download Link</h2>\s*<textarea.*?>(.+?)' CAPTCHA_PATTERN = r'(https?://[^"\']+?/captchas?/[^"\']+)' CAPTCHA_BLOCK_PATTERN = r'>Enter code.*?<div.*?>(.+?)</div>' @@ -71,7 +71,7 @@ class XFSHoster(SimpleHoster): set_cookie(self.req.cj, *cookie) - def prepare(self): + def _prepare(self): if not self.PLUGIN_DOMAIN: self.fail(_("Missing PLUGIN DOMAIN")) @@ -82,7 +82,7 @@ class XFSHoster(SimpleHoster): pattern = r'(?:file: "(.+?)"|(https?://(?:www\.)?([^/]*?%s|\d+\.\d+\.\d+\.\d+)(\:\d+)?(/d/|(/files)?/\d+/\w+/).+?)["\'<])' self.LINK_PATTERN = pattern % self.PLUGIN_DOMAIN.replace('.', '\.') - super(XFSHoster, self).prepare() + super(XFSHoster, self)._prepare() if self.DIRECT_LINK is None: self.direct_dl = self.premium @@ -98,12 +98,11 @@ class XFSHoster(SimpleHoster): if m is not None: break - data = self._post_parameters() + self.data = self.load(pyfile.url, + post=self._post_parameters(), + redirect=False) - self.data = self.load(pyfile.url, post=data, redirect=False) - - m = re.search(r'Location\s*:\s*(.+)', self.req.http.header, re.I) - if m and not "op=" in m.group(1): + if not "op=" in self.last_header.get('location', "op="): break m = re.search(self.LINK_PATTERN, self.data, re.S) @@ -169,10 +168,7 @@ class XFSHoster(SimpleHoster): if m is None: self.error(_("LINK_LEECH_PATTERN not found")) - header = self.load(m.group(1), just_header=True) - - if 'location' in header: #: Direct download link - self.link = header.get('location') + self.link = self.load(m.group(1), just_header=True).get('location') def _post_parameters(self): |