diff options
author | Leon Bergmann <leon.bergmann@sky-lab.de> | 2014-05-08 11:46:58 +0200 |
---|---|---|
committer | Stefano <l.stickell@yahoo.it> | 2014-05-08 11:46:58 +0200 |
commit | 836acb09f3501964fd99af70f380ada9621a05ee (patch) | |
tree | 6e5971e45275d91d338fad9d35a0c4b0a643cc02 /module/plugins/hoster | |
parent | Fixed MegaDebridEu file names (diff) | |
download | pyload-836acb09f3501964fd99af70f380ada9621a05ee.tar.xz |
Updated Zippyshare
Merges #612
Diffstat (limited to 'module/plugins/hoster')
-rw-r--r-- | module/plugins/hoster/ZippyshareCom.py | 195 |
1 files changed, 30 insertions, 165 deletions
diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index 64d2737ef..1d4033466 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -1,27 +1,21 @@ # -*- coding: utf-8 -*- # Test links (random.bin): -# http://www34.zippyshare.com/v/50494591/file.html +# http://www13.zippyshare.com/v/18665333/file.html 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 +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class ZippyshareCom(SimpleHoster): __name__ = "ZippyshareCom" __type__ = "hoster" __pattern__ = r'(?P<HOST>http://www\d{0,2}\.zippyshare.com)/v(?:/|iew.jsp.*key=)(?P<KEY>\d+)' - __version__ = "0.47" + __version__ = "0.48" __description__ = """Zippyshare.com hoster plugin""" - __author_name__ = ("spoob", "zoidberg", "stickell") - __author_mail__ = ("spoob@pyload.org", "zoidberg@mujmail.cz", "l.stickell@yahoo.it") - __config__ = [("swfdump_path", "string", "Path to swfdump", "")] + __author_name__ = ("spoob", "zoidberg", "stickell", "skylab") + __author_mail__ = ("spoob@pyload.org", "zoidberg@mujmail.cz", "l.stickell@yahoo.it", "development@sky-lab.de") FILE_NAME_PATTERN = r'>Name:</font>\s*<font [^>]*>(?P<N>[^<]+)</font><br />' FILE_SIZE_PATTERN = r'>Size:</font>\s*<font [^>]*>(?P<S>[0-9.,]+) (?P<U>[kKMG]+)i?B</font><br />' @@ -30,14 +24,6 @@ class ZippyshareCom(SimpleHoster): SH_COOKIES = [('zippyshare.com', 'ziplocale', 'en')] - DOWNLOAD_URL_PATTERN = r"<script type=\"text/javascript\">([^<]*?)(document\.getElementById\('dlbutton'\).href\s*=\s*[^;]+;)" - SEED_PATTERN = r'swfobject.embedSWF\("([^"]+)".*?seed: (\d+)' - 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 - def setup(self): self.multiDL = True @@ -48,159 +34,38 @@ class ZippyshareCom(SimpleHoster): self.logDebug("Download URL: %s" % url) self.download(url) - check = self.checkDownload({ - "swf_values": re.compile(self.SEED_PATTERN) - }) - - if check == "swf_values": - 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(1) - def get_file_url(self): - """ returns the absolute downloadable filepath - """ - url_parts = re.search("(addthis:url=\"(http://www(\d+).zippyshare.com/v/(\d*)/file.html))", self.html) - sub = url_parts.group(2) + """returns the absolute downloadable filepath""" + url_parts = re.search(r'(addthis:url="(http://www(\d+).zippyshare.com/v/(\d*)/file.html))', self.html) number = url_parts.group(4) - self.logInfo(number) - self.logInfo(sub) - a = int(re.search("<script type=\"text/javascript\">([^<]*?)(var a = (\d*);)", self.html).group(3)) - k = 78956 + check = re.search(r'<script type="text/javascript">([^<]*?)(var a = (\d*);)', self.html) + if check: + a = int(re.search(r'<script type="text/javascript">([^<]*?)(var a = (\d*);)', self.html).group(3)) + k = int(re.search(r'<script type="text/javascript">([^<]*?)(\d*%(\d*))', self.html).group(3)) + checksum = ((a + 3) % k) * ((a + 3) % 3) + 18 + else: + # This might work but is insecure + # checksum = eval(re.search("((\d*)\s\%\s(\d*)\s\+\s(\d*)\s\%\s(\d*))", self.html).group(0)) + + m = re.search(r"((?P<a>\d*)\s%\s(?P<b>\d*)\s\+\s(?P<c>\d*)\s%\s(?P<k>\d*))", self.html) + if not m: + self.parseError("Unable to detect values to calculate direct link") + a = int(m.group("a")) + b = int(m.group("b")) + c = int(m.group("c")) + k = int(m.group("k")) + if a == c: + checksum = ((a % b) + (a % k)) + else: + checksum = ((a % b) + (c % k)) - zahl = ((a + 3) % k) * ((a + 3) % 3) + 18 + self.logInfo('Checksum: %s' % checksum) - dateiname = re.search(r'>Name:</font>\s*<font [^>]*>(?P<N>[^<]+)</font><br />', self.html).group('N') + filename = re.search(r'>Name:</font>\s*<font [^>]*>(?P<N>[^<]+)</font><br />', self.html).group('N') - url = "/d/" + str(number) + "/" + str(zahl) + "/" + dateiname + url = "/d/%s/%s/%s" % (number, checksum, filename) self.logInfo(self.file_info['HOST'] + url) - return self.file_info['HOST'] + url - def swf_eval(self): - multiply = modulo = None - 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: - self.logDebug('Using default values') - multiply, modulo = self.LAST_KNOWN_VALUES - elif swf_sts == "1": - self.logDebug('Using stored values') - multiply = self.getStorage("multiply") - modulo = self.getStorage("modulo") - elif swf_sts == "2": - if swf_version < self.__version__: - self.logDebug('Reverting to default values') - self.setStorage("swf_sts", "") - self.setStorage("version", self.__version__) - multiply, modulo = self.LAST_KNOWN_VALUES - elif (swf_stamp + 3600000) < timestamp(): - swfdump = self.get_swfdump_path() - 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.") - - 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)) - return url - - return None - - def get_swf_values(self, swf_url, swfdump): - self.logDebug('Parsing values from %s' % swf_url) - 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: - m_str = re.search(r'::break.*?{(.*?)}', out, re.S).group(1) - 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.remove(fpath) - - if multiply and modulo: - self.setStorage("multiply", multiply) - self.setStorage("modulo", modulo) - self.setStorage("swf_sts", 1) - self.setStorage("version", self.__version__) - else: - self.logError("Parsing SWF failed: swfdump not installed or plugin out of date") - self.setStorage("swf_sts", 2) - - 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) - if ppath: - if is_exe(program): - swfdump = program - else: - for ppath in os.environ["PATH"].split(os.pathsep): - 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) - - recaptcha = ReCaptcha(self) - - for _ in xrange(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})) - self.logDebug("reCaptcha response : %s" % response) - if response: - self.correctCaptcha() - break - else: - self.invalidCaptcha() - else: - self.fail("Invalid captcha") - - return url - getInfo = create_getInfo(ZippyshareCom) |