summaryrefslogtreecommitdiffstats
path: root/module/plugins/hoster/CrockoCom.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/hoster/CrockoCom.py')
-rw-r--r--module/plugins/hoster/CrockoCom.py41
1 files changed, 22 insertions, 19 deletions
diff --git a/module/plugins/hoster/CrockoCom.py b/module/plugins/hoster/CrockoCom.py
index f075d073b..7d5336cd9 100644
--- a/module/plugins/hoster/CrockoCom.py
+++ b/module/plugins/hoster/CrockoCom.py
@@ -1,15 +1,17 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
+import re
+
from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo
from module.plugins.internal.CaptchaService import ReCaptcha
-import re
+
class CrockoCom(SimpleHoster):
__name__ = "CrockoCom"
__type__ = "hoster"
__pattern__ = r"http://(www\.)?(crocko|easy-share).com/.*"
- __version__ = "0.13"
+ __version__ = "0.14"
__description__ = """Crocko Download Hoster"""
__author_name__ = ("zoidberg")
__author_mail__ = ("zoidberg@mujmail.cz")
@@ -20,45 +22,46 @@ class CrockoCom(SimpleHoster):
DOWNLOAD_URL_PATTERN = r"window.location ='([^']+)';"
CAPTCHA_URL_PATTERN = re.compile(r"u='(/file_contents/captcha/\w+)';\s*w='(\d+)';")
CAPTCHA_KEY_PATTERN = re.compile(r'Recaptcha.create\("([^"]+)"')
-
+
FORM_PATTERN = r'<form method="post" action="([^"]+)">(.*?)</form>'
FORM_INPUT_PATTERN = r'<input[^>]* name="?([^" ]+)"? value="?([^" ]+)"?[^>]*>'
-
+
FILE_NAME_REPLACEMENTS = [(r'<[^>]*>', '')]
def handleFree(self):
if "You need Premium membership to download this file." in self.html:
self.fail("You need Premium membership to download this file.")
-
- url = False
+
for i in range(5):
found = re.search(self.CAPTCHA_URL_PATTERN, self.html)
- if found:
+ if found:
url, wait_time = 'http://crocko.com' + found.group(1), found.group(2)
self.setWait(wait_time)
self.wait()
self.html = self.load(url)
- else:
- break
-
+ else:
+ break
+
found = re.search(self.CAPTCHA_KEY_PATTERN, self.html)
- if not found: self.parseError('Captcha KEY')
+ if not found:
+ self.parseError('Captcha KEY')
captcha_key = found.group(1)
-
+
found = re.search(self.FORM_PATTERN, self.html, re.DOTALL)
- if not found: self.parseError('ACTION')
+ if not found:
+ self.parseError('ACTION')
action, form = found.groups()
inputs = dict(re.findall(self.FORM_INPUT_PATTERN, form))
-
+
recaptcha = ReCaptcha(self)
-
+
for i in range(5):
inputs['recaptcha_challenge_field'], inputs['recaptcha_response_field'] = recaptcha.challenge(captcha_key)
- self.download(action, post = inputs)
-
+ self.download(action, post=inputs)
+
check = self.checkDownload({
"captcha_err": self.CAPTCHA_KEY_PATTERN
- })
+ })
if check == "captcha_err":
self.invalidCaptcha()
@@ -67,5 +70,5 @@ class CrockoCom(SimpleHoster):
else:
self.fail('No valid captcha solution received')
+
getInfo = create_getInfo(CrockoCom)
- \ No newline at end of file