diff options
author | Nitzo <nitzo2001@yahoo.com> | 2016-06-18 21:19:06 +0200 |
---|---|---|
committer | Nitzo <nitzo2001@yahoo.com> | 2016-06-18 21:19:06 +0200 |
commit | 23c50ea340b96bc0f2d6746a070d5564dfe1cad3 (patch) | |
tree | b5255a46e105f3e2acd5fc8576d1c91b6cd6ace4 /module/plugins/hoster | |
parent | [MegaCoNz] Update (diff) | |
download | pyload-23c50ea340b96bc0f2d6746a070d5564dfe1cad3.tar.xz |
[BitshareCom] Dead, fix #2510
Diffstat (limited to 'module/plugins/hoster')
-rw-r--r-- | module/plugins/hoster/BitshareCom.py | 151 |
1 files changed, 4 insertions, 147 deletions
diff --git a/module/plugins/hoster/BitshareCom.py b/module/plugins/hoster/BitshareCom.py index 54f413d13..7d7de1d88 100644 --- a/module/plugins/hoster/BitshareCom.py +++ b/module/plugins/hoster/BitshareCom.py @@ -1,161 +1,18 @@ # -*- coding: utf-8 -*- -from __future__ import with_statement +from module.plugins.internal.DeadHoster import DeadHoster -import re -from module.plugins.captcha.ReCaptcha import ReCaptcha -from module.plugins.internal.SimpleHoster import SimpleHoster - - -class BitshareCom(SimpleHoster): +class BitshareCom(DeadHoster): __name__ = "BitshareCom" __type__ = "hoster" - __version__ = "0.60" + __version__ = "0.61" __status__ = "testing" __pattern__ = r'http://(?:www\.)?bitshare\.com/(files/)?(?(1)|\?f=)(?P<ID>\w+)(?(1)/(?P<NAME>.+?)\.html)' - __config__ = [("activated" , "bool", "Activated" , True), - ("use_premium" , "bool", "Use premium account if available" , True), - ("fallback" , "bool", "Fallback to free download if premium fails" , True), - ("chk_filesize", "bool", "Check file size" , True), - ("max_wait" , "int" , "Reconnect if waiting time is greater than minutes", 10 )] + __config__ = [("activated" , "bool", "Activated", True)] __description__ = """Bitshare.com hoster plugin""" __license__ = "GPLv3" __authors__ = [("Paul King", None), ("fragonib", "fragonib[AT]yahoo[DOT]es")] - - - COOKIES = [("bitshare.com", "language_selection", "EN")] - - INFO_PATTERN = r'Downloading (?P<N>.+) - (?P<S>[\d.,]+) (?P<U>[\w^_]+)</h1>' - OFFLINE_PATTERN = r'[Ff]ile (not available|was deleted|was not found)' - - AJAXID_PATTERN = r'var ajaxdl = "(.*?)";' - TRAFFIC_USED_UP = r'Your Traffic is used up for today' - - - def setup(self): - self.multiDL = self.premium - self.chunk_limit = 1 - - - def process(self, pyfile): - if self.premium: - self.account.relogin() - - #: File id - m = re.match(self.__pattern__, pyfile.url) - self.file_id = max(m.group('ID1'), m.group('ID2')) - self.log_debug("File id is [%s]" % self.file_id) - - #: Load main page - self.data = self.load(pyfile.url, ref=False) - - #: Check offline - if re.search(self.OFFLINE_PATTERN, self.data): - self.offline() - - #: Check Traffic used up - if re.search(self.TRAFFIC_USED_UP, self.data): - self.log_info(_("Your Traffic is used up for today")) - self.wait(30 * 60, True) - self.retry() - - #: File name - m = re.match(self.__pattern__, pyfile.url) - name1 = m.group('NAME') if m else None - - m = re.search(self.INFO_PATTERN, self.data) - name2 = m.group('N') if m else None - - pyfile.name = max(name1, name2) - - #: Ajax file id - self.ajaxid = re.search(self.AJAXID_PATTERN, self.data).group(1) - self.log_debug("File ajax id is [%s]" % self.ajaxid) - - #: This may either download our file or forward us to an error page - self.link = self.get_download_url() - - if self.scan_download({'error': ">Error occured<"}): - self.retry(5, 5 * 60, "Bitshare host : Error occured") - - - def get_download_url(self): - #: Return location if direct download is active - if self.premium: - header = self.load(self.pyfile.url, just_header=True) - if 'location' in header: - return header.get('location') - - #: Get download info - self.log_debug("Getting download info") - res = self.load("http://bitshare.com/files-ajax/" + self.file_id + "/request.html", - post={'request': "generateID", 'ajaxid': self.ajaxid}) - - self.handle_errors(res, ':') - - parts = res.split(":") - filetype = parts[0] - wait = int(parts[1]) - captcha = int(parts[2]) - - self.log_debug("Download info [type: '%s', waiting: %d, captcha: %d]" % (filetype, wait, captcha)) - - #: Waiting - if wait > 0: - self.log_debug("Waiting %d seconds." % wait) - if wait < 120: - self.wait(wait, False) - else: - self.wait(wait - 55, True) - self.retry() - - #: Resolve captcha - if captcha == 1: - self.log_debug("File is captcha protected") - self.captcha = ReCaptcha(self.pyfile) - - response, challenge = self.captcha.challenge() - res = self.load("http://bitshare.com/files-ajax/" + self.file_id + "/request.html", - post={'request' : "validateCaptcha", - 'ajaxid' : self.ajaxid, - 'recaptcha_challenge_field': challenge, - 'recaptcha_response_field' : response}) - - self.handle_captcha_errors(res) - - #: Get download URL - self.log_debug("Getting download url") - res = self.load("http://bitshare.com/files-ajax/" + self.file_id + "/request.html", - post={'request': "getDownloadURL", 'ajaxid': self.ajaxid}) - - self.handle_errors(res, '#') - - url = res.split("#")[-1] - - return url - - - def handle_errors(self, res, separator): - self.log_debug("Checking response [%s]" % res) - if "ERROR:Session timed out" in res: - self.retry() - - elif "ERROR" in res: - msg = res.split(separator)[-1] - self.fail(msg) - - - def handle_captcha_errors(self, res): - self.log_debug("Result of captcha resolving [%s]" % res) - if "SUCCESS" in res: - self.captcha.correct() - - elif "ERROR:SESSION ERROR" in res: - self.retry() - - else: - self.retry_captcha() |