From 2edeee0532ec6d6b4b26fd045a5971f67ca455da Mon Sep 17 00:00:00 2001 From: Stefano Date: Mon, 22 Jul 2013 20:50:34 +0200 Subject: Fixed PEP 8 violations in Hosters --- module/plugins/hoster/ARD.py | 9 +- module/plugins/hoster/BasePlugin.py | 40 +++--- module/plugins/hoster/BayfilesCom.py | 48 ++++--- module/plugins/hoster/BezvadataCz.py | 16 ++- module/plugins/hoster/BillionuploadsCom.py | 2 + module/plugins/hoster/BitshareCom.py | 38 +++--- module/plugins/hoster/BoltsharingCom.py | 2 + module/plugins/hoster/CatShareNet.py | 1 + module/plugins/hoster/ChipDe.py | 31 ++--- module/plugins/hoster/CloudzerNet.py | 3 +- module/plugins/hoster/CramitIn.py | 12 +- module/plugins/hoster/CrockoCom.py | 41 +++--- module/plugins/hoster/CyberlockerCh.py | 2 + module/plugins/hoster/CzshareCom.py | 35 ++--- module/plugins/hoster/DailymotionCom.py | 10 +- module/plugins/hoster/DataportCz.py | 28 ++-- module/plugins/hoster/DateiTo.py | 53 ++++---- module/plugins/hoster/DepositfilesCom.py | 49 ++++--- module/plugins/hoster/DlFreeFr.py | 114 +++++++++------- module/plugins/hoster/EdiskCz.py | 7 +- module/plugins/hoster/EuroshareEu.py | 7 +- module/plugins/hoster/FastshareCz.py | 20 +-- module/plugins/hoster/FileApeCom.py | 29 +++-- module/plugins/hoster/FilecloudIo.py | 45 +++---- module/plugins/hoster/FilejungleCom.py | 14 +- module/plugins/hoster/FilepostCom.py | 91 +++++++------ module/plugins/hoster/FilerioCom.py | 14 +- module/plugins/hoster/FilesMailRu.py | 34 ++--- module/plugins/hoster/FileserveCom.py | 125 +++++++++--------- module/plugins/hoster/FileshareInUa.py | 35 ++--- module/plugins/hoster/FilezyNet.py | 4 +- module/plugins/hoster/FlyFilesNet.py | 8 +- module/plugins/hoster/FourSharedCom.py | 22 ++-- module/plugins/hoster/FreakshareCom.py | 61 ++++----- module/plugins/hoster/FreevideoCz.py | 2 + module/plugins/hoster/FshareVn.py | 32 +++-- module/plugins/hoster/Ftp.py | 55 ++++---- module/plugins/hoster/GamefrontCom.py | 39 +++--- module/plugins/hoster/GigapetaCom.py | 41 +++--- module/plugins/hoster/HellshareCz.py | 10 +- module/plugins/hoster/HellspyCz.py | 17 ++- module/plugins/hoster/HotfileCom.py | 65 +++++----- module/plugins/hoster/IcyFilesCom.py | 18 +-- module/plugins/hoster/IfileIt.py | 21 +-- module/plugins/hoster/IfolderRu.py | 18 ++- module/plugins/hoster/JumbofilesCom.py | 11 +- module/plugins/hoster/LetitbitNet.py | 36 ++--- module/plugins/hoster/MegaNz.py | 8 +- module/plugins/hoster/MegacrypterCom.py | 12 +- module/plugins/hoster/MegasharesCom.py | 36 ++--- module/plugins/hoster/MovReelCom.py | 202 +++++++++++++++-------------- module/plugins/hoster/MultishareCz.py | 52 ++++---- module/plugins/hoster/MyvideoDe.py | 5 +- module/plugins/hoster/NarodRu.py | 22 ++-- module/plugins/hoster/NetloadIn.py | 58 ++++----- module/plugins/hoster/NovafileCom.py | 14 +- module/plugins/hoster/NowDownloadEu.py | 16 ++- module/plugins/hoster/OneFichierCom.py | 41 +++--- module/plugins/hoster/PornhostCom.py | 27 ++-- module/plugins/hoster/PornhubCom.py | 23 ++-- module/plugins/hoster/PremiumizeMe.py | 31 +++-- module/plugins/hoster/QuickshareCz.py | 42 +++--- module/plugins/hoster/RapidshareCom.py | 100 +++++++------- module/plugins/hoster/RarefileNet.py | 3 +- module/plugins/hoster/RealdebridCom.py | 20 +-- module/plugins/hoster/RedtubeCom.py | 16 +-- module/plugins/hoster/RehostTo.py | 3 +- module/plugins/hoster/ReloadCc.py | 28 ++-- module/plugins/hoster/RyushareCom.py | 10 +- module/plugins/hoster/SecureUploadEu.py | 1 + module/plugins/hoster/SendmywayCom.py | 1 + module/plugins/hoster/SendspaceCom.py | 19 +-- module/plugins/hoster/Share4webCom.py | 6 +- module/plugins/hoster/Share76Com.py | 2 + module/plugins/hoster/ShareFilesCo.py | 8 +- module/plugins/hoster/ShareRapidCom.py | 44 ++++--- module/plugins/hoster/SharebeesCom.py | 1 + module/plugins/hoster/ShareonlineBiz.py | 122 ++++++++--------- module/plugins/hoster/ShareplaceCom.py | 26 ++-- module/plugins/hoster/ShragleCom.py | 55 ++++---- module/plugins/hoster/SpeedLoadOrg.py | 4 +- module/plugins/hoster/SpeedfileCz.py | 6 +- module/plugins/hoster/StreamCz.py | 36 ++--- module/plugins/hoster/StreamcloudEu.py | 27 ++-- module/plugins/hoster/TurbobitNet.py | 60 +++++---- module/plugins/hoster/TurbouploadCom.py | 15 ++- module/plugins/hoster/TusfilesNet.py | 2 + module/plugins/hoster/TwoSharedCom.py | 15 ++- module/plugins/hoster/UlozTo.py | 56 ++++---- module/plugins/hoster/UloziskoSk.py | 13 +- module/plugins/hoster/UnibytesCom.py | 38 +++--- module/plugins/hoster/UploadStationCom.py | 14 +- module/plugins/hoster/UploadedTo.py | 9 +- module/plugins/hoster/UploadheroCom.py | 37 +++--- module/plugins/hoster/UploadingCom.py | 47 +++---- module/plugins/hoster/UptoboxCom.py | 10 +- module/plugins/hoster/VeehdCom.py | 32 ++--- module/plugins/hoster/WarserverCz.py | 41 +++--- module/plugins/hoster/WebshareCz.py | 15 ++- module/plugins/hoster/WrzucTo.py | 38 +++--- module/plugins/hoster/X7To.py | 7 +- module/plugins/hoster/XFileSharingPro.py | 56 ++++---- module/plugins/hoster/XHamsterCom.py | 39 +++--- module/plugins/hoster/XVideosCom.py | 4 +- module/plugins/hoster/Xdcc.py | 121 +++++++++-------- module/plugins/hoster/YibaishiwuCom.py | 22 ++-- module/plugins/hoster/YoupornCom.py | 11 +- module/plugins/hoster/YourfilesTo.py | 22 ++-- module/plugins/hoster/YoutubeCom.py | 55 ++++---- module/plugins/hoster/ZDF.py | 9 +- module/plugins/hoster/ZeveraCom.py | 160 +++++++++++------------ module/plugins/hoster/ZippyshareCom.py | 111 ++++++++-------- 112 files changed, 1946 insertions(+), 1655 deletions(-) diff --git a/module/plugins/hoster/ARD.py b/module/plugins/hoster/ARD.py index cda783091..4404994b3 100644 --- a/module/plugins/hoster/ARD.py +++ b/module/plugins/hoster/ARD.py @@ -1,4 +1,3 @@ - import subprocess import re import os.path @@ -10,6 +9,7 @@ from module.plugins.Hoster import Hoster # Requires rtmpdump # by Roland Beermann + class RTMP: # TODO: Port to some RTMP-library like rtmpy or similar # TODO?: Integrate properly into the API of pyLoad @@ -37,6 +37,7 @@ class RTMP: return subprocess.check_call(args) + class ARD(Hoster): __name__ = "ARD Mediathek" __version__ = "0.11" @@ -46,8 +47,10 @@ class ARD(Hoster): def process(self, pyfile): site = self.load(pyfile.url) - avail_videos = re.findall(r"""mediaCollection.addMediaStream\(0, ([0-9]*), "([^\"]*)", "([^\"]*)", "[^\"]*"\);""", site) - avail_videos.sort(key=lambda videodesc: int(videodesc[0]), reverse=True) # The higher the number, the better the quality + avail_videos = re.findall( + r'mediaCollection.addMediaStream\(0, ([0-9]*), "([^\"]*)", "([^\"]*)", "[^\"]*"\);', site) + avail_videos.sort(key=lambda videodesc: int(videodesc[0]), + reverse=True) # The higher the number, the better the quality quality, url, playpath = avail_videos[0] diff --git a/module/plugins/hoster/BasePlugin.py b/module/plugins/hoster/BasePlugin.py index f8d494e39..332921dc4 100644 --- a/module/plugins/hoster/BasePlugin.py +++ b/module/plugins/hoster/BasePlugin.py @@ -8,11 +8,12 @@ from module.network.HTTPRequest import BadHeader from module.plugins.Hoster import Hoster from module.utils import html_unescape, remove_chars + class BasePlugin(Hoster): __name__ = "BasePlugin" __type__ = "hoster" __pattern__ = r"^unmatchable$" - __version__ = "0.17" + __version__ = "0.18" __description__ = """Base Plugin when any other didnt fit""" __author_name__ = ("RaNaN") __author_mail__ = ("RaNaN@pyload.org") @@ -29,17 +30,17 @@ class BasePlugin(Hoster): self.multiDL = False return -# self.__name__ = "NetloadIn" -# pyfile.name = "test" -# self.html = self.load("http://localhost:9000/short") -# self.download("http://localhost:9000/short") -# self.api = self.load("http://localhost:9000/short") -# self.decryptCaptcha("http://localhost:9000/captcha") -# -# if pyfile.url == "79": -# self.core.api.addPackage("test", [str(i) for i in range(80)], 1) -# -# return + # self.__name__ = "NetloadIn" + # pyfile.name = "test" + # self.html = self.load("http://localhost:9000/short") + # self.download("http://localhost:9000/short") + # self.api = self.load("http://localhost:9000/short") + # self.decryptCaptcha("http://localhost:9000/captcha") + # + # if pyfile.url == "79": + # self.core.api.addPackage("test", [str(i) for i in range(80)], 1) + # + # return if pyfile.url.startswith("http"): try: @@ -49,7 +50,7 @@ class BasePlugin(Hoster): self.logDebug("Auth required") account = self.core.accountManager.getAccountPlugin('Http') - servers = [ x['login'] for x in account.getAllAccounts() ] + servers = [x['login'] for x in account.getAllAccounts()] server = urlparse(pyfile.url).netloc if server in servers: @@ -70,15 +71,14 @@ class BasePlugin(Hoster): else: self.fail("No Plugin matched and not a downloadable url.") - def downloadFile(self, pyfile): url = pyfile.url for i in range(5): - header = self.load(url, just_header = True) + header = self.load(url, just_header=True) # self.load does not raise a BadHeader on 404 responses, do it here - if header.has_key('code') and header['code'] == 404: + if 'code' in header and header['code'] == 404: raise BadHeader(404) if 'location' in header: @@ -95,11 +95,13 @@ class BasePlugin(Hoster): if m: disp = m.groupdict() self.logDebug(disp) - if not disp['enc']: disp['enc'] = 'utf-8' + if not disp['enc']: + disp['enc'] = 'utf-8' name = remove_chars(disp['name'], "\"';").strip() name = unicode(unquote(name), disp['enc']) - if not name: name = url + if not name: + name = url pyfile.name = name self.logDebug("Filename: %s" % pyfile.name) - self.download(url, disposition=True) \ No newline at end of file + self.download(url, disposition=True) diff --git a/module/plugins/hoster/BayfilesCom.py b/module/plugins/hoster/BayfilesCom.py index 8473468ba..bb1e78bb3 100644 --- a/module/plugins/hoster/BayfilesCom.py +++ b/module/plugins/hoster/BayfilesCom.py @@ -17,9 +17,11 @@ """ import re +from time import time + from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo from module.common.json_layer import json_loads -from time import time + class BayfilesCom(SimpleHoster): __name__ = "BayfilesCom" @@ -32,50 +34,53 @@ class BayfilesCom(SimpleHoster): FILE_INFO_PATTERN = r'

[^<]*(?P[0-9., ]+)(?P[kKMG])i?B

