summaryrefslogtreecommitdiffstats
path: root/pyload/plugins/hoster/ZippyshareCom.py
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2014-09-08 00:29:57 +0200
committerGravatar Walter Purcaro <vuolter@gmail.com> 2014-09-14 11:02:23 +0200
commit68d662e689cd42687341c550fb6ebb74e6968d21 (patch)
tree486cef41bd928b8db704894233b2cef94a6e346f /pyload/plugins/hoster/ZippyshareCom.py
parentsave_join -> safe_join & save_path -> safe_filename (diff)
downloadpyload-68d662e689cd42687341c550fb6ebb74e6968d21.tar.xz
module -> pyload
Diffstat (limited to 'pyload/plugins/hoster/ZippyshareCom.py')
-rw-r--r--pyload/plugins/hoster/ZippyshareCom.py74
1 files changed, 74 insertions, 0 deletions
diff --git a/pyload/plugins/hoster/ZippyshareCom.py b/pyload/plugins/hoster/ZippyshareCom.py
new file mode 100644
index 000000000..d6b7375e2
--- /dev/null
+++ b/pyload/plugins/hoster/ZippyshareCom.py
@@ -0,0 +1,74 @@
+# -*- coding: utf-8 -*-
+#
+# Test links:
+# http://www13.zippyshare.com/v/18665333/file.html
+
+import re
+
+from pyload.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo
+
+
+class ZippyshareCom(SimpleHoster):
+ __name__ = "ZippyshareCom"
+ __type__ = "hoster"
+ __version__ = "0.49"
+
+ __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")
+
+ 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>[^"]+)";'
+ OFFLINE_PATTERN = r'>File does not exist on this server</div>'
+
+ SH_COOKIES = [(".zippyshare.com", "ziplocale", "en")]
+
+
+ def setup(self):
+ self.multiDL = True
+
+ def handleFree(self):
+ url = self.get_file_url()
+ if not url:
+ self.fail("Download URL not found.")
+ self.logDebug("Download URL: %s" % url)
+ 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 m is None:
+ 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))
+
+ self.logInfo('Checksum: %s' % checksum)
+
+ 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
+
+
+getInfo = create_getInfo(ZippyshareCom)