From acc46fc3497a66a427b795b4a22c6e71d69185a1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 13 Dec 2014 15:56:57 +0100 Subject: Update --- pyload/plugin/hoster/CzshareCom.py | 152 +++++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 pyload/plugin/hoster/CzshareCom.py (limited to 'pyload/plugin/hoster/CzshareCom.py') diff --git a/pyload/plugin/hoster/CzshareCom.py b/pyload/plugin/hoster/CzshareCom.py new file mode 100644 index 000000000..2297450e4 --- /dev/null +++ b/pyload/plugin/hoster/CzshareCom.py @@ -0,0 +1,152 @@ +# -*- coding: utf-8 -*- +# +# Test links: +# http://czshare.com/5278880/random.bin + +import re + +from pyload.plugin.internal.SimpleHoster import SimpleHoster, create_getInfo +from pyload.utils import parseFileSize + + +class CzshareCom(SimpleHoster): + __name = "CzshareCom" + __type = "hoster" + __version = "0.95" + + __pattern = r'http://(?:www\.)?(czshare|sdilej)\.(com|cz)/(\d+/|download\.php\?).*' + + __description = """CZshare.com hoster plugin, now Sdilej.cz""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz")] + + + NAME_PATTERN = r'
\s*

\s*Cel. n.zev: ]*>(?P[^<]+)' + SIZE_PATTERN = r'

(?:\s*

[^\n]*

)*\s*Velikost:\s*(?P[\d .,]+)(?P[\w^_]+)\s*
' + OFFLINE_PATTERN = r'
\s*

' + + SIZE_REPLACEMENTS = [(' ', '')] + URL_REPLACEMENTS = [(r'http://[^/]*/download.php\?.*?id=(\w+).*', r'http://sdilej.cz/\1/x/')] + + FORCE_CHECK_TRAFFIC = True + + FREE_URL_PATTERN = r'[^>]*alt="([^"]+)" />' + FREE_FORM_PATTERN = r'
\s*(.*?)
' + PREMIUM_FORM_PATTERN = r'
(.*?)
' + FORM_INPUT_PATTERN = r']* name="([^"]+)" value="([^"]+)"[^>]*/>' + MULTIDL_PATTERN = r'

Z[^<]*PROFI.

' + USER_CREDIT_PATTERN = r'
\s*kredit: ([\d .,]+)(\w+)\s*
' + + + def checkTrafficLeft(self): + # check if user logged in + m = re.search(self.USER_CREDIT_PATTERN, self.html) + if m is None: + self.account.relogin(self.user) + self.html = self.load(self.pyfile.url, cookies=True, decode=True) + m = re.search(self.USER_CREDIT_PATTERN, self.html) + if m is None: + return False + + # check user credit + try: + credit = parseFileSize(m.group(1).replace(' ', ''), m.group(2)) + self.logInfo(_("Premium download for %i KiB of Credit") % (self.pyfile.size / 1024)) + self.logInfo(_("User %s has %i KiB left") % (self.user, credit / 1024)) + if credit < self.pyfile.size: + self.logInfo(_("Not enough credit to download file: %s") % self.pyfile.name) + return False + except Exception, e: + # let's continue and see what happens... + self.logError(e) + + return True + + + def handlePremium(self): + # parse download link + try: + form = re.search(self.PREMIUM_FORM_PATTERN, self.html, re.S).group(1) + inputs = dict(re.findall(self.FORM_INPUT_PATTERN, form)) + except Exception, e: + self.logError(e) + self.resetAccount() + + # download the file, destination is determined by pyLoad + self.download("http://sdilej.cz/profi_down.php", post=inputs, disposition=True) + self.checkDownloadedFile() + + + def handleFree(self): + # get free url + m = re.search(self.FREE_URL_PATTERN, self.html) + if m is None: + self.error(_("FREE_URL_PATTERN not found")) + parsed_url = "http://sdilej.cz" + m.group(1) + self.logDebug("PARSED_URL:" + parsed_url) + + # get download ticket and parse html + self.html = self.load(parsed_url, cookies=True, decode=True) + if re.search(self.MULTIDL_PATTERN, self.html): + self.longWait(5 * 60, 12) + + try: + form = re.search(self.FREE_FORM_PATTERN, self.html, re.S).group(1) + inputs = dict(re.findall(self.FORM_INPUT_PATTERN, form)) + self.pyfile.size = int(inputs['size']) + except Exception, e: + self.logError(e) + self.error(_("Form")) + + # get and decrypt captcha + captcha_url = 'http://sdilej.cz/captcha.php' + for _i in xrange(5): + inputs['captchastring2'] = self.decryptCaptcha(captcha_url) + self.html = self.load(parsed_url, cookies=True, post=inputs, decode=True) + if u"
  • Zadaný ověřovací kód nesouhlasí!
  • " in self.html: + self.invalidCaptcha() + elif re.search(self.MULTIDL_PATTERN, self.html): + self.longWait(5 * 60, 12) + else: + self.correctCaptcha() + break + else: + self.fail(_("No valid captcha code entered")) + + m = re.search("countdown_number = (\d+);", self.html) + self.setWait(int(m.group(1)) if m else 50) + + # download the file, destination is determined by pyLoad + self.logDebug("WAIT URL", self.req.lastEffectiveURL) + m = re.search("free_wait.php\?server=(.*?)&(.*)", self.req.lastEffectiveURL) + if m is None: + self.error(_("Download URL not found")) + + url = "http://%s/download.php?%s" % (m.group(1), m.group(2)) + + self.wait() + self.download(url) + self.checkDownloadedFile() + + + def checkDownloadedFile(self): + # check download + check = self.checkDownload({ + "temp_offline": re.compile(r"^Soubor je do.*asn.* nedostupn.*$"), + "credit": re.compile(r"^Nem.*te dostate.*n.* kredit.$"), + "multi_dl": re.compile(self.MULTIDL_PATTERN), + "captcha_err": "
  • Zadaný ověřovací kód nesouhlasí!
  • " + }) + + if check == "temp_offline": + self.fail(_("File not available - try later")) + if check == "credit": + self.resetAccount() + elif check == "multi_dl": + self.longWait(5 * 60, 12) + elif check == "captcha_err": + self.invalidCaptcha() + self.retry() + + +getInfo = create_getInfo(CzshareCom) -- cgit v1.2.3