diff options
| author | 2014-09-24 19:16:52 +0200 | |
|---|---|---|
| committer | 2014-09-24 19:16:52 +0200 | |
| commit | 59b1df9619770b21eb9ed2e5d7e705ca7f99fb49 (patch) | |
| tree | c276428cdbc4b1255a1294945636b1cdb5991e09 /module | |
| parent | [SimpleCrypter] Better built-in info (diff) | |
| download | pyload-59b1df9619770b21eb9ed2e5d7e705ca7f99fb49.tar.xz | |
[ZippyshareCom] Partially rewritten
Diffstat (limited to 'module')
| -rw-r--r-- | module/plugins/hoster/ZippyshareCom.py | 73 | 
1 files changed, 30 insertions, 43 deletions
| diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index 33a672198..8d81e6f24 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -1,74 +1,61 @@  # -*- coding: utf-8 -*- -# -# Test links: -# http://www13.zippyshare.com/v/18665333/file.html  import re +from os import path +from urlparse import urljoin +  from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo  class ZippyshareCom(SimpleHoster):      __name__ = "ZippyshareCom"      __type__ = "hoster" -    __version__ = "0.49" +    __version__ = "0.50"      __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") +    __description__ = """ Zippyshare.com hoster plugin """ +    __author_name__ = ("stickell", "skylab", "Walter Purcaro") +    __author_mail__ = ("l.stickell@yahoo.it", "development@sky-lab.de", "vuolter@gmail.com") +      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>' +    OFFLINE_PATTERN = r'>File does not exist on this server<'      SH_COOKIES = [(".zippyshare.com", "ziplocale", "en")]      def setup(self):          self.multiDL = True +        self.resumeDownload = True +      def handleFree(self): -        url = self.get_file_url() -        if not url: -            self.fail("Download URL not found.") +        url = self.get_link()          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 + +    def get_checksum(self): +        m_a = re.search(r'var a = (\d+)\%(\d+);', self.html) +        m_b = re.search(r'var b = (\d+)\%(\d+);', self.html) +        if m_a is None or m_b is None: +            self.parseError("Unable to calculate checksum") + +        # Checksum is calculated as (a*b+19), where a and b are the result of modulo calculations +        a = map(lambda x: int(x), m_a.groups()) +        b = map(lambda x: int(x), m_b.groups()) +        return a[0] % a[1] * b[0] % b[1] + 19 + + +    def get_link(self): +        checksum = self.get_checksum() +        p_url = path.join("d", self.file_info['KEY'], str(checksum), self.pyfile.name) +        dl_link = urljoin(self.file_info['HOST'], p_url) +        return dl_link  getInfo = create_getInfo(ZippyshareCom) | 
