diff options
Diffstat (limited to 'module/plugins/hoster/ZippyshareCom.py')
-rw-r--r-- | module/plugins/hoster/ZippyshareCom.py | 85 |
1 files changed, 39 insertions, 46 deletions
diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index b4fa4f8ac..67b384c5f 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -1,71 +1,64 @@ # -*- coding: utf-8 -*- -# Test links (random.bin): -# http://www13.zippyshare.com/v/18665333/file.html - import re +from urlparse import urljoin + 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.49" + __name__ = "ZippyshareCom" + __type__ = "hoster" + __version__ = "0.63" + + __pattern__ = r'(?P<HOST>http://www\d{0,2}\.zippyshare\.com)/v(?:/|iew\.jsp.*key=)(?P<KEY>\d+)' + __description__ = """Zippyshare.com hoster plugin""" - __author_name__ = ("spoob", "zoidberg", "stickell", "skylab") - __author_mail__ = ("spoob@pyload.org", "zoidberg@mujmail.cz", "l.stickell@yahoo.it", "development@sky-lab.de") + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + + + NAME_PATTERN = r'("\d{6,}/"[ ]*\+.+?"/|<title>Zippyshare.com - )(?P<N>.+?)("|</title>)' + SIZE_PATTERN = r'>Size:.+?">(?P<S>[\d.,]+) (?P<U>[\w^_]+)' - FILE_NAME_PATTERN = r'<title>Zippyshare\.com - (?P<N>[^<]+)</title>' - FILE_SIZE_PATTERN = r'>Size:</font>\s*<font [^>]*>(?P<S>[0-9.,]+) (?P<U>[kKMG]+)i?B</font><br />' - FILE_INFO_PATTERN = r'document\.getElementById\(\'dlbutton\'\)\.href = "[^;]*/(?P<N>[^"]+)";' - FILE_OFFLINE_PATTERN = r'>File does not exist on this server</div>' + OFFLINE_PATTERN = r'>File does not exist on this server<' + + COOKIES = [("zippyshare.com", "ziplocale", "en")] - SH_COOKIES = [('zippyshare.com', 'ziplocale', 'en')] def setup(self): self.multiDL = True + self.chunkLimit = -1 + self.resumeDownload = True + def handleFree(self): - url = self.get_file_url() - if not url: - self.fail("Download URL not found.") - self.logDebug("Download URL: %s" % url) + url = self.get_link() self.download(url) - def get_file_url(self): - """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) - 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)) + + def get_checksum(self): + try: + m = re.search(r'\+[ ]*\((\d+)[ ]*\%[ ]*(\d+)[ ]*\+[ ]*(\d+)[ ]*\%[ ]*(\d+)\)[ ]*\+', self.html) + if m: + a1, a2, c1, c2 = map(int, m.groups()) else: - checksum = ((a % b) + (c % k)) + a1, a2 = map(int, re.search(r'\(\'downloadB\'\).omg = (\d+)%(\d+)', self.html).groups()) + c1, c2 = map(int, re.search(r'\(\'downloadB\'\).omg\) \* \((\d+)%(\d+)', self.html).groups()) - self.logInfo('Checksum: %s' % checksum) + b = (a1 % a2) * (c1 % c2) + except: + self.error(_("Unable to calculate checksum")) + else: + return b + 18 - filename = re.search(r'>Name:</font>\s*<font [^>]*>(?P<N>[^<]+)</font><br />', self.html).group('N') - url = "/d/%s/%s/%s" % (number, checksum, filename) - self.logInfo(self.file_info['HOST'] + url) - return self.file_info['HOST'] + url + def get_link(self): + checksum = self.get_checksum() + p_url = '/'.join(("d", self.info['pattern']['KEY'], str(checksum), self.pyfile.name)) + dl_link = urljoin(self.info['pattern']['HOST'], p_url) + return dl_link getInfo = create_getInfo(ZippyshareCom) |