' FILE_OFFLINE_PATTERN = r'(

The requested file could not be found.

|404 Not Found)' - + WAIT_PATTERN = r'>Your IP [0-9.]* has recently downloaded a file\. Upgrade to premium or wait (\d+) minutes\.<' VARS_PATTERN = r'var vfid = (\d+);\s*var delay = (\d+);' LINK_PATTERN = r"javascript:window.location.href = '([^']+)';" PREMIUM_LINK_PATTERN = r'(?:BayFiles"), "notfound": re.compile(r"404 Not Found") - }) + }) if check == "waitforfreeslots": self.retry(60, 300, "Wait for free slot") elif check == "notfound": self.retry(60, 300, "404 Not found") - + + getInfo = create_getInfo(BayfilesCom) diff --git a/module/plugins/hoster/BezvadataCz.py b/module/plugins/hoster/BezvadataCz.py index cb9bae07c..d923a0633 100644 --- a/module/plugins/hoster/BezvadataCz.py +++ b/module/plugins/hoster/BezvadataCz.py @@ -19,6 +19,7 @@ import re from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo + class BezvadataCz(SimpleHoster): __name__ = "BezvadataCz" __type__ = "hoster" @@ -38,7 +39,8 @@ class BezvadataCz(SimpleHoster): def handleFree(self): #download button found = re.search(r'', self.html) - if not found: self.parseError("page2 URL") + if not found: + self.parseError("page2 URL") url = "http://bezvadata.cz%s" % found.group(1) self.logDebug("DL URL %s" % url) @@ -84,11 +89,12 @@ class BezvadataCz(SimpleHoster): def checkErrors(self): if 'images/button-download-disable.png' in self.html: - self.longWait(300, 24) #parallel dl limit + self.longWait(300, 24) # parallel dl limit elif '
Size:(?P.*?)
' HOSTER_NAME = "billionuploads.com" + getInfo = create_getInfo(BillionuploadsCom) diff --git a/module/plugins/hoster/BitshareCom.py b/module/plugins/hoster/BitshareCom.py index 5e117ff45..82c2fe9cb 100644 --- a/module/plugins/hoster/BitshareCom.py +++ b/module/plugins/hoster/BitshareCom.py @@ -15,9 +15,9 @@ class BitshareCom(SimpleHoster): __description__ = """Bitshare.Com File Download Hoster""" __author_name__ = ("paulking", "fragonib") __author_mail__ = (None, "fragonib[AT]yahoo[DOT]es") - + HOSTER_DOMAIN = "bitshare.com" - FILE_OFFLINE_PATTERN = r'''(>We are sorry, but the requested file was not found in our database|>Error - File not available<|The file was deleted either by the uploader, inactivity or due to copyright claim)''' + FILE_OFFLINE_PATTERN = r'(>We are sorry, but the requested file was not found in our database|>Error - File not available<|The file was deleted either by the uploader, inactivity or due to copyright claim)' FILE_NAME_PATTERN = r'Download:\s*[\d.]+) (?P\w+)' FILE_AJAXID_PATTERN = r'var ajaxdl = "(.*?)";' @@ -31,12 +31,12 @@ class BitshareCom(SimpleHoster): def process(self, pyfile): if self.premium: self.account.relogin(self.user) - + self.pyfile = pyfile - + # File id m = re.match(self.__pattern__, self.pyfile.url) - self.file_id = max(m.group('id1'), m.group('id2')) + self.file_id = max(m.group('id1'), m.group('id2')) self.logDebug("File id is [%s]" % self.file_id) # Load main page @@ -66,24 +66,23 @@ class BitshareCom(SimpleHoster): # Ajax file id self.ajaxid = re.search(BitshareCom.FILE_AJAXID_PATTERN, self.html).group(1) self.logDebug("File ajax id is [%s]" % self.ajaxid) - + # This may either download our file or forward us to an error page - url = self.getDownloadUrl() + url = self.getDownloadUrl() self.logDebug("Downloading file with url [%s]" % url) self.download(url) - def getDownloadUrl(self): # Return location if direct download is active if self.premium: - header = self.load(self.pyfile.url, cookies = True, just_header = True) + header = self.load(self.pyfile.url, cookies=True, just_header=True) if 'location' in header: - return header['location'] - + return header['location'] + # Get download info self.logDebug("Getting download info") response = self.load("http://bitshare.com/files-ajax/" + self.file_id + "/request.html", - post={"request" : "generateID", "ajaxid" : self.ajaxid}) + post={"request": "generateID", "ajaxid": self.ajaxid}) self.handleErrors(response, ':') parts = response.split(":") filetype = parts[0] @@ -108,24 +107,24 @@ class BitshareCom(SimpleHoster): id = re.search(BitshareCom.CAPTCHA_KEY_PATTERN, self.html).group(1) # Try up to 3 times for i in range(3): - self.logDebug("Resolving ReCaptcha with key [%s], round %d" % (id, i+1)) + self.logDebug("Resolving ReCaptcha with key [%s], round %d" % (id, i + 1)) recaptcha = ReCaptcha(self) challenge, code = recaptcha.challenge(id) response = self.load("http://bitshare.com/files-ajax/" + self.file_id + "/request.html", - post={"request" : "validateCaptcha", "ajaxid" : self.ajaxid, "recaptcha_challenge_field" : challenge, "recaptcha_response_field" : code}) + post={"request": "validateCaptcha", "ajaxid": self.ajaxid, + "recaptcha_challenge_field": challenge, "recaptcha_response_field": code}) if self.handleCaptchaErrors(response): break - # Get download URL self.logDebug("Getting download url") response = self.load("http://bitshare.com/files-ajax/" + self.file_id + "/request.html", - post={"request" : "getDownloadURL", "ajaxid" : self.ajaxid}) + post={"request": "getDownloadURL", "ajaxid": self.ajaxid}) self.handleErrors(response, '#') - url = response.split("#")[-1] - + url = response.split("#")[-1] + return url - + def handleErrors(self, response, separator): self.logDebug("Checking response [%s]" % response) if "ERROR:Session timed out" in response: @@ -144,4 +143,5 @@ class BitshareCom(SimpleHoster): self.logDebug("Wrong captcha") self.invalidCaptcha() + getInfo = create_getInfo(BitshareCom) diff --git a/module/plugins/hoster/BoltsharingCom.py b/module/plugins/hoster/BoltsharingCom.py index 2f42c8b23..f9cc91ca5 100644 --- a/module/plugins/hoster/BoltsharingCom.py +++ b/module/plugins/hoster/BoltsharingCom.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo + class BoltsharingCom(XFileSharingPro): __name__ = "BoltsharingCom" __type__ = "hoster" @@ -12,4 +13,5 @@ class BoltsharingCom(XFileSharingPro): HOSTER_NAME = "boltsharing.com" + getInfo = create_getInfo(BoltsharingCom) diff --git a/module/plugins/hoster/CatShareNet.py b/module/plugins/hoster/CatShareNet.py index 3289ef72c..66d46c2e8 100644 --- a/module/plugins/hoster/CatShareNet.py +++ b/module/plugins/hoster/CatShareNet.py @@ -35,4 +35,5 @@ class CatShareNet(SimpleHoster): self.invalidCaptcha() self.retry() + getInfo = create_getInfo(CatShareNet) diff --git a/module/plugins/hoster/ChipDe.py b/module/plugins/hoster/ChipDe.py index fcb84a300..8e13b914d 100644 --- a/module/plugins/hoster/ChipDe.py +++ b/module/plugins/hoster/ChipDe.py @@ -4,21 +4,22 @@ import re from module.plugins.Crypter import Crypter + class ChipDe(Crypter): - __name__ = "ChipDe" - __type__ = "container" - __pattern__ = r"http://(?:www\.)?chip.de/video/.*\.html" - __version__ = "0.1" - __description__ = """Chip.de Container Plugin""" - __author_name__ = ('4Christopher') - __author_mail__ = ('4Christopher@gmx.de') + __name__ = "ChipDe" + __type__ = "container" + __pattern__ = r"http://(?:www\.)?chip.de/video/.*\.html" + __version__ = "0.1" + __description__ = """Chip.de Container Plugin""" + __author_name__ = ('4Christopher') + __author_mail__ = ('4Christopher@gmx.de') - def decrypt(self, pyfile): - self.html = self.load(pyfile.url) - try: - url = re.search(r'"(http://video.chip.de/\d+?/.*)"', self.html).group(1) - self.logDebug('The file URL is %s' % url) - except: - self.fail('Failed to find the URL') + def decrypt(self, pyfile): + self.html = self.load(pyfile.url) + try: + url = re.search(r'"(http://video.chip.de/\d+?/.*)"', self.html).group(1) + self.logDebug('The file URL is %s' % url) + except: + self.fail('Failed to find the URL') - self.packages.append((self.pyfile.package().name, [ url ], self.pyfile.package().folder)) + self.packages.append((self.pyfile.package().name, [url], self.pyfile.package().folder)) diff --git a/module/plugins/hoster/CloudzerNet.py b/module/plugins/hoster/CloudzerNet.py index 6c02203ca..e95f90792 100644 --- a/module/plugins/hoster/CloudzerNet.py +++ b/module/plugins/hoster/CloudzerNet.py @@ -52,7 +52,8 @@ class CloudzerNet(SimpleHoster): recaptcha = ReCaptcha(self) challenge, response = recaptcha.challenge(self.CAPTCHA_KEY) post_data = {"recaptcha_challenge_field": challenge, "recaptcha_response_field": response} - response = json_loads(self.load('http://cloudzer.net/io/ticket/captcha/%s' % self.file_info['ID'], post=post_data, cookies=True)) + response = json_loads(self.load('http://cloudzer.net/io/ticket/captcha/%s' % self.file_info['ID'], + post=post_data, cookies=True)) self.logDebug("Captcha check response", response) self.logDebug("First check") diff --git a/module/plugins/hoster/CramitIn.py b/module/plugins/hoster/CramitIn.py index 171fba0ff..68df322f5 100644 --- a/module/plugins/hoster/CramitIn.py +++ b/module/plugins/hoster/CramitIn.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo + class CramitIn(XFileSharingPro): __name__ = "CramitIn" __type__ = "hoster" @@ -9,12 +10,13 @@ class CramitIn(XFileSharingPro): __description__ = """Cramit.in hoster plugin""" __author_name__ = ("zoidberg") __author_mail__ = ("zoidberg@mujmail.cz") - + FILE_INFO_PATTERN = r'\s*(?P.*?).*?\s*\((?P.*?)\)' - DIRECT_LINK_PATTERN = r'href="(http://cramit.in/file_download/.*?)"' + DIRECT_LINK_PATTERN = r'href="(http://cramit.in/file_download/.*?)"' HOSTER_NAME = "cramit.in" - + def setup(self): - self.resumeDownload = self.multiDL = self.premium + self.resumeDownload = self.multiDL = self.premium + -getInfo = create_getInfo(CramitIn) \ No newline at end of file +getInfo = create_getInfo(CramitIn) diff --git a/module/plugins/hoster/CrockoCom.py b/module/plugins/hoster/CrockoCom.py index f075d073b..7d5336cd9 100644 --- a/module/plugins/hoster/CrockoCom.py +++ b/module/plugins/hoster/CrockoCom.py @@ -1,15 +1,17 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +import re + from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo from module.plugins.internal.CaptchaService import ReCaptcha -import re + class CrockoCom(SimpleHoster): __name__ = "CrockoCom" __type__ = "hoster" __pattern__ = r"http://(www\.)?(crocko|easy-share).com/.*" - __version__ = "0.13" + __version__ = "0.14" __description__ = """Crocko Download Hoster""" __author_name__ = ("zoidberg") __author_mail__ = ("zoidberg@mujmail.cz") @@ -20,45 +22,46 @@ class CrockoCom(SimpleHoster): DOWNLOAD_URL_PATTERN = r"window.location ='([^']+)';" CAPTCHA_URL_PATTERN = re.compile(r"u='(/file_contents/captcha/\w+)';\s*w='(\d+)';") CAPTCHA_KEY_PATTERN = re.compile(r'Recaptcha.create\("([^"]+)"') - + FORM_PATTERN = r'
(.*?)
' FORM_INPUT_PATTERN = r']* name="?([^" ]+)"? value="?([^" ]+)"?[^>]*>' - + FILE_NAME_REPLACEMENTS = [(r'<[^>]*>', '')] def handleFree(self): if "You need Premium membership to download this file." in self.html: self.fail("You need Premium membership to download this file.") - - url = False + for i in range(5): found = re.search(self.CAPTCHA_URL_PATTERN, self.html) - if found: + if found: url, wait_time = 'http://crocko.com' + found.group(1), found.group(2) self.setWait(wait_time) self.wait() self.html = self.load(url) - else: - break - + else: + break + found = re.search(self.CAPTCHA_KEY_PATTERN, self.html) - if not found: self.parseError('Captcha KEY') + if not found: + self.parseError('Captcha KEY') captcha_key = found.group(1) - + found = re.search(self.FORM_PATTERN, self.html, re.DOTALL) - if not found: self.parseError('ACTION') + if not found: + self.parseError('ACTION') action, form = found.groups() inputs = dict(re.findall(self.FORM_INPUT_PATTERN, form)) - + recaptcha = ReCaptcha(self) - + for i in range(5): inputs['recaptcha_challenge_field'], inputs['recaptcha_response_field'] = recaptcha.challenge(captcha_key) - self.download(action, post = inputs) - + self.download(action, post=inputs) + check = self.checkDownload({ "captcha_err": self.CAPTCHA_KEY_PATTERN - }) + }) if check == "captcha_err": self.invalidCaptcha() @@ -67,5 +70,5 @@ class CrockoCom(SimpleHoster): else: self.fail('No valid captcha solution received') + getInfo = create_getInfo(CrockoCom) - \ No newline at end of file diff --git a/module/plugins/hoster/CyberlockerCh.py b/module/plugins/hoster/CyberlockerCh.py index 57dd26787..19a4473b3 100644 --- a/module/plugins/hoster/CyberlockerCh.py +++ b/module/plugins/hoster/CyberlockerCh.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo + class CyberlockerCh(XFileSharingPro): __name__ = "CyberlockerCh" __type__ = "hoster" @@ -12,4 +13,5 @@ class CyberlockerCh(XFileSharingPro): HOSTER_NAME = "cyberlocker.ch" + getInfo = create_getInfo(CyberlockerCh) diff --git a/module/plugins/hoster/CzshareCom.py b/module/plugins/hoster/CzshareCom.py index 347427586..8f6f76d84 100644 --- a/module/plugins/hoster/CzshareCom.py +++ b/module/plugins/hoster/CzshareCom.py @@ -23,6 +23,7 @@ import re from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, PluginParseError from module.utils import parseFileSize + class CzshareCom(SimpleHoster): __name__ = "CzshareCom" __type__ = "hoster" @@ -34,7 +35,7 @@ class CzshareCom(SimpleHoster): FILE_NAME_PATTERN = r'
\s*

\s*Cel. n.zev: ]*>(?P[^<]+)' FILE_SIZE_PATTERN = r'

(?:\s*

[^\n]*

)*\s*Velikost:\s*(?P[0-9., ]+)(?P[kKMG])i?B\s*
' FILE_OFFLINE_PATTERN = r'
\s*

' - + FILE_SIZE_REPLACEMENTS = [(' ', '')] FILE_URL_REPLACEMENTS = [(r'http://[^/]*/download.php\?.*?id=(\w+).*', r'http://czshare.com/\1/x/')] SH_CHECK_TRAFFIC = True @@ -57,11 +58,12 @@ class CzshareCom(SimpleHoster): 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: return False + if not found: + return False # check user credit try: - credit = parseFileSize(found.group(1).replace(' ',''), found.group(2)) + credit = parseFileSize(found.group(1).replace(' ', ''), found.group(2)) self.logInfo("Premium download for %i KiB of Credit" % (self.pyfile.size / 1024)) self.logInfo("User %s has %i KiB left" % (self.user, credit / 1024)) if credit < self.pyfile.size: @@ -70,11 +72,11 @@ class CzshareCom(SimpleHoster): except Exception, e: # let's continue and see what happens... self.logError('Parse error (CREDIT): %s' % e) - - return True - - def handlePremium(self): - # parse download link + + return True + + def handlePremium(self): + # parse download link try: form = re.search(self.PREMIUM_FORM_PATTERN, self.html, re.DOTALL).group(1) inputs = dict(re.findall(self.FORM_INPUT_PATTERN, form)) @@ -121,20 +123,20 @@ class CzshareCom(SimpleHoster): break else: self.fail("No valid captcha code entered") - + found = re.search("countdown_number = (\d+);", self.html) self.setWait(int(found.group(1)) if found else 50) # 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) + self.logDebug("WAIT URL", self.req.lastEffectiveURL) + found = re.search("free_wait.php\?server=(.*?)&(.*)", self.req.lastEffectiveURL) if not found: raise PluginParseError('Download URL') url = "http://%s/download.php?%s" % (found.group(1), found.group(2)) - - self.wait() - self.multiDL = True + + self.wait() + self.multiDL = True self.download(url) self.checkDownloadedFile() @@ -145,7 +147,7 @@ class CzshareCom(SimpleHoster): "credit": re.compile(r"^Nem.*te dostate.*n.* kredit.$"), "multi_dl": re.compile(self.MULTIDL_PATTERN), "captcha_err": "
  • Zadaný ověřovací kód nesouhlasí!
  • " - }) + }) if check == "tempoffline": self.fail("File not available - try later") @@ -156,5 +158,6 @@ class CzshareCom(SimpleHoster): elif check == "captcha_err": self.invalidCaptcha() self.retry() - + + getInfo = create_getInfo(CzshareCom) diff --git a/module/plugins/hoster/DailymotionCom.py b/module/plugins/hoster/DailymotionCom.py index 1b411393d..ab8ff7910 100644 --- a/module/plugins/hoster/DailymotionCom.py +++ b/module/plugins/hoster/DailymotionCom.py @@ -5,6 +5,7 @@ import re from urllib import unquote from module.plugins.Hoster import Hoster + class DailymotionCom(Hoster): __name__ = 'DailymotionCom' __type__ = 'hoster' @@ -22,12 +23,13 @@ class DailymotionCom(Hoster): r'', r'"(?:vs_videotitle|videoTitle|dm_title|ss_mediaTitle)": "(.*?)"'): filename = re.search(pattern, html) - if filename is not None: break + if filename is not None: + break else: self.fail("Unable to find file name") - pyfile.name = filename.group(1)+'.mp4' - self.logDebug('Filename='+pyfile.name) + pyfile.name = filename.group(1) + '.mp4' + self.logDebug('Filename=' + pyfile.name) allLinksInfo = re.search(r'"sequence":"(.*?)"', html) self.logDebug(allLinksInfo.groups()) allLinksInfo = unquote(allLinksInfo.group(1)) @@ -44,4 +46,4 @@ class DailymotionCom(Hoster): def getQuality(self, quality, data): link = re.search('"' + quality + '":"(http:[^<>"\']+)"', data) if link is not None: - return link.group(1).replace('\\','') \ No newline at end of file + return link.group(1).replace('\\', '') diff --git a/module/plugins/hoster/DataportCz.py b/module/plugins/hoster/DataportCz.py index 3dc581bf1..1e24388d7 100644 --- a/module/plugins/hoster/DataportCz.py +++ b/module/plugins/hoster/DataportCz.py @@ -16,10 +16,9 @@ @author: zoidberg """ -import re from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, PluginParseError -from pycurl import FOLLOWLOCATION - + + class DataportCz(SimpleHoster): __name__ = "DataportCz" __type__ = "hoster" @@ -32,26 +31,26 @@ class DataportCz(SimpleHoster): FILE_SIZE_PATTERN = r'Velikost\s*(?P[^<]+)' FILE_OFFLINE_PATTERN = r'

    Soubor nebyl nalezen

    ' FILE_URL_REPLACEMENTS = [(__pattern__, r'http://www.dataport.cz/file/\1')] - - CAPTCHA_URL_PATTERN = r'
    \s*\s*(\d+)
    ' - def handleFree(self): + def handleFree(self): captchas = {"1": "jkeG", "2": "hMJQ", "3": "vmEK", "4": "ePQM", "5": "blBd"} - + for i in range(60): action, inputs = self.parseHtmlForm('free_download_form') self.logDebug(action, inputs) if not action or not inputs: raise PluginParseError('free_download_form') - + if "captchaId" in inputs and inputs["captchaId"] in captchas: - inputs['captchaCode'] = captchas[inputs["captchaId"]] + inputs['captchaCode'] = captchas[inputs["captchaId"]] else: raise PluginParseError('captcha') - - self.html = self.download("http://www.dataport.cz%s" % action, post = inputs) - + + self.html = self.download("http://www.dataport.cz%s" % action, post=inputs) + check = self.checkDownload({"captcha": 'alert("\u0160patn\u011b opsan\u00fd k\u00f3d z obr\u00e1zu");', "slot": 'alert("Je n\u00e1m l\u00edto, ale moment\u00e1ln\u011b nejsou'}) if check == "captcha": @@ -60,9 +59,10 @@ class DataportCz(SimpleHoster): self.logDebug("No free slots - wait 60s and retry") self.setWait(60, False) self.wait() - self.html = self.load(self.pyfile.url, decode = True) + self.html = self.load(self.pyfile.url, decode=True) continue else: break - + + create_getInfo(DataportCz) \ No newline at end of file diff --git a/module/plugins/hoster/DateiTo.py b/module/plugins/hoster/DateiTo.py index 061881e4b..d7760d940 100644 --- a/module/plugins/hoster/DateiTo.py +++ b/module/plugins/hoster/DateiTo.py @@ -20,6 +20,7 @@ import re from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo from module.plugins.internal.CaptchaService import ReCaptcha + class DateiTo(SimpleHoster): __name__ = "DateiTo" __type__ = "hoster" @@ -33,47 +34,48 @@ class DateiTo(SimpleHoster): FILE_SIZE_PATTERN = r'Dateigröße:\s*(?P.*?)Datei wurde nicht gefunden<|>Bitte wähle deine Datei aus... <' PARALELL_PATTERN = r'>Du lädst bereits eine Datei herunter<' - + WAIT_PATTERN = r'countdown\({seconds: (\d+)' DATA_PATTERN = r'url: "(.*?)", data: "(.*?)",' RECAPTCHA_KEY_PATTERN = r'Recaptcha.create\("(.*?)"' - + def handleFree(self): url = 'http://datei.to/ajax/download.php' data = {'P': 'I', 'ID': self.file_info['ID']} - - recaptcha = ReCaptcha(self) - + + recaptcha = ReCaptcha(self) + for i in range(10): - self.logDebug("URL", url, "POST", data) - self.html = self.load(url, post = data) + self.logDebug("URL", url, "POST", data) + self.html = self.load(url, post=data) self.checkErrors() - + if url.endswith('download.php') and 'P' in data: if data['P'] == 'I': self.doWait() - + elif data['P'] == 'IV': - break - + break + found = re.search(self.DATA_PATTERN, self.html) - if not found: self.parseError('data') + if not found: + self.parseError('data') url = 'http://datei.to/' + found.group(1) data = dict(x.split('=') for x in found.group(2).split('&')) - + if url.endswith('recaptcha.php'): found = re.search(self.RECAPTCHA_KEY_PATTERN, self.html) recaptcha_key = found.group(1) if found else "6LdBbL8SAAAAAI0vKUo58XRwDd5Tu_Ze1DA7qTao" - - data['recaptcha_challenge_field'], data['recaptcha_response_field'] = recaptcha.challenge(recaptcha_key) - + + data['recaptcha_challenge_field'], data['recaptcha_response_field'] = recaptcha.challenge(recaptcha_key) + else: - self.fail('Too bad...') - + self.fail('Too bad...') + download_url = self.html self.logDebug('Download URL', download_url) self.download(download_url) - + def checkErrors(self): found = re.search(self.PARALELL_PATTERN, self.html) if found: @@ -82,13 +84,14 @@ class DateiTo(SimpleHoster): self.setWait(wait_time + 1, False) self.wait(300) self.retry() - - def doWait(self): + + def doWait(self): found = re.search(self.WAIT_PATTERN, self.html) wait_time = int(found.group(1)) if found else 30 self.setWait(wait_time + 1, False) - - self.load('http://datei.to/ajax/download.php', post = {'P': 'Ads'}) - self.wait() - + + self.load('http://datei.to/ajax/download.php', post={'P': 'Ads'}) + self.wait() + + getInfo = create_getInfo(DateiTo) diff --git a/module/plugins/hoster/DepositfilesCom.py b/module/plugins/hoster/DepositfilesCom.py index ee5fdf6af..1ede3b715 100644 --- a/module/plugins/hoster/DepositfilesCom.py +++ b/module/plugins/hoster/DepositfilesCom.py @@ -4,9 +4,9 @@ import re from urllib import unquote from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo -from module.network.RequestFactory import getURL from module.plugins.internal.CaptchaService import ReCaptcha + class DepositfilesCom(SimpleHoster): __name__ = "DepositfilesCom" __type__ = "hoster" @@ -21,7 +21,8 @@ class DepositfilesCom(SimpleHoster): FILE_INFO_PATTERN = r'' def process(self, pyfile): - self.html = self.load(pyfile.url, decode = True) + self.html = self.load(pyfile.url, decode=True) self.getFileInfo() - + # parse js variables - self.jsvars = dict((x, y.strip("'")) for x,y in re.findall(r"var (\w+) = ([0-9.]+|'[^']*')", self.html)) - self.logDebug(self.jsvars) + self.jsvars = dict((x, y.strip("'")) for x, y in re.findall(r"var (\w+) = ([0-9.]+|'[^']*')", self.html)) + self.logDebug(self.jsvars) pyfile.name = self.jsvars['ID3'] - + # determine download type - free or premium if self.premium: if 'UU_prihlasen' in self.jsvars: @@ -51,32 +53,33 @@ class QuickshareCz(SimpleHoster): elif float(self.jsvars['UU_kredit']) < float(self.jsvars['kredit_odecet']): self.logWarning('Not enough credit left') self.premium = False - + if self.premium: self.handlePremium() else: self.handleFree() - + check = self.checkDownload({"err": re.compile(r"\AChyba!")}, max_size=100) if check == "err": self.fail("File not found or plugin defect") - - def handleFree(self): + + def handleFree(self): # get download url download_url = '%s/download.php' % self.jsvars['server'] data = dict((x, self.jsvars[x]) for x in self.jsvars if x in ('ID1', 'ID2', 'ID3', 'ID4')) self.logDebug("FREE URL1:" + download_url, data) - - self.req.http.c.setopt(FOLLOWLOCATION, 0) + + self.req.http.c.setopt(FOLLOWLOCATION, 0) self.load(download_url, post=data) - self.header = self.req.http.header + self.header = self.req.http.header self.req.http.c.setopt(FOLLOWLOCATION, 1) - + found = re.search("Location\s*:\s*(.*)", self.header, re.I) - if not found: self.fail('File not found') - download_url = found.group(1) + if not found: + self.fail('File not found') + download_url = found.group(1) self.logDebug("FREE URL2:" + download_url) - + # check errors found = re.search(r'/chyba/(\d+)', download_url) if found: @@ -88,12 +91,13 @@ class QuickshareCz(SimpleHoster): self.fail('Error %d' % found.group(1)) # download file - self.download(download_url) - + self.download(download_url) + def handlePremium(self): download_url = '%s/download_premium.php' % self.jsvars['server'] data = dict((x, self.jsvars[x]) for x in self.jsvars if x in ('ID1', 'ID2', 'ID4', 'ID5')) self.logDebug("PREMIUM URL:" + download_url, data) self.download(download_url, get=data) + getInfo = create_getInfo(QuickshareCz) diff --git a/module/plugins/hoster/RapidshareCom.py b/module/plugins/hoster/RapidshareCom.py index cbbf5115a..9d40b867f 100644 --- a/module/plugins/hoster/RapidshareCom.py +++ b/module/plugins/hoster/RapidshareCom.py @@ -1,4 +1,3 @@ - #!/usr/bin/env python # -*- coding: utf-8 -*- @@ -14,6 +13,7 @@ import re from module.network.RequestFactory import getURL from module.plugins.Hoster import Hoster + def getInfo(urls): ids = "" names = "" @@ -23,26 +23,29 @@ def getInfo(urls): for url in urls: r = p.search(url) if r.group("name"): - ids+= ","+r.group("id") - names+= ","+r.group("name") + ids += "," + r.group("id") + names += "," + r.group("name") elif r.group("name_new"): - ids+= ","+r.group("id_new") - names+= ","+r.group("name_new") - + ids += "," + r.group("id_new") + names += "," + r.group("name_new") + url = "http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=checkfiles&files=%s&filenames=%s" % (ids[1:], names[1:]) - + api = getURL(url) result = [] i = 0 for res in api.split(): tmp = res.split(",") - if tmp[4] in ("0", "4", "5"): status = 1 - elif tmp[4] == "1": status = 2 - else: status = 3 - - result.append( (tmp[1], tmp[2], status, urls[i]) ) + if tmp[4] in ("0", "4", "5"): + status = 1 + elif tmp[4] == "1": + status = 2 + else: + status = 3 + + result.append((tmp[1], tmp[2], status, urls[i])) i += 1 - + yield result @@ -52,7 +55,9 @@ class RapidshareCom(Hoster): __pattern__ = r"https?://[\w\.]*?rapidshare.com/(?:files/(?P\d*?)/(?P[^?]+)|#!download\|(?:\w+)\|(?P\d+)\|(?P[^|]+))" __version__ = "1.39" __description__ = """Rapidshare.com Download Hoster""" - __config__ = [["server", "Cogent;Deutsche Telekom;Level(3);Level(3) #2;GlobalCrossing;Level(3) #3;Teleglobe;GlobalCrossing #2;TeliaSonera #2;Teleglobe #2;TeliaSonera #3;TeliaSonera", "Preferred Server", "None"]] + __config__ = [["server", + "Cogent;Deutsche Telekom;Level(3);Level(3) #2;GlobalCrossing;Level(3) #3;Teleglobe;GlobalCrossing #2;TeliaSonera #2;Teleglobe #2;TeliaSonera #3;TeliaSonera", + "Preferred Server", "None"]] __author_name__ = ("spoob", "RaNaN", "mkaay") __author_mail__ = ("spoob@pyload.org", "ranan@pyload.org", "mkaay@mkaay.de") @@ -65,14 +70,14 @@ class RapidshareCom(Hoster): self.id = None self.name = None - - self.chunkLimit = -1 if self.premium else 1 + + self.chunkLimit = -1 if self.premium else 1 self.multiDL = self.resumeDownload = self.premium def process(self, pyfile): - self.url = self.pyfile.url + self.url = self.pyfile.url self.prepare() - + def prepare(self): m = re.search(self.__pattern__, self.url) @@ -96,9 +101,9 @@ class RapidshareCom(Hoster): self.logInfo(_("Rapidshare: Traffic Share (direct download)")) self.pyfile.name = self.get_file_name() - self.download(self.pyfile.url, get={"directstart":1}) - - elif self.api_data["status"] in ("0","4","5"): + self.download(self.pyfile.url, get={"directstart": 1}) + + elif self.api_data["status"] in ("0", "4", "5"): self.offline() elif self.api_data["status"] == "3": self.tempOffline() @@ -116,8 +121,8 @@ class RapidshareCom(Hoster): self.logDebug("RS API Request: %s" % download) self.download(download, ref=False) - check = self.checkDownload({"ip" : "You need RapidPro to download more files from your IP address", - "auth" : "Download auth invalid"}) + check = self.checkDownload({"ip": "You need RapidPro to download more files from your IP address", + "auth": "Download auth invalid"}) if check == "ip": self.setWait(60) self.logInfo(_("Already downloading from this ip address, waiting 60 seconds")) @@ -132,8 +137,7 @@ class RapidshareCom(Hoster): info = self.account.getAccountInfo(self.user, True) self.logDebug("%s: Use Premium Account" % self.__name__) url = self.api_data["mirror"] - self.download(url, get={"directstart":1}) - + self.download(url, get={"directstart": 1}) def download_api_data(self, force=False): """ @@ -148,16 +152,17 @@ class RapidshareCom(Hoster): if src.startswith("ERROR"): return fields = src.split(",") - """ - status codes: - 0=File not found - 1=File OK (Anonymous downloading) - 3=Server down - 4=File marked as illegal - 5=Anonymous file locked, because it has more than 10 downloads already - 50+n=File OK (TrafficShare direct download type "n" without any logging.) - 100+n=File OK (TrafficShare direct download type "n" with logging. Read our privacy policy to see what is logged.) - """ + + # status codes: + # 0=File not found + # 1=File OK (Anonymous downloading) + # 3=Server down + # 4=File marked as illegal + # 5=Anonymous file locked, because it has more than 10 downloads already + # 50+n=File OK (TrafficShare direct download type "n" without any logging.) + # 100+n=File OK (TrafficShare direct download type "n" with logging. + # Read our privacy policy to see what is logged.) + self.api_data = {"fileid": fields[0], "filename": fields[1], "size": int(fields[2]), "serverid": fields[3], "status": fields[4], "shorthost": fields[5], "checksum": fields[6].strip().lower()} @@ -166,7 +171,8 @@ class RapidshareCom(Hoster): elif int(self.api_data["status"]) > 50: self.api_data["status"] = str(int(self.api_data["status"]) - 50) - self.api_data["mirror"] = "http://rs%(serverid)s%(shorthost)s.rapidshare.com/files/%(fileid)s/%(filename)s" % self.api_data + self.api_data["mirror"] = \ + "http://rs%(serverid)s%(shorthost)s.rapidshare.com/files/%(fileid)s/%(filename)s" % self.api_data def freeWait(self): """downloads html with the important information @@ -176,7 +182,8 @@ class RapidshareCom(Hoster): id = self.id name = self.name - prepare = "https://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=download&fileid=%(id)s&filename=%(name)s&try=1&cbf=RSAPIDispatcher&cbid=1" % {"name": name, "id" : id} + prepare = "https://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=download&fileid=%(id)s&filename=%(name)s&try=1&cbf=RSAPIDispatcher&cbid=1" % { + "name": name, "id": id} self.logDebug("RS API Request: %s" % prepare) result = self.load(prepare, ref=False) @@ -188,7 +195,8 @@ class RapidshareCom(Hoster): self.setWait(60) self.logInfo(_("Already downloading from this ip address, waiting 60 seconds")) self.wait() - elif "Too many users downloading from this server right now" in result or "All free download slots are full" in result: + elif "Too many users downloading from this server right now" in result or \ + "All free download slots are full" in result: self.setWait(120) self.logInfo(_("RapidShareCom: No free slots")) self.wait() @@ -207,19 +215,17 @@ class RapidshareCom(Hoster): data = info.split(",") dl_dict = {"id": id, - "name": name, - "host": data[0], - "auth": data[1], - "server": self.api_data["serverid"], - "size": self.api_data["size"] - } - self.setWait(int(data[2])+2+self.offset) + "name": name, + "host": data[0], + "auth": data[1], + "server": self.api_data["serverid"], + "size": self.api_data["size"]} + self.setWait(int(data[2]) + 2 + self.offset) self.wait() return dl_dict - def get_file_name(self): if self.api_data["filename"]: return self.api_data["filename"] - return self.url.split("/")[-1] \ No newline at end of file + return self.url.split("/")[-1] diff --git a/module/plugins/hoster/RarefileNet.py b/module/plugins/hoster/RarefileNet.py index a0f5930b5..1ede51953 100644 --- a/module/plugins/hoster/RarefileNet.py +++ b/module/plugins/hoster/RarefileNet.py @@ -27,8 +27,9 @@ class RarefileNet(XFileSharingPro): captcha_div = re.search(r'Enter code.*?(.*?)

    ', self.html, re.S).group(1) self.logDebug(captcha_div) numerals = re.findall('(\d)', html_unescape(captcha_div)) - inputs['code'] = "".join([a[1] for a in sorted(numerals, key = lambda num: int(num[0]))]) + inputs['code'] = "".join([a[1] for a in sorted(numerals, key=lambda num: int(num[0]))]) self.logDebug("CAPTCHA", inputs['code'], numerals) return 3 + getInfo = create_getInfo(RarefileNet) diff --git a/module/plugins/hoster/RealdebridCom.py b/module/plugins/hoster/RealdebridCom.py index 73baff5b3..fd91b89b7 100644 --- a/module/plugins/hoster/RealdebridCom.py +++ b/module/plugins/hoster/RealdebridCom.py @@ -6,10 +6,11 @@ from time import time from urllib import quote, unquote from random import randrange -from module.utils import parseFileSize, remove_chars +from module.utils import parseFileSize from module.common.json_layer import json_loads from module.plugins.Hoster import Hoster + class RealdebridCom(Hoster): __name__ = "RealdebridCom" __version__ = "0.51" @@ -25,8 +26,8 @@ class RealdebridCom(Hoster): name = unquote(url.rsplit("/", 1)[1]) except IndexError: name = "Unknown_Filename..." - if not name or name.endswith(".."): #incomplete filename, append random stuff - name += "%s.tmp" % randrange(100,999) + if not name or name.endswith(".."): # incomplete filename, append random stuff + name += "%s.tmp" % randrange(100, 999) return name def init(self): @@ -34,7 +35,6 @@ class RealdebridCom(Hoster): self.chunkLimit = 3 self.resumeDownload = True - def process(self, pyfile): if not self.account: self.logError(_("Please enter your %s account or deactivate this plugin") % "Real-debrid") @@ -45,10 +45,13 @@ class RealdebridCom(Hoster): new_url = pyfile.url else: password = self.getPassword().splitlines() - if not password: password = "" - else: password = password[0] + if not password: + password = "" + else: + password = password[0] - url = "http://real-debrid.com/ajax/unrestrict.php?lang=en&link=%s&password=%s&time=%s" % (quote(pyfile.url, ""), password, int(time()*1000)) + url = "http://real-debrid.com/ajax/unrestrict.php?lang=en&link=%s&password=%s&time=%s" % ( + quote(pyfile.url, ""), password, int(time() * 1000)) page = self.load(url) data = json_loads(page) @@ -80,9 +83,8 @@ class RealdebridCom(Hoster): self.download(new_url, disposition=True) check = self.checkDownload( - {"error": "An error occured while processing your request"}) + {"error": "An error occured while processing your request"}) if check == "error": #usual this download can safely be retried self.retry(reason="An error occured while generating link.", wait_time=60) - diff --git a/module/plugins/hoster/RedtubeCom.py b/module/plugins/hoster/RedtubeCom.py index c2083e679..caf33eeac 100644 --- a/module/plugins/hoster/RedtubeCom.py +++ b/module/plugins/hoster/RedtubeCom.py @@ -5,6 +5,7 @@ import re from module.plugins.Hoster import Hoster from module.unescape import unescape + class RedtubeCom(Hoster): __name__ = "RedtubeCom" __type__ = "hoster" @@ -13,15 +14,15 @@ class RedtubeCom(Hoster): __description__ = """Redtube.com Download Hoster""" __author_name__ = ("jeix") __author_mail__ = ("jeix@hasnomail.de") - + def process(self, pyfile): self.download_html() if not self.file_exists(): self.offline() - + pyfile.name = self.get_file_name() self.download(self.get_file_url()) - + def download_html(self): url = self.pyfile.url self.html = self.load(url) @@ -35,12 +36,12 @@ class RedtubeCom(Hoster): file_url = unescape(re.search(r'hashlink=(http.*?)"', self.html).group(1)) return file_url - + def get_file_name(self): if self.html is None: self.download_html() - - name = re.search('(.*?)- RedTube - Free Porn Videos', self.html).group(1).strip() + ".flv" + + name = re.search('(.*?)- RedTube - Free Porn Videos', self.html).group(1).strip() + ".flv" return name def file_exists(self): @@ -48,9 +49,8 @@ class RedtubeCom(Hoster): """ if self.html is None: self.download_html() - + if re.search(r'This video has been removed.', self.html) is not None: return False else: return True - diff --git a/module/plugins/hoster/RehostTo.py b/module/plugins/hoster/RehostTo.py index 7d1b1c3ea..bb6110415 100644 --- a/module/plugins/hoster/RehostTo.py +++ b/module/plugins/hoster/RehostTo.py @@ -4,6 +4,7 @@ from urllib import quote, unquote from module.plugins.Hoster import Hoster + class RehostTo(Hoster): __name__ = "RehostTo" __version__ = "0.13" @@ -34,4 +35,4 @@ class RehostTo(Hoster): #raise timeout to 2min self.req.setOption("timeout", 120) - self.download(new_url, disposition=True) \ No newline at end of file + self.download(new_url, disposition=True) diff --git a/module/plugins/hoster/ReloadCc.py b/module/plugins/hoster/ReloadCc.py index b39c2812c..2295c792a 100644 --- a/module/plugins/hoster/ReloadCc.py +++ b/module/plugins/hoster/ReloadCc.py @@ -1,16 +1,18 @@ -from module.plugins.Hoster import Hoster +from module.plugins.Hoster import Hoster from module.common.json_layer import json_loads from module.network.HTTPRequest import BadHeader + class ReloadCc(Hoster): __name__ = "ReloadCc" __version__ = "0.5" __type__ = "hoster" __description__ = """Reload.Cc hoster plugin""" - # Since we want to allow the user to specify the list of hoster to use we let MultiHoster.coreReady create the regex patterns for us using getHosters in our ReloadCc hook. + # Since we want to allow the user to specify the list of hoster to use we let MultiHoster.coreReady + # create the regex patterns for us using getHosters in our ReloadCc hook. __pattern__ = None __author_name__ = ("Reload Team") @@ -22,8 +24,9 @@ class ReloadCc(Hoster): self.logError(_("Please enter your %s account or deactivate this plugin") % "reload.cc") self.fail("No valid reload.cc account provided") - # In some cases hostsers do not supply us with a filename at download, so we are going to set a fall back filename (e.g. for freakshare or xfileshare) - self.pyfile.name = self.pyfile.name.split('/').pop() # Remove everthing before last slash + # In some cases hostsers do not supply us with a filename at download, so we + # are going to set a fall back filename (e.g. for freakshare or xfileshare) + self.pyfile.name = self.pyfile.name.split('/').pop() # Remove everthing before last slash # Correction for automatic assigned filename: Removing html at end if needed suffix_to_remove = ["html", "htm", "php", "php3", "asp", "shtm", "shtml", "cfml", "cfm"] @@ -62,11 +65,15 @@ class ReloadCc(Hoster): # Wait for 6 hours and retry up to 4 times => one day self.retry(max_retries=4, wait_time=(3600 * 6), reason="Limited hoster traffic limit exceeded") elif e.code == 429: - self.retry(max_retries=5, wait_time=120, reason="Too many concurrent connections") # Too many connections, wait 2 minutes and try again + # Too many connections, wait 2 minutes and try again + self.retry(max_retries=5, wait_time=120, reason="Too many concurrent connections") elif e.code == 503: - self.retry(wait_time=600, reason="Reload.cc is currently in maintenance mode! Please check again later.") # Retry in 10 minutes + # Retry in 10 minutes + self.retry(wait_time=600, + reason="Reload.cc is currently in maintenance mode! Please check again later.") else: - self.fail("Internal error within Reload.cc. Please contact the Reload.cc support for further information.") + self.fail( + "Internal error within Reload.cc. Please contact the Reload.cc support for further information.") return data = json_loads(answer) @@ -95,9 +102,12 @@ class ReloadCc(Hoster): elif e.code == 417: self.fail("Password required for file access") elif e.code == 429: - self.retry(max_retries=5, wait_time=120, reason="Too many concurrent connections") # Too many connections, wait 2 minutes and try again + # Too many connections, wait 2 minutes and try again + self.retry(max_retries=5, wait_time=120, reason="Too many concurrent connections") else: - self.fail("Internal error within Reload.cc. Please contact the Reload.cc support for further information.") + self.fail( + "Internal error within Reload.cc. Please contact the Reload.cc support for further information." + ) return else: self.fail("Internal error within Reload.cc. Please contact the Reload.cc support for further information.") diff --git a/module/plugins/hoster/RyushareCom.py b/module/plugins/hoster/RyushareCom.py index 7bfe4e8fe..eff9a6140 100644 --- a/module/plugins/hoster/RyushareCom.py +++ b/module/plugins/hoster/RyushareCom.py @@ -1,7 +1,8 @@ # -*- coding: utf-8 -*- -from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo import re +from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo + class RyushareCom(XFileSharingPro): __name__ = "RyushareCom" @@ -27,10 +28,10 @@ class RyushareCom(XFileSharingPro): def getDownloadLink(self): self.html = self.load(self.pyfile.url) action, inputs = self.parseHtmlForm(input_names={"op": re.compile("^download")}) - if inputs.has_key('method_premium'): + if 'method_premium' in inputs: del inputs['method_premium'] - self.html = self.load(self.pyfile.url, post = inputs) + self.html = self.load(self.pyfile.url, post=inputs) action, inputs = self.parseHtmlForm('F1') for i in xrange(10): @@ -45,11 +46,12 @@ class RyushareCom(XFileSharingPro): self.setWait(waittime) self.wait() - self.html = self.load(self.pyfile.url, post = inputs) + self.html = self.load(self.pyfile.url, post=inputs) if 'Click here to download' in self.html: m = re.search(self.DIRECT_LINK_PATTERN, self.html) return m.group(1) self.parseError('No direct link within 10 retries') + getInfo = create_getInfo(RyushareCom) diff --git a/module/plugins/hoster/SecureUploadEu.py b/module/plugins/hoster/SecureUploadEu.py index b9a900d96..dc220c508 100644 --- a/module/plugins/hoster/SecureUploadEu.py +++ b/module/plugins/hoster/SecureUploadEu.py @@ -15,4 +15,5 @@ class SecureUploadEu(XFileSharingPro): FILE_INFO_PATTERN = '

    Downloading (?P[^<]+) \((?P[^<]+)\)

    ' FILE_OFFLINE_PATTERN = 'The file was removed|File Not Found' + getInfo = create_getInfo(SecureUploadEu) diff --git a/module/plugins/hoster/SendmywayCom.py b/module/plugins/hoster/SendmywayCom.py index fcbac850a..9b4fc14bc 100644 --- a/module/plugins/hoster/SendmywayCom.py +++ b/module/plugins/hoster/SendmywayCom.py @@ -15,4 +15,5 @@ class SendmywayCom(XFileSharingPro): FILE_SIZE_PATTERN = r'\((?P\d+) bytes\)' HOSTER_NAME = "sendmyway.com" + getInfo = create_getInfo(SendmywayCom) diff --git a/module/plugins/hoster/SendspaceCom.py b/module/plugins/hoster/SendspaceCom.py index 22abaff56..729ee17bc 100644 --- a/module/plugins/hoster/SendspaceCom.py +++ b/module/plugins/hoster/SendspaceCom.py @@ -19,6 +19,7 @@ import re from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo + class SendspaceCom(SimpleHoster): __name__ = "SendspaceCom" __type__ = "hoster" @@ -33,35 +34,37 @@ class SendspaceCom(SimpleHoster): FILE_OFFLINE_PATTERN = r'
    Sorry, the file you requested is not available.
    ' CAPTCHA_PATTERN = r'' USER_CAPTCHA_PATTERN = r'' - + def handleFree(self): params = {} for i in range(3): found = re.search(self.DOWNLOAD_URL_PATTERN, self.html) if found: - if params.has_key('captcha_hash'): self.correctCaptcha() + if 'captcha_hash' in params: + self.correctCaptcha() download_url = found.group(1) break found = re.search(self.CAPTCHA_PATTERN, self.html) if found: - if params.has_key('captcha_hash'): self.invalidCaptcha() + if 'captcha_hash' in params: + self.invalidCaptcha() captcha_url1 = "http://www.sendspace.com/" + found.group(1) found = re.search(self.USER_CAPTCHA_PATTERN, self.html) captcha_url2 = "http://www.sendspace.com/" + found.group(1) - params = {'captcha_hash' : found.group(2), + params = {'captcha_hash': found.group(2), 'captcha_submit': 'Verify', - 'captcha_answer': self.decryptCaptcha(captcha_url1) + " " + self.decryptCaptcha(captcha_url2) - } + 'captcha_answer': self.decryptCaptcha(captcha_url1) + " " + self.decryptCaptcha(captcha_url2)} else: params = {'download': "Regular Download"} self.logDebug(params) - self.html = self.load(self.pyfile.url, post = params) + self.html = self.load(self.pyfile.url, post=params) else: self.fail("Download link not found") self.logDebug("Download URL: %s" % download_url) self.download(download_url) -create_getInfo(SendspaceCom) \ No newline at end of file + +create_getInfo(SendspaceCom) diff --git a/module/plugins/hoster/Share4webCom.py b/module/plugins/hoster/Share4webCom.py index ef9c2acf8..ead808024 100644 --- a/module/plugins/hoster/Share4webCom.py +++ b/module/plugins/hoster/Share4webCom.py @@ -3,6 +3,7 @@ from module.plugins.hoster.UnibytesCom import UnibytesCom from module.plugins.internal.SimpleHoster import create_getInfo + class Share4webCom(UnibytesCom): __name__ = "Share4webCom" __type__ = "hoster" @@ -10,7 +11,8 @@ class Share4webCom(UnibytesCom): __version__ = "0.1" __description__ = """Share4web.com""" __author_name__ = ("zoidberg") - + DOMAIN = 'http://www.share4web.com' -getInfo = create_getInfo(UnibytesCom) \ No newline at end of file + +getInfo = create_getInfo(UnibytesCom) diff --git a/module/plugins/hoster/Share76Com.py b/module/plugins/hoster/Share76Com.py index db850cb73..aaa8cd950 100644 --- a/module/plugins/hoster/Share76Com.py +++ b/module/plugins/hoster/Share76Com.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo + class Share76Com(XFileSharingPro): __name__ = "Share76Com" __type__ = "hoster" @@ -16,4 +17,5 @@ class Share76Com(XFileSharingPro): self.resumeDownload = self.multiDL = self.premium self.chunkLimit = 1 + getInfo = create_getInfo(Share76Com) diff --git a/module/plugins/hoster/ShareFilesCo.py b/module/plugins/hoster/ShareFilesCo.py index ee44b0a1f..245e20ea6 100644 --- a/module/plugins/hoster/ShareFilesCo.py +++ b/module/plugins/hoster/ShareFilesCo.py @@ -1,7 +1,9 @@ # -*- coding: utf-8 -*- -from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo import re +from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo + + class ShareFilesCo(XFileSharingPro): __name__ = "ShareFilesCo" __type__ = "hoster" @@ -17,8 +19,10 @@ class ShareFilesCo(XFileSharingPro): link = link.strip() if link.startswith('http://adf.ly'): link = re.sub('http://adf.ly/\d+/', '', link) - if self.captcha: self.correctCaptcha() + if self.captcha: + self.correctCaptcha() self.logDebug('DIRECT LINK: %s' % link) self.download(link) + getInfo = create_getInfo(ShareFilesCo) diff --git a/module/plugins/hoster/ShareRapidCom.py b/module/plugins/hoster/ShareRapidCom.py index 5a08fed1f..42bdaa4e3 100644 --- a/module/plugins/hoster/ShareRapidCom.py +++ b/module/plugins/hoster/ShareRapidCom.py @@ -8,8 +8,9 @@ from module.network.HTTPRequest import BadHeader from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo from module.common.json_layer import json_loads -def checkFile(url): - response = getURL("http://share-rapid.com/checkfiles.php", post = {"files": url}, decode = True) + +def checkFile(url): + response = getURL("http://share-rapid.com/checkfiles.php", post={"files": url}, decode=True) info = json_loads(response) if "error" in info: @@ -17,28 +18,30 @@ def checkFile(url): info['name'] = info['filename'] info['status'] = 2 elif info['msg'] == "Not found": - info['status'] = 1 #offline + info['status'] = 1 # offline elif info['msg'] == "Service Unavailable": - info['status'] = 6 #temp.offline + info['status'] = 6 # temp.offline return info - + + def getInfo(urls): for url in urls: info = checkFile(url) if "filename" in info: yield info['name'], info['size'], info['status'], url - else: + else: file_info = (url, 0, 3, url) h = getRequest() try: h.c.setopt(HTTPHEADER, ["Accept: text/html"]) - html = h.load(url, cookies = True, decode = True) - file_info = parseFileInfo(ShareRapidCom, url, html) + html = h.load(url, cookies=True, decode=True) + file_info = parseFileInfo(ShareRapidCom, url, html) finally: h.close() yield file_info + class ShareRapidCom(SimpleHoster): __name__ = "ShareRapidCom" __type__ = "hoster" @@ -51,11 +54,11 @@ class ShareRapidCom(SimpleHoster): FILE_NAME_PATTERN = r']*>]*>(?:]*>)?(?P[^<]+)' FILE_SIZE_PATTERN = r'Velikost:\s*\s*(?P[0-9.]+) (?P[kKMG])i?B' FILE_OFFLINE_PATTERN = ur'Nastala chyba 404|Soubor byl smazán' - + DOWNLOAD_URL_PATTERN = r'([^<]+)' ERR_LOGIN_PATTERN = ur'
    Stahování je přístupné pouze přihlášeným uživatelům' ERR_CREDIT_PATTERN = ur'
    Stahování zdarma je možné jen přes náš' - + FILE_URL_REPLACEMENTS = [(__pattern__, r'http://share-rapid.com/stahuj/\1')] def setup(self): @@ -63,23 +66,24 @@ class ShareRapidCom(SimpleHoster): self.resumeDownload = True def process(self, pyfile): - if not self.account: self.fail("User not logged in") - + if not self.account: + self.fail("User not logged in") + self.info = checkFile(pyfile.url) self.logDebug(self.info) - - pyfile.status = self.info['status'] - + + pyfile.status = self.info['status'] + if pyfile.status == 2: pyfile.name = self.info['name'] pyfile.size = self.info['size'] - elif pyfile.status == 1: + elif pyfile.status == 1: self.offline() elif pyfile.status == 6: self.tempOffline() else: self.fail("Unexpected file status") - + url = "http://share-rapid.com/stahuj/%s" % self.info['filepath'] try: self.html = self.load(url, decode=True) @@ -89,15 +93,15 @@ class ShareRapidCom(SimpleHoster): found = re.search(self.DOWNLOAD_URL_PATTERN, self.html) if found is not None: - link = found.group(1) + link = found.group(1) self.logDebug("Premium link: %s" % link) - + self.check_data = {"size": pyfile.size} self.download(link) else: if re.search(self.ERR_LOGIN_PATTERN, self.html): self.relogin(self.user) - self.retry(3,0,"User login failed") + self.retry(3, 0, "User login failed") elif re.search(self.ERR_CREDIT_PATTERN, self.html): self.fail("Not enough credit left") else: diff --git a/module/plugins/hoster/SharebeesCom.py b/module/plugins/hoster/SharebeesCom.py index f5bacc5b0..cc1173fea 100644 --- a/module/plugins/hoster/SharebeesCom.py +++ b/module/plugins/hoster/SharebeesCom.py @@ -16,4 +16,5 @@ class SharebeesCom(XFileSharingPro): FORM_PATTERN = 'F1' HOSTER_NAME = "sharebees.com" + getInfo = create_getInfo(SharebeesCom) diff --git a/module/plugins/hoster/ShareonlineBiz.py b/module/plugins/hoster/ShareonlineBiz.py index 8a4bcfba8..7c0f9c069 100644 --- a/module/plugins/hoster/ShareonlineBiz.py +++ b/module/plugins/hoster/ShareonlineBiz.py @@ -11,33 +11,38 @@ from module.plugins.Hoster import Hoster from module.network.RequestFactory import getURL from module.plugins.Plugin import chunks from module.plugins.internal.CaptchaService import ReCaptcha as _ReCaptcha - + + def getInfo(urls): api_url_base = "http://api.share-online.biz/linkcheck.php" - + for chunk in chunks(urls, 90): - api_param_file = {"links": "\n".join(x.replace("http://www.share-online.biz/dl/","").rstrip("/") for x in chunk)} #api only supports old style links + api_param_file = {"links": "\n".join(x.replace("http://www.share-online.biz/dl/", "").rstrip("/") for x in + chunk)} # api only supports old style links src = getURL(api_url_base, post=api_param_file, decode=True) result = [] for i, res in enumerate(src.split("\n")): if not res: continue fields = res.split(";") - + if fields[1] == "OK": status = 2 elif fields[1] in ("DELETED", "NOT FOUND"): status = 1 else: status = 3 - + result.append((fields[2], int(fields[3]), status, chunk[i])) yield result + #suppress ocr plugin class ReCaptcha(_ReCaptcha): def result(self, server, challenge): - return self.plugin.decryptCaptcha("%simage"%server, get={"c":challenge}, cookies=True, forceUser=True, imgtype="jpg") + return self.plugin.decryptCaptcha("%simage" % server, get={"c": challenge}, + cookies=True, forceUser=True, imgtype="jpg") + class ShareonlineBiz(Hoster): __name__ = "ShareonlineBiz" @@ -47,7 +52,7 @@ class ShareonlineBiz(Hoster): __description__ = """Shareonline.biz Download Hoster""" __author_name__ = ("spoob", "mkaay", "zoidberg") __author_mail__ = ("spoob@pyload.org", "mkaay@mkaay.de", "zoidberg@mujmail.cz") - + ERROR_INFO_PATTERN = r'

    Information:

    \s*
    \s*(.*?)' def setup(self): @@ -60,133 +65,134 @@ class ShareonlineBiz(Hoster): self.resumeDownload = self.premium self.multiDL = False #self.chunkLimit = 1 - + self.check_data = None - def process(self, pyfile): + def process(self, pyfile): if self.premium: self.handleAPIPremium() #web-download fallback removed - didn't work anyway else: self.handleFree() - - """ - check = self.checkDownload({"failure": re.compile(self.ERROR_INFO_PATTERN)}) - if check == "failure": - try: - self.retry(reason = self.lastCheck.group(1).decode("utf8")) - except: - self.retry(reason = "Unknown error") - """ - - if self.api_data: + + # check = self.checkDownload({"failure": re.compile(self.ERROR_INFO_PATTERN)}) + # if check == "failure": + # try: + # self.retry(reason = self.lastCheck.group(1).decode("utf8")) + # except: + # self.retry(reason = "Unknown error") + + if self.api_data: self.check_data = {"size": int(self.api_data['size']), "md5": self.api_data['md5']} def downloadAPIData(self): api_url_base = "http://api.share-online.biz/linkcheck.php?md5=1" - api_param_file = {"links": self.pyfile.url.replace("http://www.share-online.biz/dl/","")} #api only supports old style links + api_param_file = {"links": self.pyfile.url.replace( + "http://www.share-online.biz/dl/", "")} # api only supports old style links src = self.load(api_url_base, cookies=False, post=api_param_file, decode=True) - + fields = src.split(";") self.api_data = {"fileid": fields[0], "status": fields[1]} if not self.api_data["status"] == "OK": self.offline() self.api_data["filename"] = fields[2] - self.api_data["size"] = fields[3] # in bytes - self.api_data["md5"] = fields[4].strip().lower().replace("\n\n", "") # md5 + self.api_data["size"] = fields[3] # in bytes + self.api_data["md5"] = fields[4].strip().lower().replace("\n\n", "") # md5 - def handleFree(self): + def handleFree(self): self.downloadAPIData() self.pyfile.name = self.api_data["filename"] self.pyfile.size = int(self.api_data["size"]) - - self.html = self.load(self.pyfile.url, cookies = True) #refer, stuff + + self.html = self.load(self.pyfile.url, cookies=True) # refer, stuff self.setWait(3) self.wait() - - self.html = self.load("%s/free/" % self.pyfile.url, post={"dl_free":"1", "choice": "free"}, decode = True) + + self.html = self.load("%s/free/" % self.pyfile.url, post={"dl_free": "1", "choice": "free"}, decode=True) self.checkErrors() - - found = re.search(r'var wait=(\d+);', self.html) - + + found = re.search(r'var wait=(\d+);', self.html) + recaptcha = ReCaptcha(self) - for i in range(5): - challenge, response = recaptcha.challenge("6LdatrsSAAAAAHZrB70txiV5p-8Iv8BtVxlTtjKX") - self.setWait(int(found.group(1)) if found else 30) - response = self.load("%s/free/captcha/%d" % (self.pyfile.url, int(time() * 1000)), post = { + for i in range(5): + challenge, response = recaptcha.challenge("6LdatrsSAAAAAHZrB70txiV5p-8Iv8BtVxlTtjKX") + self.setWait(int(found.group(1)) if found else 30) + response = self.load("%s/free/captcha/%d" % (self.pyfile.url, int(time() * 1000)), post={ 'dl_free': '1', 'recaptcha_challenge_field': challenge, 'recaptcha_response_field': response}) - + if not response == '0': break - else: self.fail("No valid captcha solution received") - + else: + self.fail("No valid captcha solution received") + download_url = response.decode("base64") self.logDebug(download_url) if not download_url.startswith("http://"): self.parseError("download url") - - self.wait() + + self.wait() self.download(download_url) # check download check = self.checkDownload({ "cookie": re.compile(r'
    Share-Online") - }) + }) if check == "cookie": self.retry(5, 60, "Cookie failure") elif check == "fail": self.retry(5, 300, "Download failed") - + def checkErrors(self): found = re.search(r"/failure/(.*?)/1", self.req.lastEffectiveURL) if found: err = found.group(1) found = re.search(self.ERROR_INFO_PATTERN, self.html) msg = found.group(1) if found else "" - self.logError(err, msg or "Unknown error occurred") - + self.logError(err, msg or "Unknown error occurred") + if err in ('freelimit', 'size', 'proxy'): self.fail(msg or "Premium account needed") - if err in ('invalid'): + if err in 'invalid': self.fail(msg or "File not available") - elif err in ('server'): + elif err in 'server': self.setWait(600, False) - elif err in ('expired'): + elif err in 'expired': self.setWait(30, False) - else: + else: self.setWait(300, True) - + self.wait() - self.retry(max_tries=25, reason = msg) - - def handleAPIPremium(self): #should be working better + self.retry(max_tries=25, reason=msg) + + def handleAPIPremium(self): # should be working better self.account.getAccountInfo(self.user, True) src = self.load("http://api.share-online.biz/account.php", - {"username": self.user, "password": self.account.accounts[self.user]["password"], "act": "download", "lid": self.file_id}) + {"username": self.user, "password": self.account.accounts[self.user]["password"], + "act": "download", "lid": self.file_id}) self.api_data = dlinfo = {} for line in src.splitlines(): key, value = line.split(": ") dlinfo[key.lower()] = value - + self.logDebug(dlinfo) if not dlinfo["status"] == "online": self.offline() - + self.pyfile.name = dlinfo["name"] self.pyfile.size = int(dlinfo["size"]) - + dlLink = dlinfo["url"] if dlLink == "server_under_maintenance": self.tempoffline() else: self.multiDL = True self.download(dlLink) - + def checksum(self, local_file): if self.api_data and "md5" in self.api_data and self.api_data["md5"]: h = hashlib.md5() diff --git a/module/plugins/hoster/ShareplaceCom.py b/module/plugins/hoster/ShareplaceCom.py index c55f6703a..5f23f9708 100644 --- a/module/plugins/hoster/ShareplaceCom.py +++ b/module/plugins/hoster/ShareplaceCom.py @@ -5,6 +5,7 @@ import re import urllib from module.plugins.Hoster import Hoster + class ShareplaceCom(Hoster): __name__ = "ShareplaceCom" __type__ = "hoster" @@ -18,35 +19,35 @@ class ShareplaceCom(Hoster): self.html = None self.multiDL = True - def process(self,pyfile): + def process(self, pyfile): self.pyfile = pyfile self.prepare() self.download(self.get_file_url()) - + def prepare(self): if not self.file_exists(): self.offline() self.pyfile.name = self.get_file_name() - + wait_time = self.get_waiting_time() self.setWait(wait_time) - self.logDebug("%s: Waiting %d seconds." % (self.__name__,wait_time)) + self.logDebug("%s: Waiting %d seconds." % (self.__name__, wait_time)) self.wait() def get_waiting_time(self): if self.html is None: self.download_html() - + #var zzipitime = 15; m = re.search(r'var zzipitime = (\d+);', self.html) if m: sec = int(m.group(1)) else: sec = 0 - + return sec - + def download_html(self): url = re.sub("shareplace.com\/\?", "shareplace.com//index1.php/?a=", self.pyfile.url) self.html = self.load(url, decode=True) @@ -57,12 +58,14 @@ class ShareplaceCom(Hoster): url = re.search(r"var beer = '(.*?)';", self.html) if url: url = url.group(1) - url = urllib.unquote(url.replace("http://http:/", "").replace("vvvvvvvvv", "").replace("lllllllll", "").replace("teletubbies", "")) + url = urllib.unquote( + url.replace("http://http:/", "").replace("vvvvvvvvv", "").replace("lllllllll", "").replace( + "teletubbies", "")) self.logDebug("URL: %s" % url) return url else: self.fail("absolute filepath could not be found. offline? ") - + def get_file_name(self): if self.html is None: self.download_html() @@ -74,11 +77,8 @@ class ShareplaceCom(Hoster): """ if self.html is None: self.download_html() - + if re.search(r"HTTP Status 404", self.html) is not None: return False else: return True - - - diff --git a/module/plugins/hoster/ShragleCom.py b/module/plugins/hoster/ShragleCom.py index f21ad213d..2a2738974 100644 --- a/module/plugins/hoster/ShragleCom.py +++ b/module/plugins/hoster/ShragleCom.py @@ -11,29 +11,30 @@ from module.network.RequestFactory import getURL API_KEY = "078e5ca290d728fd874121030efb4a0d" + def parseFileInfo(self, url): file_id = re.match(self.__pattern__, url).group('ID') - - data = getURL( - "http://www.cloudnator.com/api.php?key=%s&action=getStatus&fileID=%s" % (API_KEY, file_id), - decode = True - ).split() - + + data = getURL("http://www.cloudnator.com/api.php?key=%s&action=getStatus&fileID=%s" % (API_KEY, file_id), + decode=True).split() + if len(data) == 4: name, size, md5, status = data size = int(size) - + if hasattr(self, "check_data"): - self.checkdata = {"size": size, "md5": md5} - + self.checkdata = {"size": size, "md5": md5} + return name, size, 2 if status == "0" else 1, url else: return url, 0, 1, url + def getInfo(urls): for url in urls: file_info = parseFileInfo(ShragleCom, url) - yield file_info + yield file_info + class ShragleCom(Hoster): __name__ = "ShragleCom" @@ -48,38 +49,38 @@ class ShragleCom(Hoster): self.html = None self.multiDL = False self.check_data = None - + def process(self, pyfile): #get file status and info self.pyfile.name, self.pyfile.size, status = parseFileInfo(self, pyfile.url)[:3] - if status != 2: + if status != 2: self.offline() - + self.handleFree() - + def handleFree(self): self.html = self.load(self.pyfile.url) - + #get wait time found = re.search('\s*var\sdownloadWait\s=\s(\d+);', self.html) self.setWait(int(found.group(1)) if found else 30) - + #parse download form action, inputs = parseHtmlForm('id="download', self.html) - + #solve captcha found = re.search('recaptcha/api/(?:challenge|noscript)?k=(.+?)', self.html) captcha_key = found.group(1) if found else "6LdEFb0SAAAAAAwM70vnYo2AkiVkCx-xmfniatHz" - + recaptcha = ReCaptcha(self) - + inputs['recaptcha_challenge_field'], inputs['recaptcha_response_field'] = recaptcha.challenge(captcha_key) self.wait() - + #validate self.req.http.c.setopt(FOLLOWLOCATION, 0) - self.html = self.load(action, post = inputs) - + self.html = self.load(action, post=inputs) + found = re.search(r"Location\s*:\s*(\S*)", self.req.http.header, re.I) if found: self.correctCaptcha() @@ -87,20 +88,18 @@ class ShragleCom(Hoster): else: if "Sicherheitscode falsch" in self.html: self.invalidCaptcha() - self.retry(max_tries = 5, reason = "Invalid captcha") + self.retry(max_tries=5, reason="Invalid captcha") else: self.fail("Invalid session") - + #download self.req.http.c.setopt(FOLLOWLOCATION, 1) self.download(download_url) - + check = self.checkDownload({ "ip_blocked": re.compile(r'
    Str.nku nebylo mo.n. nal.zt \(404\)' FILE_NAME_PATTERN = r'' CDN_PATTERN = r'\d+)(?:&cdnLQ=(?P\d*))?(?:&cdnHQ=(?P\d*))?(?:&cdnHD=(?P\d*))?&' @@ -49,28 +51,30 @@ class StreamCz(Hoster): self.multiDL = True self.resumeDownload = True - def process(self, pyfile): - + def process(self, pyfile): + self.html = self.load(pyfile.url, decode=True) - - if re.search(self.FILE_OFFLINE_PATTERN, self.html): + + if re.search(self.FILE_OFFLINE_PATTERN, self.html): self.offline() - + found = re.search(self.CDN_PATTERN, self.html) - if found is None: self.fail("Parse error (CDN)") + if found is None: + self.fail("Parse error (CDN)") cdn = found.groupdict() self.logDebug(cdn) for cdnkey in ("cdnHD", "cdnHQ", "cdnLQ"): - if cdn.has_key(cdnkey) and cdn[cdnkey] > '': + if cdnkey in cdn and cdn[cdnkey] > '': cdnid = cdn[cdnkey] break - else: + else: self.fail("Stream URL not found") - + found = re.search(self.FILE_NAME_PATTERN, self.html) - if found is None: self.fail("Parse error (NAME)") + if found is None: + self.fail("Parse error (NAME)") pyfile.name = "%s-%s.%s.mp4" % (found.group(2), found.group(1), cdnkey[-2:]) - + download_url = "http://cdn-dispatcher.stream.cz/?id=" + cdnid self.logInfo("STREAM (%s): %s" % (cdnkey[-2:], download_url)) self.download(download_url) diff --git a/module/plugins/hoster/StreamcloudEu.py b/module/plugins/hoster/StreamcloudEu.py index 73c0465f8..dd9bf9429 100644 --- a/module/plugins/hoster/StreamcloudEu.py +++ b/module/plugins/hoster/StreamcloudEu.py @@ -1,9 +1,11 @@ # -*- coding: utf-8 -*- -from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo -from module.network.HTTPRequest import HTTPRequest from time import sleep import re +from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo +from module.network.HTTPRequest import HTTPRequest + + class StreamcloudEu(XFileSharingPro): __name__ = "StreamcloudEu" __type__ = "hoster" @@ -31,7 +33,7 @@ class StreamcloudEu(XFileSharingPro): httpRequest = HTTPRequest(options=self.req.options) httpRequest.cj = self.req.cj sleep(10) - self.html = httpRequest.load(self.pyfile.url, post = data, referer=False, cookies=True, decode = True) + self.html = httpRequest.load(self.pyfile.url, post=data, referer=False, cookies=True, decode=True) self.header = httpRequest.header found = re.search("Location\s*:\s*(.*)", self.header, re.I) @@ -52,9 +54,10 @@ class StreamcloudEu(XFileSharingPro): def getPostParameters(self): for i in range(3): - if not self.errmsg: self.checkErrors() + if not self.errmsg: + self.checkErrors() - if hasattr(self,"FORM_PATTERN"): + if hasattr(self, "FORM_PATTERN"): action, inputs = self.parseHtmlForm(self.FORM_PATTERN) else: action, inputs = self.parseHtmlForm(input_names={"op": re.compile("^download")}) @@ -86,7 +89,8 @@ class StreamcloudEu(XFileSharingPro): self.captcha = self.handleCaptcha(inputs) - if wait_time: self.wait() + if wait_time: + self.wait() self.errmsg = None self.logDebug("getPostParameters {0}".format(i)) @@ -97,15 +101,18 @@ class StreamcloudEu(XFileSharingPro): if self.premium: inputs['method_premium'] = "Premium Download" - if 'method_free' in inputs: del inputs['method_free'] + if 'method_free' in inputs: + del inputs['method_free'] else: inputs['method_free'] = "Free Download" - if 'method_premium' in inputs: del inputs['method_premium'] + if 'method_premium' in inputs: + del inputs['method_premium'] - self.html = self.load(self.pyfile.url, post = inputs, ref = False) + self.html = self.load(self.pyfile.url, post=inputs, ref=False) self.errmsg = None - else: self.parseError('FORM: %s' % (inputs['op'] if 'op' in inputs else 'UNKNOWN')) + else: + self.parseError('FORM: %s' % (inputs['op'] if 'op' in inputs else 'UNKNOWN')) getInfo = create_getInfo(StreamcloudEu) diff --git a/module/plugins/hoster/TurbobitNet.py b/module/plugins/hoster/TurbobitNet.py index 4e7eb81c2..5fe42bba7 100644 --- a/module/plugins/hoster/TurbobitNet.py +++ b/module/plugins/hoster/TurbobitNet.py @@ -23,14 +23,14 @@ import re import random from urllib import quote from binascii import hexlify, unhexlify -from Crypto.Cipher import ARC4 import time +from pycurl import HTTPHEADER +from Crypto.Cipher import ARC4 from module.network.RequestFactory import getURL from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, timestamp from module.plugins.internal.CaptchaService import ReCaptcha -from pycurl import HTTPHEADER class TurbobitNet(SimpleHoster): __name__ = "TurbobitNet" @@ -41,10 +41,12 @@ class TurbobitNet(SimpleHoster): __author_name__ = ("zoidberg") __author_mail__ = ("zoidberg@mujmail.cz") - FILE_INFO_PATTERN = r"\w+).*", "http://turbobit.net/\g.html")] + FILE_URL_REPLACEMENTS = [(r"http://(?:\w*\.)?(turbobit.net|unextfiles.com)/(?:download/free/)?(?P\w+).*", + "http://turbobit.net/\g.html")] SH_COOKIES = [("turbobit.net", "user_lang", "en")] CAPTCHA_KEY_PATTERN = r'src="http://api\.recaptcha\.net/challenge\?k=([^"]+)"' @@ -59,7 +61,7 @@ class TurbobitNet(SimpleHoster): rtUpdate = self.getRtUpdate() self.solveCaptcha() - self.req.http.c.setopt(HTTPHEADER, ["X-Requested-With: XMLHttpRequest"]) + self.req.http.c.setopt(HTTPHEADER, ["X-Requested-With: XMLHttpRequest"]) self.url = self.getDownloadUrl(rtUpdate) self.wait() @@ -67,7 +69,7 @@ class TurbobitNet(SimpleHoster): self.req.http.c.setopt(HTTPHEADER, ["X-Requested-With:"]) self.downloadFile() - def solveCaptcha(self): + def solveCaptcha(self): for i in range(5): found = re.search(self.LIMIT_WAIT_PATTERN, self.html) if found: @@ -77,41 +79,47 @@ class TurbobitNet(SimpleHoster): self.retry() action, inputs = self.parseHtmlForm("action='#'") - if not inputs: self.parseError("captcha form") + if not inputs: + self.parseError("captcha form") self.logDebug(inputs) if inputs['captcha_type'] == 'recaptcha': recaptcha = ReCaptcha(self) found = re.search(self.CAPTCHA_KEY_PATTERN, self.html) captcha_key = found.group(1) if found else '6LcTGLoSAAAAAHCWY9TTIrQfjUlxu6kZlTYP50_c' - inputs['recaptcha_challenge_field'], inputs['recaptcha_response_field'] = recaptcha.challenge(captcha_key) + inputs['recaptcha_challenge_field'], inputs['recaptcha_response_field'] = recaptcha.challenge( + captcha_key) else: found = re.search(self.CAPTCHA_SRC_PATTERN, self.html) - if not found: self.parseError('captcha') + if not found: + self.parseError('captcha') captcha_url = found.group(1) inputs['captcha_response'] = self.decryptCaptcha(captcha_url) self.logDebug(inputs) - self.html = self.load(self.url, post = inputs) + self.html = self.load(self.url, post=inputs) if not "
    " in self.html: self.invalidCaptcha() else: self.correctCaptcha() break - else: self.fail("Invalid captcha") + else: + self.fail("Invalid captcha") def getRtUpdate(self): rtUpdate = self.getStorage("rtUpdate") if not rtUpdate: - if self.getStorage("version") != self.__version__ or int(self.getStorage("timestamp", 0)) + 86400000 < timestamp(): + if self.getStorage("version") != self.__version__ or int( + self.getStorage("timestamp", 0)) + 86400000 < timestamp(): # that's right, we are even using jdownloader updates rtUpdate = getURL("http://update0.jdownloader.org/pluginstuff/tbupdate.js") rtUpdate = self.decrypt(rtUpdate.splitlines()[1]) # but we still need to fix the syntax to work with other engines than rhino - rtUpdate = re.sub(r'for each\(var (\w+) in(\[[^\]]+\])\)\{',r'zza=\2;for(var zzi=0;zzi]+)", self.html) - url = "http://turbobit.net%s%s" % (found.groups() if found else ('/files/timeout.js?ver=', ''.join(random.choice('0123456789ABCDEF') for x in range(32)))) + url = "http://turbobit.net%s%s" % (found.groups() if found else ( + '/files/timeout.js?ver=', ''.join(random.choice('0123456789ABCDEF') for x in range(32)))) fun = self.load(url) self.setWait(65, False) - for b in [1,3]: - self.jscode = "var id = \'%s\';var b = %d;var inn = \'%s\';%sout" % (self.file_info['ID'], b, quote(fun), rtUpdate) - + for b in [1, 3]: + self.jscode = "var id = \'%s\';var b = %d;var inn = \'%s\';%sout" % ( + self.file_info['ID'], b, quote(fun), rtUpdate) + try: out = self.js.eval(self.jscode) self.logDebug("URL", self.js.engine, out) @@ -150,11 +160,11 @@ class TurbobitNet(SimpleHoster): def decrypt(self, data): cipher = ARC4.new(hexlify('E\x15\xa1\x9e\xa3M\xa0\xc6\xa0\x84\xb6H\x83\xa8o\xa0')) return unhexlify(cipher.encrypt(unhexlify(data))) - + def getLocalTimeString(self): lt = time.localtime() - tz = time.altzone if lt.tm_isdst else time.timezone - return "%s GMT%+03d%02d" % (time.strftime("%a %b %d %Y %H:%M:%S", lt), -tz // 3600, tz % 3600) + tz = time.altzone if lt.tm_isdst else time.timezone + return "%s GMT%+03d%02d" % (time.strftime("%a %b %d %Y %H:%M:%S", lt), -tz // 3600, tz % 3600) def handlePremium(self): self.logDebug("Premium download as user %s" % self.user) @@ -162,9 +172,11 @@ class TurbobitNet(SimpleHoster): def downloadFile(self): found = re.search(self.DOWNLOAD_URL_PATTERN, self.html) - if not found: self.parseError("download link") + if not found: + self.parseError("download link") self.url = "http://turbobit.net" + found.group('url') self.logDebug(self.url) self.download(self.url) + getInfo = create_getInfo(TurbobitNet) diff --git a/module/plugins/hoster/TurbouploadCom.py b/module/plugins/hoster/TurbouploadCom.py index 6e81c6319..12dad7906 100644 --- a/module/plugins/hoster/TurbouploadCom.py +++ b/module/plugins/hoster/TurbouploadCom.py @@ -18,8 +18,7 @@ import re from module.plugins.internal.DeadHoster import DeadHoster as EasybytezCom, create_getInfo -#from module.plugins.internal.SimpleHoster import create_getInfo -#from module.plugins.hoster.EasybytezCom import EasybytezCom + class TurbouploadCom(EasybytezCom): __name__ = "TurbouploadCom" @@ -29,17 +28,19 @@ class TurbouploadCom(EasybytezCom): __description__ = """turboupload.com""" __author_name__ = ("zoidberg") __author_mail__ = ("zoidberg@mujmail.cz") - + # shares code with EasybytezCom - + DIRECT_LINK_PATTERN = r'\1' def handleFree(self): - self.html = self.load(self.pyfile.url, post = self.getPostParameters(), ref = True, cookies = True) + self.html = self.load(self.pyfile.url, post=self.getPostParameters(), ref=True, cookies=True) found = re.search(self.DIRECT_LINK_PATTERN, self.html) - if not found: self.parseError('Download Link') + if not found: + self.parseError('Download Link') url = found.group(1) self.logDebug('URL: ' + url) self.download(url) -getInfo = create_getInfo(TurbouploadCom) \ No newline at end of file + +getInfo = create_getInfo(TurbouploadCom) diff --git a/module/plugins/hoster/TusfilesNet.py b/module/plugins/hoster/TusfilesNet.py index 517df8561..a155439b2 100644 --- a/module/plugins/hoster/TusfilesNet.py +++ b/module/plugins/hoster/TusfilesNet.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo + class TusfilesNet(XFileSharingPro): __name__ = "TusfilesNet" __type__ = "hoster" @@ -15,4 +16,5 @@ class TusfilesNet(XFileSharingPro): HOSTER_NAME = "tusfiles.net" + getInfo = create_getInfo(TusfilesNet) diff --git a/module/plugins/hoster/TwoSharedCom.py b/module/plugins/hoster/TwoSharedCom.py index 8401e0cb0..5d1cd835b 100644 --- a/module/plugins/hoster/TwoSharedCom.py +++ b/module/plugins/hoster/TwoSharedCom.py @@ -1,9 +1,11 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo import re +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo + + class TwoSharedCom(SimpleHoster): __name__ = "TwoSharedCom" __type__ = "hoster" @@ -17,17 +19,18 @@ class TwoSharedCom(SimpleHoster): FILE_SIZE_PATTERN = r'File size:\s*(?P[0-9,.]+) (?P[kKMG])i?B' FILE_OFFLINE_PATTERN = r'The file link that you requested is not valid\.|This file was deleted\.' DOWNLOAD_URL_PATTERN = r"window.location ='([^']+)';" - + def setup(self): self.resumeDownload = self.multiDL = True - def handleFree(self): + def handleFree(self): found = re.search(self.DOWNLOAD_URL_PATTERN, self.html) - if not found: self.parseError('Download link') + if not found: + self.parseError('Download link') link = found.group(1) self.logDebug("Download URL %s" % link) - + self.download(link) + getInfo = create_getInfo(TwoSharedCom) - \ No newline at end of file diff --git a/module/plugins/hoster/UlozTo.py b/module/plugins/hoster/UlozTo.py index 1c3891eb1..fe0bc671e 100644 --- a/module/plugins/hoster/UlozTo.py +++ b/module/plugins/hoster/UlozTo.py @@ -19,9 +19,11 @@ import re from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo + def convertDecimalPrefix(m): # decimal prefixes used in filesize and traffic - return ("%%.%df" % {'k':3,'M':6,'G':9}[m.group(2)] % float(m.group(1))).replace('.','') + return ("%%.%df" % {'k': 3, 'M': 6, 'G': 9}[m.group(2)] % float(m.group(1))).replace('.', '') + class UlozTo(SimpleHoster): __name__ = "UlozTo" @@ -44,20 +46,20 @@ class UlozTo(SimpleHoster): PREMIUM_URL_PATTERN = r'
    \s*
  • Error rewriting the text.
  • '), "offline": re.compile(self.FILE_OFFLINE_PATTERN), "passwd": self.PASSWD_PATTERN, - "server_error": 'src="http://img.ulozto.cz/error403/vykricnik.jpg"', #paralell dl, server overload etc. + "server_error": 'src="http://img.ulozto.cz/error403/vykricnik.jpg"', # paralell dl, server overload etc. "not_found": "Ulož.to" }) @@ -153,4 +154,5 @@ class UlozTo(SimpleHoster): elif check == "not_found": self.fail("Server error - file not downloadable") + getInfo = create_getInfo(UlozTo) diff --git a/module/plugins/hoster/UloziskoSk.py b/module/plugins/hoster/UloziskoSk.py index c607e7a5b..7060dff65 100644 --- a/module/plugins/hoster/UloziskoSk.py +++ b/module/plugins/hoster/UloziskoSk.py @@ -19,6 +19,7 @@ import re from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, PluginParseError + class UloziskoSk(SimpleHoster): __name__ = "UloziskoSk" __type__ = "hoster" @@ -38,7 +39,7 @@ class UloziskoSk(SimpleHoster): def process(self, pyfile): self.html = self.load(pyfile.url, decode=True) self.getFileInfo() - + found = re.search(self.IMG_PATTERN, self.html) if found: url = "http://ulozisko.sk" + found.group(1) @@ -48,17 +49,20 @@ class UloziskoSk(SimpleHoster): def handleFree(self): found = re.search(self.URL_PATTERN, self.html) - if found is None: raise PluginParseError('URL') + if found is None: + raise PluginParseError('URL') parsed_url = 'http://www.ulozisko.sk' + found.group(1) found = re.search(self.ID_PATTERN, self.html) - if found is None: raise PluginParseError('ID') + if found is None: + raise PluginParseError('ID') id = found.group(1) self.logDebug('URL:' + parsed_url + ' ID:' + id) found = re.search(self.CAPTCHA_PATTERN, self.html) - if found is None: raise PluginParseError('CAPTCHA') + if found is None: + raise PluginParseError('CAPTCHA') captcha_url = 'http://www.ulozisko.sk' + found.group(1) captcha = self.decryptCaptcha(captcha_url, cookies=True) @@ -72,4 +76,5 @@ class UloziskoSk(SimpleHoster): "but": "++++STIAHNI+S%DABOR++++" }) + getInfo = create_getInfo(UloziskoSk) diff --git a/module/plugins/hoster/UnibytesCom.py b/module/plugins/hoster/UnibytesCom.py index 3c8552271..d13f01ef3 100644 --- a/module/plugins/hoster/UnibytesCom.py +++ b/module/plugins/hoster/UnibytesCom.py @@ -20,6 +20,7 @@ import re from pycurl import FOLLOWLOCATION from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo + class UnibytesCom(SimpleHoster): __name__ = "UnibytesCom" __type__ = "hoster" @@ -30,28 +31,28 @@ class UnibytesCom(SimpleHoster): FILE_INFO_PATTERN = r']*?id="fileName"[^>]*>(?P[^>]+)\s*\((?P\d.*?)\)' DOMAIN = 'http://www.unibytes.com' - + WAIT_PATTERN = r'Wait for (\d+) sec' DOWNLOAD_LINK_PATTERN = r'Download' def handleFree(self): - action, post_data = self.parseHtmlForm('id="startForm"') + action, post_data = self.parseHtmlForm('id="startForm"') self.req.http.c.setopt(FOLLOWLOCATION, 0) - + for i in range(8): self.logDebug(action, post_data) - self.html = self.load(self.DOMAIN + action, post = post_data) - + self.html = self.load(self.DOMAIN + action, post=post_data) + found = re.search(r'location:\s*(\S+)', self.req.http.header, re.I) if found: url = found.group(1) break - - if '>Somebody else is already downloading using your IP-address<' in self.html: + + if '>Somebody else is already downloading using your IP-address<' in self.html: self.setWait(600, True) self.wait() self.retry() - + if post_data['step'] == 'last': found = re.search(self.DOWNLOAD_LINK_PATTERN, self.html) if found: @@ -60,21 +61,22 @@ class UnibytesCom(SimpleHoster): break else: self.invalidCaptcha() - - last_step = post_data['step'] + + last_step = post_data['step'] action, post_data = self.parseHtmlForm('id="stepForm"') - - if last_step == 'timer': + + if last_step == 'timer': found = re.search(self.WAIT_PATTERN, self.html) self.setWait(int(found.group(1)) if found else 60, False) - self.wait() + self.wait() elif last_step in ('captcha', 'last'): post_data['captcha'] = self.decryptCaptcha(self.DOMAIN + '/captcha.jpg') else: - self.fail("No valid captcha code entered") - + self.fail("No valid captcha code entered") + self.logDebug('Download link: ' + url) - self.req.http.c.setopt(FOLLOWLOCATION, 1) - self.download(url) + self.req.http.c.setopt(FOLLOWLOCATION, 1) + self.download(url) + -getInfo = create_getInfo(UnibytesCom) \ No newline at end of file +getInfo = create_getInfo(UnibytesCom) diff --git a/module/plugins/hoster/UploadStationCom.py b/module/plugins/hoster/UploadStationCom.py index 96dc7b577..2831facac 100644 --- a/module/plugins/hoster/UploadStationCom.py +++ b/module/plugins/hoster/UploadStationCom.py @@ -2,6 +2,7 @@ from module.plugins.hoster.FileserveCom import FileserveCom, checkFile from module.plugins.Plugin import chunks + class UploadStationCom(FileserveCom): __name__ = "UploadStationCom" __type__ = "hoster" @@ -10,12 +11,15 @@ class UploadStationCom(FileserveCom): __description__ = """UploadStation.Com File Download Hoster""" __author_name__ = ("fragonib", "zoidberg") __author_mail__ = ("fragonib[AT]yahoo[DOT]es", "zoidberg@mujmail.cz") - - URLS = ['http://www.uploadstation.com/file/', 'http://www.uploadstation.com/check-links.php', 'http://www.uploadstation.com/checkReCaptcha.php'] + + URLS = ['http://www.uploadstation.com/file/', 'http://www.uploadstation.com/check-links.php', + 'http://www.uploadstation.com/checkReCaptcha.php'] LINKCHECK_TR = r'
    (.*?)\t{9}
    ' LINKCHECK_TD = r'
    (?:<[^>]*>| )*([^<]*)' - + LONG_WAIT_PATTERN = r'

    You have to wait (\d+) (\w+) to download the next file\.

    ' - + + def getInfo(urls): - for chunk in chunks(urls, 100): yield checkFile(UploadStationCom, chunk) \ No newline at end of file + for chunk in chunks(urls, 100): + yield checkFile(UploadStationCom, chunk) diff --git a/module/plugins/hoster/UploadedTo.py b/module/plugins/hoster/UploadedTo.py index f38336773..6ac3320c0 100644 --- a/module/plugins/hoster/UploadedTo.py +++ b/module/plugins/hoster/UploadedTo.py @@ -52,7 +52,8 @@ def getAPIData(urls): def parseFileInfo(self, url='', html=''): - if not html and hasattr(self, "html"): html = self.html + if not html and hasattr(self, "html"): + html = self.html name, size, status, found, fileid = url, 0, 3, None, None if re.search(self.FILE_OFFLINE_PATTERN, html): @@ -91,7 +92,8 @@ class UploadedTo(Hoster): __version__ = "0.71" __description__ = """Uploaded.net Download Hoster""" __author_name__ = ("spoob", "mkaay", "zoidberg", "netpok", "stickell") - __author_mail__ = ("spoob@pyload.org", "mkaay@mkaay.de", "zoidberg@mujmail.cz", "netpok@gmail.com", "l.stickell@yahoo.it") + __author_mail__ = ("spoob@pyload.org", "mkaay@mkaay.de", "zoidberg@mujmail.cz", + "netpok@gmail.com", "l.stickell@yahoo.it") FILE_INFO_PATTERN = r'(?P[^<]+)  \s*]*>(?P[^<]+)' FILE_OFFLINE_PATTERN = r'Error: 404' @@ -151,11 +153,10 @@ class UploadedTo(Hoster): else: self.handleFree() - def handlePremium(self): info = self.account.getAccountInfo(self.user, True) self.logDebug("%(name)s: Use Premium Account (%(left)sGB left)" % {"name": self.__name__, - "left": info["trafficleft"] / 1024 / 1024}) + "left": info["trafficleft"] / 1024 / 1024}) if int(self.data[1]) / 1024 > info["trafficleft"]: self.logInfo(_("%s: Not enough traffic left" % self.__name__)) self.account.empty(self.user) diff --git a/module/plugins/hoster/UploadheroCom.py b/module/plugins/hoster/UploadheroCom.py index 65d6cc4e9..79bca748e 100644 --- a/module/plugins/hoster/UploadheroCom.py +++ b/module/plugins/hoster/UploadheroCom.py @@ -22,6 +22,7 @@ import re from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo + class UploadheroCom(SimpleHoster): __name__ = "UploadheroCom" __type__ = "hoster" @@ -35,26 +36,27 @@ class UploadheroCom(SimpleHoster): FILE_NAME_PATTERN = r'
    (?P.*?)
    ' FILE_SIZE_PATTERN = r'Taille du fichier : (?P.*?)' FILE_OFFLINE_PATTERN = r'

    |

    Le lien du fichier ci-dessus n\'existe plus.' - + DOWNLOAD_URL_PATTERN = r'(\d+).*\s*(\d+)' CAPTCHA_PATTERN = r'"(/captchadl\.php\?[a-z0-9]+)"' FREE_URL_PATTERN = r'var magicomfg = \'"/]+)"' - + def handleFree(self): - self.checkErrors() - + self.checkErrors() + found = re.search(self.CAPTCHA_PATTERN, self.html) - if not found: self.parseError("Captcha URL") + if not found: + self.parseError("Captcha URL") captcha_url = "http://uploadhero.com" + found.group(1) - + for i in range(5): - captcha = self.decryptCaptcha(captcha_url) - self.html = self.load(self.pyfile.url, get = {"code": captcha}) - found = re.search(self.FREE_URL_PATTERN, self.html) + captcha = self.decryptCaptcha(captcha_url) + self.html = self.load(self.pyfile.url, get={"code": captcha}) + found = re.search(self.FREE_URL_PATTERN, self.html) if found: self.correctCaptcha() download_url = found.group(1) or found.group(2) @@ -62,26 +64,27 @@ class UploadheroCom(SimpleHoster): else: self.invalidCaptcha() else: - self.fail("No valid captcha code entered") - + self.fail("No valid captcha code entered") + self.download(download_url) - + def handlePremium(self): self.logDebug("%s: Use Premium Account" % self.__name__) self.html = self.load(self.pyfile.url) link = re.search(self.DOWNLOAD_URL_PATTERN, self.html).group(1) self.logDebug("Downloading link : '%s'" % link) - self.download(link) - + self.download(link) + def checkErrors(self): found = re.search(self.IP_BLOCKED_PATTERN, self.html) if found: self.html = self.load("http://uploadhero.com%s" % found.group(1)) - + found = re.search(self.IP_WAIT_PATTERN, self.html) wait_time = (int(found.group(1)) * 60 + int(found.group(2))) if found else 300 self.setWait(wait_time, True) self.wait() self.retry() - + + getInfo = create_getInfo(UploadheroCom) diff --git a/module/plugins/hoster/UploadingCom.py b/module/plugins/hoster/UploadingCom.py index a98c3bf71..1da571460 100644 --- a/module/plugins/hoster/UploadingCom.py +++ b/module/plugins/hoster/UploadingCom.py @@ -22,6 +22,7 @@ from pycurl import HTTPHEADER from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, timestamp from module.common.json_layer import json_loads + class UploadingCom(SimpleHoster): __name__ = "UploadingCom" __type__ = "hoster" @@ -30,29 +31,29 @@ class UploadingCom(SimpleHoster): __description__ = """Uploading.Com File Download Hoster""" __author_name__ = ("jeix", "mkaay", "zoidberg") __author_mail__ = ("jeix@hasnomail.de", "mkaay@mkaay.de", "zoidberg@mujmail.cz") - + FILE_NAME_PATTERN = r'Download (?P<N>.*?) for free on uploading.com' FILE_SIZE_PATTERN = r'File size: (?P.*?)' FILE_OFFLINE_PATTERN = r'The requested file is not found' - + def process(self, pyfile): # set lang to english self.req.cj.setCookie("uploading.com", "lang", "1") self.req.cj.setCookie("uploading.com", "language", "1") self.req.cj.setCookie("uploading.com", "setlang", "en") self.req.cj.setCookie("uploading.com", "_lang", "en") - + if not "/get/" in self.pyfile.url: self.pyfile.url = self.pyfile.url.replace("/files", "/files/get") - - self.html = self.load(pyfile.url, decode = True) + + self.html = self.load(pyfile.url, decode=True) self.file_info = self.getFileInfo() - + if self.premium: self.handlePremium() else: - self.handleFree() - + self.handleFree() + def handlePremium(self): postData = {'action': 'get_link', 'code': self.file_info['ID'], @@ -63,21 +64,21 @@ class UploadingCom(SimpleHoster): if url: url = url.group(1).replace("\\/", "/") self.download(url) - + raise Exception("Plugin defect.") - + def handleFree(self): found = re.search('

    ((Daily )?Download Limit)

    ', self.html) if found: self.pyfile.error = found.group(1) self.logWarning(self.pyfile.error) - self.retry(max_tries=6, wait_time = 21600 if found.group(2) else 900, reason = self.pyfile.error) - + self.retry(max_tries=6, wait_time=21600 if found.group(2) else 900, reason=self.pyfile.error) + ajax_url = "http://uploading.com/files/get/?ajax" self.req.http.c.setopt(HTTPHEADER, ["X-Requested-With: XMLHttpRequest"]) self.req.http.lastURL = self.pyfile.url - - response = json_loads(self.load(ajax_url, post = {'action': 'second_page', 'code': self.file_info['ID']})) + + response = json_loads(self.load(ajax_url, post={'action': 'second_page', 'code': self.file_info['ID']})) if 'answer' in response and 'wait_time' in response['answer']: wait_time = int(response['answer']['wait_time']) self.logInfo("%s: Waiting %d seconds." % (self.__name__, wait_time)) @@ -85,26 +86,28 @@ class UploadingCom(SimpleHoster): self.wait() else: self.pluginParseError("AJAX/WAIT") - - response = json_loads(self.load(ajax_url, post = {'action': 'get_link', 'code': self.file_info['ID'], 'pass': 'false'})) + + response = json_loads( + self.load(ajax_url, post={'action': 'get_link', 'code': self.file_info['ID'], 'pass': 'false'})) if 'answer' in response and 'link' in response['answer']: url = response['answer']['link'] else: self.pluginParseError("AJAX/URL") - + self.html = self.load(url) found = re.search(r'\s*Download File\s*]*>(?P[^>]+)\s*[^\(]*\((?P[^\)]+)\)' FILE_OFFLINE_PATTERN = r'
    File Not Found
    ' HOSTER_NAME = "uptobox.com" - + def setup(self): - self.resumeDownload = self.multiDL = self.premium + self.resumeDownload = self.multiDL = self.premium self.chunkLimit = 1 -getInfo = create_getInfo(UptoboxCom) \ No newline at end of file + +getInfo = create_getInfo(UptoboxCom) diff --git a/module/plugins/hoster/VeehdCom.py b/module/plugins/hoster/VeehdCom.py index 4486eb84a..88bcb20ad 100644 --- a/module/plugins/hoster/VeehdCom.py +++ b/module/plugins/hoster/VeehdCom.py @@ -3,6 +3,7 @@ import re from module.plugins.Hoster import Hoster + class VeehdCom(Hoster): __name__ = 'VeehdCom' __type__ = 'hoster' @@ -11,14 +12,14 @@ class VeehdCom(Hoster): ('filename_spaces', 'bool', "Allow spaces in filename", 'False'), ('replacement_char', 'str', "Filename replacement character", '_'), ] - __version__ = '0.22' + __version__ = '0.23' __description__ = """Veehd.com Download Hoster""" __author_name__ = ('cat') __author_mail__ = ('cat@pyload') - + def _debug(self, msg): self.logDebug('[%s] %s' % (self.__name__, msg)) - + def setup(self): self.html = None self.multiDL = True @@ -28,51 +29,50 @@ class VeehdCom(Hoster): self.download_html() if not self.file_exists(): self.offline() - + pyfile.name = self.get_file_name() self.download(self.get_file_url()) - + def download_html(self): url = self.pyfile.url self._debug("Requesting page: %s" % (repr(url),)) self.html = self.load(url) - + def file_exists(self): if self.html is None: self.download_html() - + if 'Veehd' in self.html: return False return True - + def get_file_name(self): if self.html is None: self.download_html() - + match = re.search(r']*>([^<]+) on Veehd', self.html) if not match: self.fail("video title not found") name = match.group(1) - + # replace unwanted characters in filename if self.getConfig('filename_spaces'): pattern = '[^0-9A-Za-z\.\ ]+' else: pattern = '[^0-9A-Za-z\.]+' - + name = re.sub(pattern, self.getConfig('replacement_char'), - name) + name) return name + '.avi' def get_file_url(self): """ returns the absolute downloadable filepath - """ + """ if self.html is None: self.download_html() - match = re.search(r'(?P[^<]+)' FILE_SIZE_PATTERN = r'
  • Velikost: (?P[^<]+)' FILE_OFFLINE_PATTERN = r'

    Soubor nenalezen

    ' - + PREMIUM_URL_PATTERN = r'href="(http://[^/]+/dwn-premium.php.*?)"' DOMAIN = "http://csd01.coolshare.cz" - - DOMAIN = "http://s01.warserver.cz" - + + DOMAIN = "http://s01.warserver.cz" + def handleFree(self): - try: - self.download("%s/dwn-free.php?fid=%s" % (self.DOMAIN, self.file_info['ID'])) + try: + self.download("%s/dwn-free.php?fid=%s" % (self.DOMAIN, self.file_info['ID'])) except BadHeader, e: self.logError(e) if e.code == 403: - self.longWait(60,60) - else: raise + self.longWait(60, 60) + else: + raise self.checkDownloadedFile() - + def handlePremium(self): found = re.search(self.PREMIUM_URL_PATTERN, self.html) - if not found: self.parseError("Premium URL") + if not found: + self.parseError("Premium URL") url = html_unescape(found.group(1)) - self.logDebug("Premium URL: " + url) - if not url.startswith("http://"): self.resetAccount() + self.logDebug("Premium URL: " + url) + if not url.startswith("http://"): + self.resetAccount() self.download(url) - self.checkDownloadedFile() - + self.checkDownloadedFile() + def checkDownloadedFile(self): check = self.checkDownload({ "offline": ">404 Not Found<" - }) + }) if check == "offline": - self.offline() + self.offline() + -getInfo = create_getInfo(WarserverCz) \ No newline at end of file +getInfo = create_getInfo(WarserverCz) diff --git a/module/plugins/hoster/WebshareCz.py b/module/plugins/hoster/WebshareCz.py index 195e65a93..10a8078c5 100644 --- a/module/plugins/hoster/WebshareCz.py +++ b/module/plugins/hoster/WebshareCz.py @@ -18,7 +18,7 @@ import re from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo -from module.network.HTTPRequest import BadHeader + class WebshareCz(SimpleHoster): __name__ = "WebshareCz" @@ -31,18 +31,19 @@ class WebshareCz(SimpleHoster): FILE_NAME_PATTERN = r'

    Stahujete soubor:

    \s*
    (?P[^<]+)
    ' FILE_SIZE_PATTERN = r'

    Velikost souboru je:

    \s*
    (?P[^<]+)
    ' FILE_OFFLINE_PATTERN = r'

    Soubor ".*?" nebyl nalezen.

    ' - + DOWNLOAD_LINK_PATTERN = r'id="download_link" href="(?P.*?)"' - + def setup(self): self.multiDL = True def handleFree(self): url_a = re.search(r"(var l.*)", self.html).group(1) - url_b = re.search(r"(var keyStr.*)", self.html).group(1) + url_b = re.search(r"(var keyStr.*)", self.html).group(1) url = self.js.eval("%s\n%s\ndec(l)" % (url_a, url_b)) - + self.logDebug('Download link: ' + url) - self.download(url) + self.download(url) + -getInfo = create_getInfo(WebshareCz) \ No newline at end of file +getInfo = create_getInfo(WebshareCz) diff --git a/module/plugins/hoster/WrzucTo.py b/module/plugins/hoster/WrzucTo.py index 4a5e89f22..861e7f11e 100644 --- a/module/plugins/hoster/WrzucTo.py +++ b/module/plugins/hoster/WrzucTo.py @@ -17,9 +17,11 @@ """ import re -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo from pycurl import HTTPHEADER +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo + + class WrzucTo(SimpleHoster): __name__ = "WrzucTo" __type__ = "hoster" @@ -29,30 +31,32 @@ class WrzucTo(SimpleHoster): __author_name__ = ("zoidberg") __author_mail__ = ("zoidberg@mujmail.cz") - SH_COOKIES = [("http://www.wrzuc.to", "language", "en")] + SH_COOKIES = [("http://www.wrzuc.to", "language", "en")] FILE_SIZE_PATTERN = r'class="info">\s*\s*(?P.*?)' FILE_NAME_PATTERN = r'id="file_info">\s*(?P.*?)' - + def setup(self): - self.multiDL = True - + self.multiDL = True + def handleFree(self): data = dict(re.findall(r'(md5|file): "(.*?)"', self.html)) - if len(data) != 2: self.parseError('File ID') - + if len(data) != 2: + self.parseError('File ID') + self.req.http.c.setopt(HTTPHEADER, ["X-Requested-With: XMLHttpRequest"]) self.req.http.lastURL = self.pyfile.url - self.load("http://www.wrzuc.to/ajax/server/prepair", post = {"md5": data['md5']}) - + self.load("http://www.wrzuc.to/ajax/server/prepair", post={"md5": data['md5']}) + self.req.http.lastURL = self.pyfile.url - self.html = self.load("http://www.wrzuc.to/ajax/server/download_link", post = {"file": data['file']}) - + self.html = self.load("http://www.wrzuc.to/ajax/server/download_link", post={"file": data['file']}) + data.update(re.findall(r'"(download_link|server_id)":"(.*?)"', self.html)) - if len(data) != 4: self.parseError('Download URL') - - download_url = "http://%s.wrzuc.to/pobierz/%s" % (data['server_id'], data['download_link']) - self.logDebug("Download URL: %s" % download_url) + if len(data) != 4: + self.parseError('Download URL') + + download_url = "http://%s.wrzuc.to/pobierz/%s" % (data['server_id'], data['download_link']) + self.logDebug("Download URL: %s" % download_url) self.download(download_url) - -getInfo = create_getInfo(WrzucTo) + +getInfo = create_getInfo(WrzucTo) diff --git a/module/plugins/hoster/X7To.py b/module/plugins/hoster/X7To.py index 965d84543..24d1643f3 100644 --- a/module/plugins/hoster/X7To.py +++ b/module/plugins/hoster/X7To.py @@ -3,7 +3,6 @@ import re from module.plugins.Hoster import Hoster -from module.network.RequestFactory import getURL def getInfo(urls): yield [(url, 0, 1, url) for url in urls] @@ -17,8 +16,8 @@ class X7To(Hoster): __description__ = """X7.To File Download Hoster""" __author_name__ = ("ernieb") __author_mail__ = ("ernieb") - - FILE_INFO_PATTERN=r'"," ",self.errmsg)) + self.logWarning(re.sub(r"<.*?>", " ", self.errmsg)) if 'wait' in self.errmsg: - wait_time = sum([int(v) * {"hour": 3600, "minute": 60, "second": 1}[u] for v, u in re.findall('(\d+)\s*(hour|minute|second)?', self.errmsg)]) + wait_time = sum([int(v) * {"hour": 3600, "minute": 60, "second": 1}[u] for v, u in + re.findall('(\d+)\s*(hour|minute|second)?', self.errmsg)]) self.setWait(wait_time, True) self.wait() elif 'captcha' in self.errmsg: @@ -229,9 +235,10 @@ class XFileSharingPro(SimpleHoster): def getPostParameters(self): for i in range(3): - if not self.errmsg: self.checkErrors() + if not self.errmsg: + self.checkErrors() - if hasattr(self,"FORM_PATTERN"): + if hasattr(self, "FORM_PATTERN"): action, inputs = self.parseHtmlForm(self.FORM_PATTERN) else: action, inputs = self.parseHtmlForm(input_names={"op": re.compile("^download")}) @@ -263,7 +270,8 @@ class XFileSharingPro(SimpleHoster): self.captcha = self.handleCaptcha(inputs) - if wait_time: self.wait() + if wait_time: + self.wait() self.errmsg = None return inputs @@ -273,15 +281,18 @@ class XFileSharingPro(SimpleHoster): if self.premium: inputs['method_premium'] = "Premium Download" - if 'method_free' in inputs: del inputs['method_free'] + if 'method_free' in inputs: + del inputs['method_free'] else: inputs['method_free'] = "Free Download" - if 'method_premium' in inputs: del inputs['method_premium'] + if 'method_premium' in inputs: + del inputs['method_premium'] - self.html = self.load(self.pyfile.url, post = inputs, ref = True) + self.html = self.load(self.pyfile.url, post=inputs, ref=True) self.errmsg = None - else: self.parseError('FORM: %s' % (inputs['op'] if 'op' in inputs else 'UNKNOWN')) + else: + self.parseError('FORM: %s' % (inputs['op'] if 'op' in inputs else 'UNKNOWN')) def handleCaptcha(self, inputs): found = re.search(self.RECAPTCHA_URL_PATTERN, self.html) @@ -303,7 +314,7 @@ class XFileSharingPro(SimpleHoster): captcha_div = found.group(1) self.logDebug(captcha_div) numerals = re.findall('(\d)', html_unescape(captcha_div)) - inputs['code'] = "".join([a[1] for a in sorted(numerals, key = lambda num: int(num[0]))]) + inputs['code'] = "".join([a[1] for a in sorted(numerals, key=lambda num: int(num[0]))]) self.logDebug("CAPTCHA", inputs['code'], numerals) return 3 else: @@ -315,4 +326,5 @@ class XFileSharingPro(SimpleHoster): return 4 return 0 + getInfo = create_getInfo(XFileSharingPro) diff --git a/module/plugins/hoster/XHamsterCom.py b/module/plugins/hoster/XHamsterCom.py index 866c5da45..cbdd818c7 100644 --- a/module/plugins/hoster/XHamsterCom.py +++ b/module/plugins/hoster/XHamsterCom.py @@ -2,17 +2,20 @@ # -*- coding: utf-8 -*- import re -from module.plugins.Hoster import Hoster from urllib import unquote + +from module.plugins.Hoster import Hoster from module.common.json_layer import json_loads + def clean_json(json_expr): json_expr = re.sub('[\n\r]', '', json_expr) json_expr = re.sub(' +', '', json_expr) - json_expr = re.sub('\'','"', json_expr) + json_expr = re.sub('\'', '"', json_expr) return json_expr - + + class XHamsterCom(Hoster): __name__ = "XHamsterCom" __type__ = "hoster" @@ -23,16 +26,16 @@ class XHamsterCom(Hoster): def setup(self): self.html = None - + def process(self, pyfile): self.pyfile = pyfile - + if not self.file_exists(): self.offline() if self.getConfig("type"): - self.desired_fmt = self.getConfig("type") - + self.desired_fmt = self.getConfig("type") + self.pyfile.name = self.get_file_name() + self.desired_fmt self.download(self.get_file_url()) @@ -45,32 +48,31 @@ class XHamsterCom(Hoster): """ if self.html is None: self.download_html() - + flashvar_pattern = re.compile('flashvars = ({.*?});', re.DOTALL) - json_flashvar=flashvar_pattern.search(self.html) + json_flashvar = flashvar_pattern.search(self.html) if json_flashvar is None: self.fail("Parse error (flashvars)") j = clean_json(json_flashvar.group(1)) flashvars = json_loads(j) - + if flashvars["srv"]: - srv_url = flashvars["srv"] + '/' + srv_url = flashvars["srv"] + '/' else: self.fail("Parse error (srv_url)") - + if flashvars["url_mode"]: - url_mode = flashvars["url_mode"] + url_mode = flashvars["url_mode"] else: self.fail("Parse error (url_mode)") - if self.desired_fmt == ".mp4": file_url = re.search(r"
    ([^<]+) retry: retry = None @@ -142,37 +139,36 @@ class Xdcc(Hoster): sock.close() self.fail("XDCC Bot did not answer") - fdset = select([sock], [], [], 0) if sock not in fdset[0]: continue - + readbuffer += sock.recv(1024) temp = readbuffer.split("\n") readbuffer = temp.pop() for line in temp: - if self.debug is 2: print "*> " + unicode(line, errors='ignore') - line = line.rstrip() + if self.debug is 2: + print "*> " + unicode(line, errors='ignore') + line = line.rstrip() first = line.split() if first[0] == "PING": sock.send("PONG %s\r\n" % first[1]) - + if first[0] == "ERROR": self.fail("IRC-Error: %s" % line) - + msg = line.split(None, 3) if len(msg) != 4: continue - - msg = { \ - "origin":msg[0][1:], \ - "action":msg[1], \ - "target":msg[2], \ - "text" :msg[3][1:] \ - } + msg = { + "origin": msg[0][1:], + "action": msg[1], + "target": msg[2], + "text": msg[3][1:] + } if nick == msg["target"][0:len(nick)] and "PRIVMSG" == msg["action"]: if msg["text"] == "\x01VERSION\x01": @@ -182,34 +178,34 @@ class Xdcc(Hoster): self.logDebug("Sending CTCP TIME.") sock.send("NOTICE %s :%d\r\n" % (msg['origin'], time.time())) elif msg["text"] == "\x01LAG\x01": - pass # don't know how to answer - - if not (bot == msg["origin"][0:len(bot)] - and nick == msg["target"][0:len(nick)] - and msg["action"] in ("PRIVMSG", "NOTICE")): + pass # don't know how to answer + + if not (bot == msg["origin"][0:len(bot)] + and nick == msg["target"][0:len(nick)] + and msg["action"] in ("PRIVMSG", "NOTICE")): continue - + if self.debug is 1: print "%s: %s" % (msg["origin"], msg["text"]) - + if "You already requested that pack" in msg["text"]: retry = time.time() + 300 - + if "you must be on a known channel to request a pack" in msg["text"]: self.fail("Wrong channel") - + m = re.match('\x01DCC SEND (.*?) (\d+) (\d+)(?: (\d+))?\x01', msg["text"]) if m: done = True - + # get connection data - ip = socket.inet_ntoa(struct.pack('L', socket.ntohl(int(m.group(2))))) - port = int(m.group(3)) + ip = socket.inet_ntoa(struct.pack('L', socket.ntohl(int(m.group(2))))) + port = int(m.group(3)) packname = m.group(1) - + if len(m.groups()) > 3: self.req.filesize = int(m.group(4)) - + self.pyfile.name = packname filename = save_join(location, packname) self.logInfo("XDCC: Downloading %s from %s:%d" % (packname, ip, port)) @@ -219,11 +215,10 @@ class Xdcc(Hoster): if newname and newname != filename: self.logInfo("%(name)s saved as %(newname)s" % {"name": self.pyfile.name, "newname": newname}) filename = newname - + # kill IRC socket # sock.send("QUIT :byebye\r\n") sock.close() self.lastDownload = filename return self.lastDownload - diff --git a/module/plugins/hoster/YibaishiwuCom.py b/module/plugins/hoster/YibaishiwuCom.py index 901225944..37eaa17e5 100644 --- a/module/plugins/hoster/YibaishiwuCom.py +++ b/module/plugins/hoster/YibaishiwuCom.py @@ -20,6 +20,7 @@ import re from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo from module.common.json_layer import json_loads + class YibaishiwuCom(SimpleHoster): __name__ = "YibaishiwuCom" __type__ = "hoster" @@ -31,24 +32,27 @@ class YibaishiwuCom(SimpleHoster): FILE_NAME_PATTERN = r"file_name: '(?P[^']+)'" FILE_SIZE_PATTERN = r"file_size: '(?P[^']+)'" FILE_OFFLINE_PATTERN = ur'

    哎呀!提取码不存在!不妨搜搜看吧!

    ' - - AJAX_URL_PATTERN = r'(/\?ct=(pickcode|download)[^"\']+)' - + + AJAX_URL_PATTERN = r'(/\?ct=(pickcode|download)[^"\']+)' + def handleFree(self): found = re.search(self.AJAX_URL_PATTERN, self.html) - if not found: self.parseError("AJAX URL") + if not found: + self.parseError("AJAX URL") url = found.group(1) self.logDebug(('FREEUSER' if found.group(2) == 'download' else 'GUEST') + ' URL', url) - - response = json_loads(self.load("http://115.com" + url, decode = False)) - for mirror in (response['urls'] if 'urls' in response else response['data'] if 'data' in response else []): + + response = json_loads(self.load("http://115.com" + url, decode=False)) + for mirror in (response['urls'] if 'urls' in response else response['data'] if 'data' in response else []): try: - url = mirror['url'].replace('\\','') + url = mirror['url'].replace('\\', '') self.logDebug("Trying URL: " + url) self.download(url) break except: continue - else: self.fail('No working link found') + else: + self.fail('No working link found') + getInfo = create_getInfo(YibaishiwuCom) diff --git a/module/plugins/hoster/YoupornCom.py b/module/plugins/hoster/YoupornCom.py index b17a4ef80..d029db7ba 100644 --- a/module/plugins/hoster/YoupornCom.py +++ b/module/plugins/hoster/YoupornCom.py @@ -4,6 +4,7 @@ import re from module.plugins.Hoster import Hoster + class YoupornCom(Hoster): __name__ = "YoupornCom" __type__ = "hoster" @@ -15,19 +16,19 @@ class YoupornCom(Hoster): def setup(self): self.html = None - + def process(self, pyfile): self.pyfile = pyfile - + if not self.file_exists(): self.offline() - + self.pyfile.name = self.get_file_name() self.download(self.get_file_url()) def download_html(self): url = self.pyfile.url - self.html = self.load(url, post={"user_choice":"Enter"}, cookies=False) + self.html = self.load(url, post={"user_choice": "Enter"}, cookies=False) def get_file_url(self): """ returns the absolute downloadable filepath @@ -43,7 +44,7 @@ class YoupornCom(Hoster): self.download_html() file_name_pattern = r"(.*) - Free Porn Videos - YouPorn" - return re.search(file_name_pattern, self.html).group(1).replace("&", "&").replace("/","") + '.flv' + return re.search(file_name_pattern, self.html).group(1).replace("&", "&").replace("/", "") + '.flv' def file_exists(self): """ returns True or False diff --git a/module/plugins/hoster/YourfilesTo.py b/module/plugins/hoster/YourfilesTo.py index 4a192b32a..8c0784205 100644 --- a/module/plugins/hoster/YourfilesTo.py +++ b/module/plugins/hoster/YourfilesTo.py @@ -5,6 +5,7 @@ import re import urllib from module.plugins.Hoster import Hoster + class YourfilesTo(Hoster): __name__ = "YourfilesTo" __type__ = "hoster" @@ -18,35 +19,35 @@ class YourfilesTo(Hoster): self.html = None self.multiDL = True - def process(self,pyfile): + def process(self, pyfile): self.pyfile = pyfile self.prepare() self.download(self.get_file_url()) - + def prepare(self): if not self.file_exists(): self.offline() self.pyfile.name = self.get_file_name() - + wait_time = self.get_waiting_time() self.setWait(wait_time) - self.logDebug("%s: Waiting %d seconds." % (self.__name__,wait_time)) + self.logDebug("%s: Waiting %d seconds." % (self.__name__, wait_time)) self.wait() def get_waiting_time(self): if self.html is None: self.download_html() - + #var zzipitime = 15; m = re.search(r'var zzipitime = (\d+);', self.html) if m: sec = int(m.group(1)) else: sec = 0 - + return sec - + def download_html(self): url = self.pyfile.url self.html = self.load(url) @@ -61,7 +62,7 @@ class YourfilesTo(Hoster): return url else: self.fail("absolute filepath could not be found. offline? ") - + def get_file_name(self): if self.html is None: self.download_html() @@ -73,11 +74,8 @@ class YourfilesTo(Hoster): """ if self.html is None: self.download_html() - + if re.search(r"HTTP Status 404", self.html) is not None: return False else: return True - - - diff --git a/module/plugins/hoster/YoutubeCom.py b/module/plugins/hoster/YoutubeCom.py index 129b948bf..1db5fc0a4 100644 --- a/module/plugins/hoster/YoutubeCom.py +++ b/module/plugins/hoster/YoutubeCom.py @@ -10,10 +10,12 @@ from urllib import unquote from module.utils import html_unescape from module.plugins.Hoster import Hoster + def which(program): """Works exactly like the unix command which Courtesy of http://stackoverflow.com/a/377028/675646""" + def is_exe(fpath): return os.path.isfile(fpath) and os.access(fpath, os.X_OK) @@ -30,45 +32,45 @@ def which(program): return None + class YoutubeCom(Hoster): __name__ = "YoutubeCom" __type__ = "hoster" __pattern__ = r"https?://(?:[^/]*?)youtube\.com/watch.*?[?&]v=.*" __version__ = "0.34" __config__ = [("quality", "sd;hd;fullhd;240p;360p;480p;720p;1080p;3072p", "Quality Setting", "hd"), - ("fmt", "int", "FMT/ITAG Number (5-102, 0 for auto)", 0), - (".mp4", "bool", "Allow .mp4", True), - (".flv", "bool", "Allow .flv", True), - (".webm", "bool", "Allow .webm", False), - (".3gp", "bool", "Allow .3gp", False), - ("3d", "bool", "Prefer 3D", False)] + ("fmt", "int", "FMT/ITAG Number (5-102, 0 for auto)", 0), + (".mp4", "bool", "Allow .mp4", True), + (".flv", "bool", "Allow .flv", True), + (".webm", "bool", "Allow .webm", False), + (".3gp", "bool", "Allow .3gp", False), + ("3d", "bool", "Prefer 3D", False)] __description__ = """Youtube.com Video Download Hoster""" __author_name__ = ("spoob", "zoidberg") __author_mail__ = ("spoob@pyload.org", "zoidberg@mujmail.cz") # name, width, height, quality ranking, 3D formats = {5: (".flv", 400, 240, 1, False), - 6: (".flv", 640, 400, 4, False), + 6: (".flv", 640, 400, 4, False), 17: (".3gp", 176, 144, 0, False), 18: (".mp4", 480, 360, 2, False), 22: (".mp4", 1280, 720, 8, False), 43: (".webm", 640, 360, 3, False), 34: (".flv", 640, 360, 4, False), 35: (".flv", 854, 480, 6, False), - 36: (".3gp", 400, 240, 1, False), + 36: (".3gp", 400, 240, 1, False), 37: (".mp4", 1920, 1080, 9, False), 38: (".mp4", 4096, 3072, 10, False), 44: (".webm", 854, 480, 5, False), 45: (".webm", 1280, 720, 7, False), - 46: (".webm", 1920, 1080, 9, False), - 82: (".mp4", 640, 360, 3, True), - 83: (".mp4", 400, 240, 1, True), - 84: (".mp4", 1280, 720, 8, True), - 85: (".mp4", 1920, 1080, 9, True), - 100: (".webm", 640, 360, 3, True), - 101: (".webm", 640, 360, 4, True), - 102: (".webm", 1280, 720, 8, True) - } + 46: (".webm", 1920, 1080, 9, False), + 82: (".mp4", 640, 360, 3, True), + 83: (".mp4", 400, 240, 1, True), + 84: (".mp4", 1280, 720, 8, True), + 85: (".mp4", 1920, 1080, 9, True), + 100: (".webm", 640, 360, 3, True), + 101: (".webm", 640, 360, 4, True), + 102: (".webm", 1280, 720, 8, True)} def setup(self): self.resumeDownload = self.multiDL = True @@ -85,9 +87,11 @@ class YoutubeCom(Hoster): #get config use3d = self.getConfig("3d") if use3d: - quality = {"sd":82,"hd":84,"fullhd":85,"240p":83,"360p":82,"480p":82,"720p":84,"1080p":85,"3072p":85} + quality = {"sd": 82, "hd": 84, "fullhd": 85, "240p": 83, "360p": 82, + "480p": 82, "720p": 84, "1080p": 85, "3072p": 85} else: - quality = {"sd":18,"hd":22,"fullhd":37,"240p":5,"360p":18,"480p":35,"720p":22,"1080p":37,"3072p":38} + quality = {"sd": 18, "hd": 22, "fullhd": 37, "240p": 5, "360p": 18, + "480p": 35, "720p": 22, "1080p": 37, "3072p": 38} desired_fmt = self.getConfig("fmt") if desired_fmt and desired_fmt not in self.formats: self.logWarning("FMT %d unknown - using default." % desired_fmt) @@ -98,7 +102,7 @@ class YoutubeCom(Hoster): #parse available streams streams = re.search(r'"url_encoded_fmt_stream_map": "(.*?)",', html).group(1) streams = [x.split('\u0026') for x in streams.split(',')] - streams = [dict((y.split('=',1)) for y in x) for x in streams] + streams = [dict((y.split('=', 1)) for y in x) for x in streams] streams = [(int(x['itag']), "%s&signature=%s" % (unquote(x['url']), x['sig'])) for x in streams] #self.logDebug("Found links: %s" % streams) self.logDebug("AVAILABLE STREAMS: %s" % [x[0] for x in streams]) @@ -111,22 +115,19 @@ class YoutubeCom(Hoster): fmt_dict = dict([x for x in streams if self.formats[x[0]][4] == use3d] or streams) self.logDebug("DESIRED STREAM: ITAG:%d (%s) %sfound, %sallowed" % - (desired_fmt, - "%s %dx%d Q:%d 3D:%s" % self.formats[desired_fmt], - "" if desired_fmt in fmt_dict else "NOT ", - "" if allowed(desired_fmt) else "NOT ") - ) + (desired_fmt, "%s %dx%d Q:%d 3D:%s" % self.formats[desired_fmt], + "" if desired_fmt in fmt_dict else "NOT ", "" if allowed(desired_fmt) else "NOT ")) #return fmt nearest to quality index if desired_fmt in fmt_dict and allowed(desired_fmt): fmt = desired_fmt else: - sel = lambda x: self.formats[x][3] #select quality index + sel = lambda x: self.formats[x][3] # select quality index comp = lambda x, y: abs(sel(x) - sel(y)) self.logDebug("Choosing nearest fmt: %s" % [(x, allowed(x), comp(x, desired_fmt)) for x in fmt_dict.keys()]) fmt = reduce(lambda x, y: x if comp(x, desired_fmt) <= comp(y, desired_fmt) and - sel(x) > sel(y) else y, fmt_dict.keys()) + sel(x) > sel(y) else y, fmt_dict.keys()) self.logDebug("Chosen fmt: %s" % fmt) url = fmt_dict[fmt] diff --git a/module/plugins/hoster/ZDF.py b/module/plugins/hoster/ZDF.py index ea45f4fd8..9940fd078 100644 --- a/module/plugins/hoster/ZDF.py +++ b/module/plugins/hoster/ZDF.py @@ -1,4 +1,3 @@ - import re from xml.etree.ElementTree import fromstring @@ -6,6 +5,7 @@ from module.plugins.Hoster import Hoster XML_API = "http://www.zdf.de/ZDFmediathek/xmlservice/web/beitragsDetails?id=%i" + class ZDF(Hoster): # Based on zdfm by Roland Beermann # http://github.com/enkore/zdfm/ @@ -23,7 +23,7 @@ class ZDF(Hoster): @staticmethod def video_valid(video): - return (video.findtext("url").startswith("http") and video.findtext("url").endswith(".mp4")) + return video.findtext("url").startswith("http") and video.findtext("url").endswith(".mp4") @staticmethod def get_id(url): @@ -40,7 +40,8 @@ class ZDF(Hoster): title = video.findtext("information/title") pyfile.name = title - - target_url = sorted((v for v in video.iter("formitaet") if self.video_valid(v)), key=self.video_key)[-1].findtext("url") + + target_url = sorted((v for v in video.iter("formitaet") if self.video_valid(v)), + key=self.video_key)[-1].findtext("url") self.download(target_url) diff --git a/module/plugins/hoster/ZeveraCom.py b/module/plugins/hoster/ZeveraCom.py index 92f9e4dcd..e8b832a13 100644 --- a/module/plugins/hoster/ZeveraCom.py +++ b/module/plugins/hoster/ZeveraCom.py @@ -2,9 +2,7 @@ # -*- coding: utf-8 -*- from module.plugins.Hoster import Hoster -from module.utils import html_unescape -from urllib import quote, unquote -from time import sleep + class ZeveraCom(Hoster): __name__ = "ZeveraCom" @@ -14,95 +12,95 @@ class ZeveraCom(Hoster): __description__ = """zevera.com hoster plugin""" __author_name__ = ("zoidberg") __author_mail__ = ("zoidberg@mujmail.cz") - + def setup(self): self.resumeDownload = self.multiDL = True self.chunkLimit = 1 - + def process(self, pyfile): if not self.account: self.logError(_("Please enter your %s account or deactivate this plugin") % "zevera.com") self.fail("No zevera.com account provided") self.logDebug("zevera.com: Old URL: %s" % pyfile.url) - - if self.account.getAPIData(self.req, cmd = "checklink", olink = pyfile.url) != "Alive": - self.fail("Offline or not downloadable - contact Zevera support") - - header = self.account.getAPIData(self.req, just_header = True, cmd="generatedownloaddirect", olink = pyfile.url) + + if self.account.getAPIData(self.req, cmd="checklink", olink=pyfile.url) != "Alive": + self.fail("Offline or not downloadable - contact Zevera support") + + header = self.account.getAPIData(self.req, just_header=True, cmd="generatedownloaddirect", olink=pyfile.url) if not "location" in header: self.fail("Unable to initialize download - contact Zevera support") - - self.download(header['location'], disposition = True) - - check = self.checkDownload({"error" : 'action="ErrorDownload.aspx'}) + + self.download(header['location'], disposition=True) + + check = self.checkDownload({"error": 'action="ErrorDownload.aspx'}) if check == "error": self.fail("Error response received - contact Zevera support") - - """ - # BitAPI not used - defunct, probably abandoned by Zevera - - api_url = "http://zevera.com/API.ashx" - - def process(self, pyfile): - if not self.account: - self.logError(_("Please enter your zevera.com account or deactivate this plugin")) - self.fail("No zevera.com account provided") - self.logDebug("zevera.com: Old URL: %s" % pyfile.url) - - last_size = retries = 0 - olink = self.pyfile.url #quote(self.pyfile.url.encode('utf_8')) - - for i in range(100): - self.retData = self.account.loadAPIRequest(self.req, cmd = 'download_request', olink = olink) - self.checkAPIErrors(self.retData) - - if self.retData['FileInfo']['StatusID'] == 100: - break - elif self.retData['FileInfo']['StatusID'] == 99: - self.fail('Failed to initialize download (99)') - else: - if self.retData['FileInfo']['Progress']['BytesReceived'] <= last_size: - if retries >= 6: - self.fail('Failed to initialize download (%d)' % self.retData['FileInfo']['StatusID'] ) - retries += 1 - else: - retries = 0 - - last_size = self.retData['FileInfo']['Progress']['BytesReceived'] - - self.setWait(self.retData['Update_Wait']) - self.wait() - - pyfile.name = self.retData['FileInfo']['RealFileName'] - pyfile.size = self.retData['FileInfo']['FileSizeInBytes'] - - self.retData = self.account.loadAPIRequest(self.req, cmd = 'download_start', FileID = self.retData['FileInfo']['FileID']) - self.checkAPIErrors(self.retData) - - self.download(self.api_url, get = { - 'cmd': "open_stream", - 'login': self.account.loginname, - 'pass': self.account.password, - 'FileID': self.retData['FileInfo']['FileID'], - 'startBytes': 0 - } - ) - - def checkAPIErrors(self, retData): - if not retData: - self.fail('Unknown API response') - - if retData['ErrorCode']: - self.logError(retData['ErrorCode'], retData['ErrorMessage']) - #self.fail('ERROR: ' + retData['ErrorMessage']) - - if self.pyfile.size / 1024000 > retData['AccountInfo']['AvailableTODAYTrafficForUseInMBytes']: - self.logWarning("Not enough data left to download the file") - - def crazyDecode(self, ustring): - # accepts decoded ie. unicode string - API response is double-quoted, double-utf8-encoded - # no idea what the proper order of calling these functions would be :-/ - return html_unescape(unquote(unquote(ustring.replace('@DELIMITER@','#'))).encode('raw_unicode_escape').decode('utf-8')) - """ \ No newline at end of file + # BitAPI not used - defunct, probably abandoned by Zevera + # + # api_url = "http://zevera.com/API.ashx" + # + # def process(self, pyfile): + # if not self.account: + # self.logError(_("Please enter your zevera.com account or deactivate this plugin")) + # self.fail("No zevera.com account provided") + # + # self.logDebug("zevera.com: Old URL: %s" % pyfile.url) + # + # last_size = retries = 0 + # olink = self.pyfile.url #quote(self.pyfile.url.encode('utf_8')) + # + # for i in range(100): + # self.retData = self.account.loadAPIRequest(self.req, cmd = 'download_request', olink = olink) + # self.checkAPIErrors(self.retData) + # + # if self.retData['FileInfo']['StatusID'] == 100: + # break + # elif self.retData['FileInfo']['StatusID'] == 99: + # self.fail('Failed to initialize download (99)') + # else: + # if self.retData['FileInfo']['Progress']['BytesReceived'] <= last_size: + # if retries >= 6: + # self.fail('Failed to initialize download (%d)' % self.retData['FileInfo']['StatusID'] ) + # retries += 1 + # else: + # retries = 0 + # + # last_size = self.retData['FileInfo']['Progress']['BytesReceived'] + # + # self.setWait(self.retData['Update_Wait']) + # self.wait() + # + # pyfile.name = self.retData['FileInfo']['RealFileName'] + # pyfile.size = self.retData['FileInfo']['FileSizeInBytes'] + # + # self.retData = self.account.loadAPIRequest(self.req, cmd = 'download_start', + # FileID = self.retData['FileInfo']['FileID']) + # self.checkAPIErrors(self.retData) + # + # self.download(self.api_url, get = { + # 'cmd': "open_stream", + # 'login': self.account.loginname, + # 'pass': self.account.password, + # 'FileID': self.retData['FileInfo']['FileID'], + # 'startBytes': 0 + # } + # ) + # + # def checkAPIErrors(self, retData): + # if not retData: + # self.fail('Unknown API response') + # + # if retData['ErrorCode']: + # self.logError(retData['ErrorCode'], retData['ErrorMessage']) + # #self.fail('ERROR: ' + retData['ErrorMessage']) + # + # if self.pyfile.size / 1024000 > retData['AccountInfo']['AvailableTODAYTrafficForUseInMBytes']: + # self.logWarning("Not enough data left to download the file") + # + # def crazyDecode(self, ustring): + # # accepts decoded ie. unicode string - API response is double-quoted, double-utf8-encoded + # # no idea what the proper order of calling these functions would be :-/ + # return html_unescape(unquote(unquote(ustring.replace( + # '@DELIMITER@','#'))).encode('raw_unicode_escape').decode('utf-8')) diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index e130be24c..3c7b68bb6 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -1,21 +1,26 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -import re, subprocess, tempfile, os +import re +import subprocess +import tempfile +import os + from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, timestamp from module.plugins.internal.CaptchaService import ReCaptcha from module.common.json_layer import json_loads + class ZippyshareCom(SimpleHoster): __name__ = "ZippyshareCom" __type__ = "hoster" __pattern__ = r"(?Phttp://www\d{0,2}\.zippyshare.com)/v(?:/|iew.jsp.*key=)(?P\d+)" - __version__ = "0.38" + __version__ = "0.39" __description__ = """Zippyshare.com Download Hoster""" __author_name__ = ("spoob", "zoidberg", "stickell") __author_mail__ = ("spoob@pyload.org", "zoidberg@mujmail.cz", "l.stickell@yahoo.it") __config__ = [("swfdump_path", "string", "Path to swfdump", "")] - + FILE_NAME_PATTERN = r'>Name:\s*]*>(?P[^<]+)
    ' FILE_SIZE_PATTERN = r'>Size:\s*]*>(?P[0-9.,]+) (?P[kKMG]+)i?B
    ' FILE_INFO_PATTERN = r'document\.getElementById\(\'dlbutton\'\)\.href = "[^;]*/(?P[^"]+)";' @@ -26,34 +31,35 @@ class ZippyshareCom(SimpleHoster): CAPTCHA_KEY_PATTERN = r'Recaptcha.create\("([^"]+)"' CAPTCHA_SHORTENCODE_PATTERN = r"shortencode: '([^']+)'" CAPTCHA_DOWNLOAD_PATTERN = r"document.location = '([^']+)'" - - LAST_KNOWN_VALUES = (9, 2374755) #time = (seed * multiply) % modulo + + LAST_KNOWN_VALUES = (9, 2374755) # time = (seed * multiply) % modulo def setup(self): self.html = None self.wantReconnect = False self.multiDL = True - def handleFree(self): + def handleFree(self): url = self.get_file_url() - if not url: self.fail("Download URL not found.") + if not url: + self.fail("Download URL not found.") self.logDebug("Download URL %s" % url) - self.download(url, cookies = True) - + self.download(url, cookies=True) + check = self.checkDownload({ "swf_values": re.compile(self.SEED_PATTERN) }) if check == "swf_values": - swf_sts = self.getStorage("swf_sts") + swf_sts = self.getStorage("swf_sts") if not swf_sts: self.setStorage("swf_sts", 2) self.setStorage("swf_stamp", 0) elif swf_sts == '1': self.setStorage("swf_sts", 2) - - self.retry(max_tries = 1) - + + self.retry(max_tries=1) + def get_file_url(self): """ returns the absolute downloadable filepath """ @@ -73,54 +79,55 @@ class ZippyshareCom(SimpleHoster): seed_search = re.search(self.SEED_PATTERN, self.html) if seed_search: swf_url, file_seed = seed_search.groups() - + swf_sts = self.getStorage("swf_sts") swf_stamp = int(self.getStorage("swf_stamp") or 0) swf_version = self.getStorage("version") self.logDebug("SWF", swf_sts, swf_stamp, swf_version) - - if not swf_sts: + + if not swf_sts: self.logDebug('Using default values') multiply, modulo = self.LAST_KNOWN_VALUES elif swf_sts == "1": - self.logDebug('Using stored values') + self.logDebug('Using stored values') multiply = self.getStorage("multiply") modulo = self.getStorage("modulo") - elif swf_sts == "2": + elif swf_sts == "2": if swf_version < self.__version__: - self.logDebug('Reverting to default values') + self.logDebug('Reverting to default values') self.setStorage("swf_sts", "") self.setStorage("version", self.__version__) - multiply, modulo = self.LAST_KNOWN_VALUES + multiply, modulo = self.LAST_KNOWN_VALUES elif (swf_stamp + 3600000) < timestamp(): swfdump = self.get_swfdump_path() - if swfdump: + if swfdump: multiply, modulo = self.get_swf_values(self.file_info['HOST'] + swf_url, swfdump) else: - self.logWarning("Swfdump not found. Install swftools to bypass captcha.") - + self.logWarning("Swfdump not found. Install swftools to bypass captcha.") + if multiply and modulo: - self.logDebug("TIME = (%s * %s) %s" % (file_seed, multiply, modulo)) - url = "/download?key=%s&time=%d" % (self.file_info['KEY'], (int(file_seed) * int(multiply)) % int(modulo)) - + self.logDebug("TIME = (%s * %s) %s" % (file_seed, multiply, modulo)) + url = "/download?key=%s&time=%d" % (self.file_info['KEY'], + (int(file_seed) * int(multiply)) % int(modulo)) + if not url: #Method #3: Captcha url = self.do_recaptcha() - + return self.file_info['HOST'] + url - + def get_swf_values(self, swf_url, swfdump): self.logDebug('Parsing values from %s' % swf_url) - multiply = modulo = None - + multiply = modulo = None + fd, fpath = tempfile.mkstemp() try: swf_data = self.load(swf_url) os.write(fd, swf_data) - + p = subprocess.Popen([swfdump, '-a', fpath], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate() - + if err: self.logError(err) else: @@ -128,9 +135,9 @@ class ZippyshareCom(SimpleHoster): multiply = re.search(r'pushbyte (\d+)', m_str).group(1) modulo = re.search(r'pushint (\d+)', m_str).group(1) finally: - os.close(fd) + os.close(fd) os.remove(fpath) - + if multiply and modulo: self.setStorage("multiply", multiply) self.setStorage("modulo", modulo) @@ -139,16 +146,16 @@ class ZippyshareCom(SimpleHoster): else: self.logError("Parsing SWF failed: swfdump not installed or plugin out of date") self.setStorage("swf_sts", 2) - - self.setStorage("swf_stamp", timestamp()) - + + self.setStorage("swf_stamp", timestamp()) + return multiply, modulo - + def get_swfdump_path(self): # used for detecting if swfdump is installed def is_exe(ppath): return os.path.isfile(ppath) and os.access(ppath, os.X_OK) - + program = self.getConfig("swfdump_path") or "swfdump" swfdump = None ppath, pname = os.path.split(program) @@ -160,33 +167,35 @@ class ZippyshareCom(SimpleHoster): exe_file = os.path.join(ppath, program) if is_exe(exe_file): swfdump = exe_file - + # return path to the executable or None if not found return swfdump - + def do_recaptcha(self): self.logDebug('Trying to solve captcha') captcha_key = re.search(self.CAPTCHA_KEY_PATTERN, self.html).group(1) shortencode = re.search(self.CAPTCHA_SHORTENCODE_PATTERN, self.html).group(1) - url = re.search(self.CAPTCHA_DOWNLOAD_PATTERN, self.html).group(1) - + url = re.search(self.CAPTCHA_DOWNLOAD_PATTERN, self.html).group(1) + recaptcha = ReCaptcha(self) for i in range(5): challenge, code = recaptcha.challenge(captcha_key) response = json_loads(self.load(self.file_info['HOST'] + '/rest/captcha/test', - post={'challenge': challenge, - 'response': code, - 'shortencode': shortencode})) + post={'challenge': challenge, + 'response': code, + 'shortencode': shortencode})) self.logDebug("reCaptcha response : %s" % response) if response == True: - self.correctCaptcha + self.correctCaptcha() break else: self.invalidCaptcha() - else: self.fail("Invalid captcha") - - return url + else: + self.fail("Invalid captcha") + + return url + -getInfo = create_getInfo(ZippyshareCom) \ No newline at end of file +getInfo = create_getInfo(ZippyshareCom) -- cgit v1.2.3