summaryrefslogtreecommitdiffstats
path: root/module/plugins/hoster/CrockoCom.py
diff options
context:
space:
mode:
authorGravatar zoidberg10 <zoidberg@mujmail.cz> 2011-11-23 12:20:54 +0100
committerGravatar zoidberg10 <zoidberg@mujmail.cz> 2011-11-23 12:20:54 +0100
commitca42a34b0803ca58a68b79ae58fddc0905c5d73a (patch)
tree63f3cb6c695acf51a6972d1337345757489bb339 /module/plugins/hoster/CrockoCom.py
parentadd 2shared.com (diff)
downloadpyload-ca42a34b0803ca58a68b79ae58fddc0905c5d73a.tar.xz
fix 4shared, replace easy-share with crocko
Diffstat (limited to 'module/plugins/hoster/CrockoCom.py')
-rw-r--r--module/plugins/hoster/CrockoCom.py70
1 files changed, 70 insertions, 0 deletions
diff --git a/module/plugins/hoster/CrockoCom.py b/module/plugins/hoster/CrockoCom.py
new file mode 100644
index 000000000..7eafa67ed
--- /dev/null
+++ b/module/plugins/hoster/CrockoCom.py
@@ -0,0 +1,70 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo
+from module.plugins.ReCaptcha import ReCaptcha
+import re
+
+class CrockoCom(SimpleHoster):
+ __name__ = "CrockoCom"
+ __type__ = "hoster"
+ __pattern__ = r"http://(www\.)?(crocko|easy-share).com/.*"
+ __version__ = "0.10"
+ __description__ = """Crocko Download Hoster"""
+ __author_name__ = ("zoidberg")
+ __author_mail__ = ("zoidberg@mujmail.cz")
+
+ FILE_INFO_PATTERN = r'<strong>(?P<N>.*)\s*<span class="tip1"><span class="inner">(?P<S>[0-9,.]+) (?P<U>[kKMG])i?B</span></span>'
+ FILE_OFFLINE_PATTERN = r"<h1>Sorry,<br />the page you're looking for <br />isn't here.</h1>"
+ 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="?([^" ]+)"?[^>]*>'
+
+ 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:
+ 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
+
+ found = re.search(self.CAPTCHA_KEY_PATTERN, self.html)
+ 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')
+ 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)
+
+ check = self.checkDownload({
+ "captcha_err": self.CAPTCHA_KEY_PATTERN
+ })
+
+ if check == "captcha_err":
+ self.invalidCaptcha()
+ else:
+ break
+ else:
+ self.fail('No valid captcha solution received')
+
+getInfo = create_getInfo(CrockoCom)
+ \ No newline at end of file