We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Problem with zippyshare
I have a problem with pyload and zippyshare.

When i add a link from zippyshare the software respond: 'NoneType' object has no attribute 'group' XX MiB ZippyshareCom.

I have add the swf path on configuration of zippyshare before the installation of sfwtools.

I use windows 8 on 64 bit and i had try with youtube and it's ok..

the log is this:

https://gist.github.com/djfelix91/6711122


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `module/plugins/hoster/ZippyshareCom.py`
Content:
```
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 import re
5 import subprocess
6 import tempfile
7 import os
8 
9 from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, timestamp
10 from module.plugins.internal.CaptchaService import ReCaptcha
11 from module.common.json_layer import json_loads
12 
13 
14 class ZippyshareCom(SimpleHoster):
15     __name__ = "ZippyshareCom"
16     __type__ = "hoster"
17     __pattern__ = r"(?P<HOST>http://www\d{0,2}\.zippyshare.com)/v(?:/|iew.jsp.*key=)(?P<KEY>\d+)"
18     __version__ = "0.39"
19     __description__ = """Zippyshare.com Download Hoster"""
20     __author_name__ = ("spoob", "zoidberg", "stickell")
21     __author_mail__ = ("spoob@pyload.org", "zoidberg@mujmail.cz", "l.stickell@yahoo.it")
22     __config__ = [("swfdump_path", "string", "Path to swfdump", "")]
23 
24     FILE_NAME_PATTERN = r'>Name:</font>\s*<font [^>]*>(?P<N>[^<]+)</font><br />'
25     FILE_SIZE_PATTERN = r'>Size:</font>\s*<font [^>]*>(?P<S>[0-9.,]+) (?P<U>[kKMG]+)i?B</font><br />'
26     FILE_INFO_PATTERN = r'document\.getElementById\(\'dlbutton\'\)\.href = "[^;]*/(?P<N>[^"]+)";'
27     FILE_OFFLINE_PATTERN = r'>File does not exist on this server</div>'
28 
29     DOWNLOAD_URL_PATTERN = r"<script type=\"text/javascript\">([^<]*?)document\.getElementById\('dlbutton'\).href = ([^;]+);"
30     SEED_PATTERN = r'swfobject.embedSWF\("([^"]+)".*?seed: (\d+)'
31     CAPTCHA_KEY_PATTERN = r'Recaptcha.create\("([^"]+)"'
32     CAPTCHA_SHORTENCODE_PATTERN = r"shortencode: '([^']+)'"
33     CAPTCHA_DOWNLOAD_PATTERN = r"document.location = '([^']+)'"
34 
35     LAST_KNOWN_VALUES = (9, 2374755)  # time = (seed * multiply) % modulo
36 
37     def setup(self):
38         self.html = None
39         self.wantReconnect = False
40         self.multiDL = True
41 
42     def handleFree(self):
43         url = self.get_file_url()
44         if not url:
45             self.fail("Download URL not found.")
46         self.logDebug("Download URL %s" % url)
47         self.download(url, cookies=True)
48 
49         check = self.checkDownload({
50             "swf_values": re.compile(self.SEED_PATTERN)
51         })
52 
53         if check == "swf_values":
54             swf_sts = self.getStorage("swf_sts")
55             if not swf_sts:
56                 self.setStorage("swf_sts", 2)
57                 self.setStorage("swf_stamp", 0)
58             elif swf_sts == '1':
59                 self.setStorage("swf_sts", 2)
60 
61             self.retry(max_tries=1)
62 
63     def get_file_url(self):
64         """ returns the absolute downloadable filepath
65         """
66         url = multiply = modulo = None
67 
68         found = re.search(self.DOWNLOAD_URL_PATTERN, self.html, re.S)
69         if found:
70             #Method #1: JS eval
71             js = "\n".join(found.groups())
72             regex = r"document.getElementById\(\\*'dlbutton\\*'\).omg"
73             omg = re.search(regex + r" = ([^;]+);", js).group(1)
74             js = re.sub(regex + r" = ([^;]+);", '', js)
75             js = re.sub(regex, omg, js)
76             url = self.js.eval(js)
77         else:
78             #Method #2: SWF eval
79             seed_search = re.search(self.SEED_PATTERN, self.html)
80             if seed_search:
81                 swf_url, file_seed = seed_search.groups()
82 
83                 swf_sts = self.getStorage("swf_sts")
84                 swf_stamp = int(self.getStorage("swf_stamp") or 0)
85                 swf_version = self.getStorage("version")
86                 self.logDebug("SWF", swf_sts, swf_stamp, swf_version)
87 
88                 if not swf_sts:
89                     self.logDebug('Using default values')
90                     multiply, modulo = self.LAST_KNOWN_VALUES
91                 elif swf_sts == "1":
92                     self.logDebug('Using stored values')
93                     multiply = self.getStorage("multiply")
94                     modulo = self.getStorage("modulo")
95                 elif swf_sts == "2":
96                     if swf_version < self.__version__:
97                         self.logDebug('Reverting to default values')
98                         self.setStorage("swf_sts", "")
99                         self.setStorage("version", self.__version__)
100                         multiply, modulo = self.LAST_KNOWN_VALUES
101                     elif (swf_stamp + 3600000) < timestamp():
102                         swfdump = self.get_swfdump_path()
103                         if swfdump:
104                             multiply, modulo = self.get_swf_values(self.file_info['HOST'] + swf_url, swfdump)
105                         else:
106                             self.logWarning("Swfdump not found. Install swftools to bypass captcha.")
107 
108                 if multiply and modulo:
109                     self.logDebug("TIME = (%s * %s) %s" % (file_seed, multiply, modulo))
110                     url = "/download?key=%s&time=%d" % (self.file_info['KEY'],
111                                                         (int(file_seed) * int(multiply)) % int(modulo))
112 
113             if not url:
114                 #Method #3: Captcha
115                 url = self.do_recaptcha()
116 
117         return self.file_info['HOST'] + url
118 
119     def get_swf_values(self, swf_url, swfdump):
120         self.logDebug('Parsing values from %s' % swf_url)
121         multiply = modulo = None
122 
123         fd, fpath = tempfile.mkstemp()
124         try:
125             swf_data = self.load(swf_url)
126             os.write(fd, swf_data)
127 
128             p = subprocess.Popen([swfdump, '-a', fpath], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
129             out, err = p.communicate()
130 
131             if err:
132                 self.logError(err)
133             else:
134                 m_str = re.search(r'::break.*?{(.*?)}', out, re.S).group(1)
135                 multiply = re.search(r'pushbyte (\d+)', m_str).group(1)
136                 modulo = re.search(r'pushint (\d+)', m_str).group(1)
137         finally:
138             os.close(fd)
139             os.remove(fpath)
140 
141         if multiply and modulo:
142             self.setStorage("multiply", multiply)
143             self.setStorage("modulo", modulo)
144             self.setStorage("swf_sts", 1)
145             self.setStorage("version", self.__version__)
146         else:
147             self.logError("Parsing SWF failed: swfdump not installed or plugin out of date")
148             self.setStorage("swf_sts", 2)
149 
150         self.setStorage("swf_stamp", timestamp())
151 
152         return multiply, modulo
153 
154     def get_swfdump_path(self):
155         # used for detecting if swfdump is installed
156         def is_exe(ppath):
157             return os.path.isfile(ppath) and os.access(ppath, os.X_OK)
158 
159         program = self.getConfig("swfdump_path") or "swfdump"
160         swfdump = None
161         ppath, pname = os.path.split(program)
162         if ppath:
163             if is_exe(program):
164                 swfdump = program
165         else:
166             for ppath in os.environ["PATH"].split(os.pathsep):
167                 exe_file = os.path.join(ppath, program)
168                 if is_exe(exe_file):
169                     swfdump = exe_file
170 
171         # return path to the executable or None if not found
172         return swfdump
173 
174     def do_recaptcha(self):
175         self.logDebug('Trying to solve captcha')
176         captcha_key = re.search(self.CAPTCHA_KEY_PATTERN, self.html).group(1)
177         shortencode = re.search(self.CAPTCHA_SHORTENCODE_PATTERN, self.html).group(1)
178         url = re.search(self.CAPTCHA_DOWNLOAD_PATTERN, self.html).group(1)
179 
180         recaptcha = ReCaptcha(self)
181 
182         for i in range(5):
183             challenge, code = recaptcha.challenge(captcha_key)
184 
185             response = json_loads(self.load(self.file_info['HOST'] + '/rest/captcha/test',
186                                             post={'challenge': challenge,
187                                                   'response': code,
188                                                   'shortencode': shortencode}))
189             self.logDebug("reCaptcha response : %s" % response)
190             if response == True:
191                 self.correctCaptcha()
192                 break
193             else:
194                 self.invalidCaptcha()
195         else:
196             self.fail("Invalid captcha")
197 
198         return url
199 
200 
201 getInfo = create_getInfo(ZippyshareCom)
202
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py
--- a/module/plugins/hoster/ZippyshareCom.py
+++ b/module/plugins/hoster/ZippyshareCom.py
@@ -26,7 +26,7 @@
     FILE_INFO_PATTERN = r'document\.getElementById\(\'dlbutton\'\)\.href = "[^;]*/(?P<N>[^"]+)";'
     FILE_OFFLINE_PATTERN = r'>File does not exist on this server</div>'
 
-    DOWNLOAD_URL_PATTERN = r"<script type=\"text/javascript\">([^<]*?)document\.getElementById\('dlbutton'\).href = ([^;]+);"
+    DOWNLOAD_URL_PATTERN = r"<script type=\"text/javascript\">([^<]*?)(document\.getElementById\('dlbutton'\).href = [^;]+;)"
     SEED_PATTERN = r'swfobject.embedSWF\("([^"]+)".*?seed: (\d+)'
     CAPTCHA_KEY_PATTERN = r'Recaptcha.create\("([^"]+)"'
     CAPTCHA_SHORTENCODE_PATTERN = r"shortencode: '([^']+)'"
@@ -69,10 +69,11 @@
         if found:
             #Method #1: JS eval
             js = "\n".join(found.groups())
-            regex = r"document.getElementById\(\\*'dlbutton\\*'\).omg"
-            omg = re.search(regex + r" = ([^;]+);", js).group(1)
-            js = re.sub(regex + r" = ([^;]+);", '', js)
-            js = re.sub(regex, omg, js)
+            d = re.search(r'span id="omg" class="(\d*)"', self.html).group(1)
+            regex = r"document.getElementById\('omg'\).getAttribute\('class'\)"
+            js = re.sub(regex, d, js)
+            regex = r"document.getElementById\(\\*'dlbutton\\*'\).href = "
+            js = re.sub(regex, '', js)
             url = self.js.eval(js)
         else:
             #Method #2: SWF eval

{"golden_diff": "diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py\n--- a/module/plugins/hoster/ZippyshareCom.py\n+++ b/module/plugins/hoster/ZippyshareCom.py\n@@ -26,7 +26,7 @@\n     FILE_INFO_PATTERN = r'document\\.getElementById\\(\\'dlbutton\\'\\)\\.href = \"[^;]*/(?P<N>[^\"]+)\";'\n     FILE_OFFLINE_PATTERN = r'>File does not exist on this server</div>'\n \n-    DOWNLOAD_URL_PATTERN = r\"<script type=\\\"text/javascript\\\">([^<]*?)document\\.getElementById\\('dlbutton'\\).href = ([^;]+);\"\n+    DOWNLOAD_URL_PATTERN = r\"<script type=\\\"text/javascript\\\">([^<]*?)(document\\.getElementById\\('dlbutton'\\).href = [^;]+;)\"\n     SEED_PATTERN = r'swfobject.embedSWF\\(\"([^\"]+)\".*?seed: (\\d+)'\n     CAPTCHA_KEY_PATTERN = r'Recaptcha.create\\(\"([^\"]+)\"'\n     CAPTCHA_SHORTENCODE_PATTERN = r\"shortencode: '([^']+)'\"\n@@ -69,10 +69,11 @@\n         if found:\n             #Method #1: JS eval\n             js = \"\\n\".join(found.groups())\n-            regex = r\"document.getElementById\\(\\\\*'dlbutton\\\\*'\\).omg\"\n-            omg = re.search(regex + r\" = ([^;]+);\", js).group(1)\n-            js = re.sub(regex + r\" = ([^;]+);\", '', js)\n-            js = re.sub(regex, omg, js)\n+            d = re.search(r'span id=\"omg\" class=\"(\\d*)\"', self.html).group(1)\n+            regex = r\"document.getElementById\\('omg'\\).getAttribute\\('class'\\)\"\n+            js = re.sub(regex, d, js)\n+            regex = r\"document.getElementById\\(\\\\*'dlbutton\\\\*'\\).href = \"\n+            js = re.sub(regex, '', js)\n             url = self.js.eval(js)\n         else:\n             #Method #2: SWF eval\n", "issue": "Problem with zippyshare\nI have a problem with pyload and zippyshare.\n\nWhen i add a link from zippyshare the software respond: 'NoneType' object has no attribute 'group' XX MiB ZippyshareCom.\n\nI have add the swf path on configuration of zippyshare before the installation of sfwtools.\n\nI use windows 8 on 64 bit and i had try with youtube and it's ok..\n\nthe log is this:\n\nhttps://gist.github.com/djfelix91/6711122\n\n", "before_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport re\nimport subprocess\nimport tempfile\nimport os\n\nfrom module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, timestamp\nfrom module.plugins.internal.CaptchaService import ReCaptcha\nfrom module.common.json_layer import json_loads\n\n\nclass ZippyshareCom(SimpleHoster):\n    __name__ = \"ZippyshareCom\"\n    __type__ = \"hoster\"\n    __pattern__ = r\"(?P<HOST>http://www\\d{0,2}\\.zippyshare.com)/v(?:/|iew.jsp.*key=)(?P<KEY>\\d+)\"\n    __version__ = \"0.39\"\n    __description__ = \"\"\"Zippyshare.com Download Hoster\"\"\"\n    __author_name__ = (\"spoob\", \"zoidberg\", \"stickell\")\n    __author_mail__ = (\"spoob@pyload.org\", \"zoidberg@mujmail.cz\", \"l.stickell@yahoo.it\")\n    __config__ = [(\"swfdump_path\", \"string\", \"Path to swfdump\", \"\")]\n\n    FILE_NAME_PATTERN = r'>Name:</font>\\s*<font [^>]*>(?P<N>[^<]+)</font><br />'\n    FILE_SIZE_PATTERN = r'>Size:</font>\\s*<font [^>]*>(?P<S>[0-9.,]+) (?P<U>[kKMG]+)i?B</font><br />'\n    FILE_INFO_PATTERN = r'document\\.getElementById\\(\\'dlbutton\\'\\)\\.href = \"[^;]*/(?P<N>[^\"]+)\";'\n    FILE_OFFLINE_PATTERN = r'>File does not exist on this server</div>'\n\n    DOWNLOAD_URL_PATTERN = r\"<script type=\\\"text/javascript\\\">([^<]*?)document\\.getElementById\\('dlbutton'\\).href = ([^;]+);\"\n    SEED_PATTERN = r'swfobject.embedSWF\\(\"([^\"]+)\".*?seed: (\\d+)'\n    CAPTCHA_KEY_PATTERN = r'Recaptcha.create\\(\"([^\"]+)\"'\n    CAPTCHA_SHORTENCODE_PATTERN = r\"shortencode: '([^']+)'\"\n    CAPTCHA_DOWNLOAD_PATTERN = r\"document.location = '([^']+)'\"\n\n    LAST_KNOWN_VALUES = (9, 2374755)  # time = (seed * multiply) % modulo\n\n    def setup(self):\n        self.html = None\n        self.wantReconnect = False\n        self.multiDL = True\n\n    def handleFree(self):\n        url = self.get_file_url()\n        if not url:\n            self.fail(\"Download URL not found.\")\n        self.logDebug(\"Download URL %s\" % url)\n        self.download(url, cookies=True)\n\n        check = self.checkDownload({\n            \"swf_values\": re.compile(self.SEED_PATTERN)\n        })\n\n        if check == \"swf_values\":\n            swf_sts = self.getStorage(\"swf_sts\")\n            if not swf_sts:\n                self.setStorage(\"swf_sts\", 2)\n                self.setStorage(\"swf_stamp\", 0)\n            elif swf_sts == '1':\n                self.setStorage(\"swf_sts\", 2)\n\n            self.retry(max_tries=1)\n\n    def get_file_url(self):\n        \"\"\" returns the absolute downloadable filepath\n        \"\"\"\n        url = multiply = modulo = None\n\n        found = re.search(self.DOWNLOAD_URL_PATTERN, self.html, re.S)\n        if found:\n            #Method #1: JS eval\n            js = \"\\n\".join(found.groups())\n            regex = r\"document.getElementById\\(\\\\*'dlbutton\\\\*'\\).omg\"\n            omg = re.search(regex + r\" = ([^;]+);\", js).group(1)\n            js = re.sub(regex + r\" = ([^;]+);\", '', js)\n            js = re.sub(regex, omg, js)\n            url = self.js.eval(js)\n        else:\n            #Method #2: SWF eval\n            seed_search = re.search(self.SEED_PATTERN, self.html)\n            if seed_search:\n                swf_url, file_seed = seed_search.groups()\n\n                swf_sts = self.getStorage(\"swf_sts\")\n                swf_stamp = int(self.getStorage(\"swf_stamp\") or 0)\n                swf_version = self.getStorage(\"version\")\n                self.logDebug(\"SWF\", swf_sts, swf_stamp, swf_version)\n\n                if not swf_sts:\n                    self.logDebug('Using default values')\n                    multiply, modulo = self.LAST_KNOWN_VALUES\n                elif swf_sts == \"1\":\n                    self.logDebug('Using stored values')\n                    multiply = self.getStorage(\"multiply\")\n                    modulo = self.getStorage(\"modulo\")\n                elif swf_sts == \"2\":\n                    if swf_version < self.__version__:\n                        self.logDebug('Reverting to default values')\n                        self.setStorage(\"swf_sts\", \"\")\n                        self.setStorage(\"version\", self.__version__)\n                        multiply, modulo = self.LAST_KNOWN_VALUES\n                    elif (swf_stamp + 3600000) < timestamp():\n                        swfdump = self.get_swfdump_path()\n                        if swfdump:\n                            multiply, modulo = self.get_swf_values(self.file_info['HOST'] + swf_url, swfdump)\n                        else:\n                            self.logWarning(\"Swfdump not found. Install swftools to bypass captcha.\")\n\n                if multiply and modulo:\n                    self.logDebug(\"TIME = (%s * %s) %s\" % (file_seed, multiply, modulo))\n                    url = \"/download?key=%s&time=%d\" % (self.file_info['KEY'],\n                                                        (int(file_seed) * int(multiply)) % int(modulo))\n\n            if not url:\n                #Method #3: Captcha\n                url = self.do_recaptcha()\n\n        return self.file_info['HOST'] + url\n\n    def get_swf_values(self, swf_url, swfdump):\n        self.logDebug('Parsing values from %s' % swf_url)\n        multiply = modulo = None\n\n        fd, fpath = tempfile.mkstemp()\n        try:\n            swf_data = self.load(swf_url)\n            os.write(fd, swf_data)\n\n            p = subprocess.Popen([swfdump, '-a', fpath], stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n            out, err = p.communicate()\n\n            if err:\n                self.logError(err)\n            else:\n                m_str = re.search(r'::break.*?{(.*?)}', out, re.S).group(1)\n                multiply = re.search(r'pushbyte (\\d+)', m_str).group(1)\n                modulo = re.search(r'pushint (\\d+)', m_str).group(1)\n        finally:\n            os.close(fd)\n            os.remove(fpath)\n\n        if multiply and modulo:\n            self.setStorage(\"multiply\", multiply)\n            self.setStorage(\"modulo\", modulo)\n            self.setStorage(\"swf_sts\", 1)\n            self.setStorage(\"version\", self.__version__)\n        else:\n            self.logError(\"Parsing SWF failed: swfdump not installed or plugin out of date\")\n            self.setStorage(\"swf_sts\", 2)\n\n        self.setStorage(\"swf_stamp\", timestamp())\n\n        return multiply, modulo\n\n    def get_swfdump_path(self):\n        # used for detecting if swfdump is installed\n        def is_exe(ppath):\n            return os.path.isfile(ppath) and os.access(ppath, os.X_OK)\n\n        program = self.getConfig(\"swfdump_path\") or \"swfdump\"\n        swfdump = None\n        ppath, pname = os.path.split(program)\n        if ppath:\n            if is_exe(program):\n                swfdump = program\n        else:\n            for ppath in os.environ[\"PATH\"].split(os.pathsep):\n                exe_file = os.path.join(ppath, program)\n                if is_exe(exe_file):\n                    swfdump = exe_file\n\n        # return path to the executable or None if not found\n        return swfdump\n\n    def do_recaptcha(self):\n        self.logDebug('Trying to solve captcha')\n        captcha_key = re.search(self.CAPTCHA_KEY_PATTERN, self.html).group(1)\n        shortencode = re.search(self.CAPTCHA_SHORTENCODE_PATTERN, self.html).group(1)\n        url = re.search(self.CAPTCHA_DOWNLOAD_PATTERN, self.html).group(1)\n\n        recaptcha = ReCaptcha(self)\n\n        for i in range(5):\n            challenge, code = recaptcha.challenge(captcha_key)\n\n            response = json_loads(self.load(self.file_info['HOST'] + '/rest/captcha/test',\n                                            post={'challenge': challenge,\n                                                  'response': code,\n                                                  'shortencode': shortencode}))\n            self.logDebug(\"reCaptcha response : %s\" % response)\n            if response == True:\n                self.correctCaptcha()\n                break\n            else:\n                self.invalidCaptcha()\n        else:\n            self.fail(\"Invalid captcha\")\n\n        return url\n\n\ngetInfo = create_getInfo(ZippyshareCom)\n", "path": "module/plugins/hoster/ZippyshareCom.py"}], "after_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport re\nimport subprocess\nimport tempfile\nimport os\n\nfrom module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, timestamp\nfrom module.plugins.internal.CaptchaService import ReCaptcha\nfrom module.common.json_layer import json_loads\n\n\nclass ZippyshareCom(SimpleHoster):\n    __name__ = \"ZippyshareCom\"\n    __type__ = \"hoster\"\n    __pattern__ = r\"(?P<HOST>http://www\\d{0,2}\\.zippyshare.com)/v(?:/|iew.jsp.*key=)(?P<KEY>\\d+)\"\n    __version__ = \"0.39\"\n    __description__ = \"\"\"Zippyshare.com Download Hoster\"\"\"\n    __author_name__ = (\"spoob\", \"zoidberg\", \"stickell\")\n    __author_mail__ = (\"spoob@pyload.org\", \"zoidberg@mujmail.cz\", \"l.stickell@yahoo.it\")\n    __config__ = [(\"swfdump_path\", \"string\", \"Path to swfdump\", \"\")]\n\n    FILE_NAME_PATTERN = r'>Name:</font>\\s*<font [^>]*>(?P<N>[^<]+)</font><br />'\n    FILE_SIZE_PATTERN = r'>Size:</font>\\s*<font [^>]*>(?P<S>[0-9.,]+) (?P<U>[kKMG]+)i?B</font><br />'\n    FILE_INFO_PATTERN = r'document\\.getElementById\\(\\'dlbutton\\'\\)\\.href = \"[^;]*/(?P<N>[^\"]+)\";'\n    FILE_OFFLINE_PATTERN = r'>File does not exist on this server</div>'\n\n    DOWNLOAD_URL_PATTERN = r\"<script type=\\\"text/javascript\\\">([^<]*?)(document\\.getElementById\\('dlbutton'\\).href = [^;]+;)\"\n    SEED_PATTERN = r'swfobject.embedSWF\\(\"([^\"]+)\".*?seed: (\\d+)'\n    CAPTCHA_KEY_PATTERN = r'Recaptcha.create\\(\"([^\"]+)\"'\n    CAPTCHA_SHORTENCODE_PATTERN = r\"shortencode: '([^']+)'\"\n    CAPTCHA_DOWNLOAD_PATTERN = r\"document.location = '([^']+)'\"\n\n    LAST_KNOWN_VALUES = (9, 2374755)  # time = (seed * multiply) % modulo\n\n    def setup(self):\n        self.html = None\n        self.wantReconnect = False\n        self.multiDL = True\n\n    def handleFree(self):\n        url = self.get_file_url()\n        if not url:\n            self.fail(\"Download URL not found.\")\n        self.logDebug(\"Download URL %s\" % url)\n        self.download(url, cookies=True)\n\n        check = self.checkDownload({\n            \"swf_values\": re.compile(self.SEED_PATTERN)\n        })\n\n        if check == \"swf_values\":\n            swf_sts = self.getStorage(\"swf_sts\")\n            if not swf_sts:\n                self.setStorage(\"swf_sts\", 2)\n                self.setStorage(\"swf_stamp\", 0)\n            elif swf_sts == '1':\n                self.setStorage(\"swf_sts\", 2)\n\n            self.retry(max_tries=1)\n\n    def get_file_url(self):\n        \"\"\" returns the absolute downloadable filepath\n        \"\"\"\n        url = multiply = modulo = None\n\n        found = re.search(self.DOWNLOAD_URL_PATTERN, self.html, re.S)\n        if found:\n            #Method #1: JS eval\n            js = \"\\n\".join(found.groups())\n            d = re.search(r'span id=\"omg\" class=\"(\\d*)\"', self.html).group(1)\n            regex = r\"document.getElementById\\('omg'\\).getAttribute\\('class'\\)\"\n            js = re.sub(regex, d, js)\n            regex = r\"document.getElementById\\(\\\\*'dlbutton\\\\*'\\).href = \"\n            js = re.sub(regex, '', js)\n            url = self.js.eval(js)\n        else:\n            #Method #2: SWF eval\n            seed_search = re.search(self.SEED_PATTERN, self.html)\n            if seed_search:\n                swf_url, file_seed = seed_search.groups()\n\n                swf_sts = self.getStorage(\"swf_sts\")\n                swf_stamp = int(self.getStorage(\"swf_stamp\") or 0)\n                swf_version = self.getStorage(\"version\")\n                self.logDebug(\"SWF\", swf_sts, swf_stamp, swf_version)\n\n                if not swf_sts:\n                    self.logDebug('Using default values')\n                    multiply, modulo = self.LAST_KNOWN_VALUES\n                elif swf_sts == \"1\":\n                    self.logDebug('Using stored values')\n                    multiply = self.getStorage(\"multiply\")\n                    modulo = self.getStorage(\"modulo\")\n                elif swf_sts == \"2\":\n                    if swf_version < self.__version__:\n                        self.logDebug('Reverting to default values')\n                        self.setStorage(\"swf_sts\", \"\")\n                        self.setStorage(\"version\", self.__version__)\n                        multiply, modulo = self.LAST_KNOWN_VALUES\n                    elif (swf_stamp + 3600000) < timestamp():\n                        swfdump = self.get_swfdump_path()\n                        if swfdump:\n                            multiply, modulo = self.get_swf_values(self.file_info['HOST'] + swf_url, swfdump)\n                        else:\n                            self.logWarning(\"Swfdump not found. Install swftools to bypass captcha.\")\n\n                if multiply and modulo:\n                    self.logDebug(\"TIME = (%s * %s) %s\" % (file_seed, multiply, modulo))\n                    url = \"/download?key=%s&time=%d\" % (self.file_info['KEY'],\n                                                        (int(file_seed) * int(multiply)) % int(modulo))\n\n            if not url:\n                #Method #3: Captcha\n                url = self.do_recaptcha()\n\n        return self.file_info['HOST'] + url\n\n    def get_swf_values(self, swf_url, swfdump):\n        self.logDebug('Parsing values from %s' % swf_url)\n        multiply = modulo = None\n\n        fd, fpath = tempfile.mkstemp()\n        try:\n            swf_data = self.load(swf_url)\n            os.write(fd, swf_data)\n\n            p = subprocess.Popen([swfdump, '-a', fpath], stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n            out, err = p.communicate()\n\n            if err:\n                self.logError(err)\n            else:\n                m_str = re.search(r'::break.*?{(.*?)}', out, re.S).group(1)\n                multiply = re.search(r'pushbyte (\\d+)', m_str).group(1)\n                modulo = re.search(r'pushint (\\d+)', m_str).group(1)\n        finally:\n            os.close(fd)\n            os.remove(fpath)\n\n        if multiply and modulo:\n            self.setStorage(\"multiply\", multiply)\n            self.setStorage(\"modulo\", modulo)\n            self.setStorage(\"swf_sts\", 1)\n            self.setStorage(\"version\", self.__version__)\n        else:\n            self.logError(\"Parsing SWF failed: swfdump not installed or plugin out of date\")\n            self.setStorage(\"swf_sts\", 2)\n\n        self.setStorage(\"swf_stamp\", timestamp())\n\n        return multiply, modulo\n\n    def get_swfdump_path(self):\n        # used for detecting if swfdump is installed\n        def is_exe(ppath):\n            return os.path.isfile(ppath) and os.access(ppath, os.X_OK)\n\n        program = self.getConfig(\"swfdump_path\") or \"swfdump\"\n        swfdump = None\n        ppath, pname = os.path.split(program)\n        if ppath:\n            if is_exe(program):\n                swfdump = program\n        else:\n            for ppath in os.environ[\"PATH\"].split(os.pathsep):\n                exe_file = os.path.join(ppath, program)\n                if is_exe(exe_file):\n                    swfdump = exe_file\n\n        # return path to the executable or None if not found\n        return swfdump\n\n    def do_recaptcha(self):\n        self.logDebug('Trying to solve captcha')\n        captcha_key = re.search(self.CAPTCHA_KEY_PATTERN, self.html).group(1)\n        shortencode = re.search(self.CAPTCHA_SHORTENCODE_PATTERN, self.html).group(1)\n        url = re.search(self.CAPTCHA_DOWNLOAD_PATTERN, self.html).group(1)\n\n        recaptcha = ReCaptcha(self)\n\n        for i in range(5):\n            challenge, code = recaptcha.challenge(captcha_key)\n\n            response = json_loads(self.load(self.file_info['HOST'] + '/rest/captcha/test',\n                                            post={'challenge': challenge,\n                                                  'response': code,\n                                                  'shortencode': shortencode}))\n            self.logDebug(\"reCaptcha response : %s\" % response)\n            if response == True:\n                self.correctCaptcha()\n                break\n            else:\n                self.invalidCaptcha()\n        else:\n            self.fail(\"Invalid captcha\")\n\n        return url\n\n\ngetInfo = create_getInfo(ZippyshareCom)\n", "path": "module/plugins/hoster/ZippyshareCom.py"}]}