summaryrefslogtreecommitdiffstats
path: root/module/plugins/hoster/BitshareCom.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/hoster/BitshareCom.py')
-rw-r--r--module/plugins/hoster/BitshareCom.py80
1 files changed, 42 insertions, 38 deletions
diff --git a/module/plugins/hoster/BitshareCom.py b/module/plugins/hoster/BitshareCom.py
index 3c84ce5da..da393f8fc 100644
--- a/module/plugins/hoster/BitshareCom.py
+++ b/module/plugins/hoster/BitshareCom.py
@@ -9,29 +9,32 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo
class BitshareCom(SimpleHoster):
- __name__ = "BitshareCom"
- __type__ = "hoster"
- __version__ = "0.50"
+ __name__ = "BitshareCom"
+ __type__ = "hoster"
+ __version__ = "0.51"
- __pattern__ = r'http://(?:www\.)?bitshare\.com/(files/(?P<id1>[a-zA-Z0-9]+)(/(?P<name>.*?)\.html)?|\?f=(?P<id2>[a-zA-Z0-9]+))'
+ __pattern__ = r'http://(?:www\.)?bitshare\.com/(files/(?P<id1>\w+)(/(?P<name>.*?)\.html)?|\?f=(?P<id2>\w+))'
__description__ = """Bitshare.com hoster plugin"""
- __author_name__ = ("Paul King", "fragonib")
- __author_mail__ = ("", "fragonib[AT]yahoo[DOT]es")
+ __license__ = "GPLv3"
+ __authors__ = [("Paul King", None),
+ ("fragonib", "fragonib[AT]yahoo[DOT]es")]
- FILE_INFO_PATTERN = r'Downloading (?P<N>.+) - (?P<S>[\d.]+) (?P<U>\w+)</h1>'
+
+ INFO_PATTERN = r'Downloading (?P<N>.+) - (?P<S>[\d.,]+) (?P<U>[\w^_]+)</h1>'
OFFLINE_PATTERN = r'(>We are sorry, but the requested file was not found in our database|>Error - File not available<|The file was deleted either by the uploader, inactivity or due to copyright claim)'
- FILE_AJAXID_PATTERN = r'var ajaxdl = "(.*?)";'
- CAPTCHA_KEY_PATTERN = r'http://api\.recaptcha\.net/challenge\?k=(.*?) '
+ COOKIES = [("bitshare.com", "language_selection", "EN")]
+
+ AJAXID_PATTERN = r'var ajaxdl = "(.*?)";'
TRAFFIC_USED_UP = r'Your Traffic is used up for today. Upgrade to premium to continue!'
def setup(self):
- self.req.cj.setCookie(".bitshare.com", "language_selection", "EN")
self.multiDL = self.premium
self.chunkLimit = 1
+
def process(self, pyfile):
if self.premium:
self.account.relogin(self.user)
@@ -52,24 +55,23 @@ class BitshareCom(SimpleHoster):
# Check Traffic used up
if re.search(self.TRAFFIC_USED_UP, self.html):
- self.logInfo("Your Traffic is used up for today")
+ self.logInfo(_("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.FILE_INFO_PATTERN, self.html)
+ m = re.search(self.INFO_PATTERN, self.html)
name2 = m.group('N') if m else None
pyfile.name = max(name1, name2)
# Ajax file id
- self.ajaxid = re.search(self.FILE_AJAXID_PATTERN, self.html).group(1)
+ self.ajaxid = re.search(self.AJAXID_PATTERN, self.html).group(1)
self.logDebug("File ajax id is [%s]" % self.ajaxid)
# This may either download our file or forward us to an error page
url = self.getDownloadUrl()
- self.logDebug("Downloading file with url [%s]" % url)
self.download(url)
check = self.checkDownload({"404": ">404 Not Found<", "Error": ">Error occured<"})
@@ -78,6 +80,7 @@ class BitshareCom(SimpleHoster):
elif check == "error":
self.retry(5, 5 * 60, "Bitshare host : Error occured")
+
def getDownloadUrl(self):
# Return location if direct download is active
if self.premium:
@@ -87,10 +90,10 @@ class BitshareCom(SimpleHoster):
# Get download info
self.logDebug("Getting download info")
- response = self.load("http://bitshare.com/files-ajax/" + self.file_id + "/request.html",
- post={"request": "generateID", "ajaxid": self.ajaxid})
- self.handleErrors(response, ':')
- parts = response.split(":")
+ res = self.load("http://bitshare.com/files-ajax/" + self.file_id + "/request.html",
+ post={"request": "generateID", "ajaxid": self.ajaxid})
+ self.handleErrors(res, ':')
+ parts = res.split(":")
filetype = parts[0]
wait = int(parts[1])
captcha = int(parts[2])
@@ -108,43 +111,44 @@ class BitshareCom(SimpleHoster):
# Resolve captcha
if captcha == 1:
self.logDebug("File is captcha protected")
- id = re.search(self.CAPTCHA_KEY_PATTERN, self.html).group(1)
+ recaptcha = ReCaptcha(self)
+
# Try up to 3 times
for i in xrange(3):
- self.logDebug("Resolving ReCaptcha with key [%s], round %d" % (id, i + 1))
- recaptcha = ReCaptcha(self)
- challenge, code = recaptcha.challenge(id)
- response = self.load("http://bitshare.com/files-ajax/" + self.file_id + "/request.html",
+ challenge, code = recaptcha.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": code})
- if self.handleCaptchaErrors(response):
+ if self.handleCaptchaErrors(res):
break
# Get download URL
self.logDebug("Getting download url")
- response = self.load("http://bitshare.com/files-ajax/" + self.file_id + "/request.html",
- post={"request": "getDownloadURL", "ajaxid": self.ajaxid})
- self.handleErrors(response, '#')
- url = response.split("#")[-1]
+ res = self.load("http://bitshare.com/files-ajax/" + self.file_id + "/request.html",
+ post={"request": "getDownloadURL", "ajaxid": self.ajaxid})
+ self.handleErrors(res, '#')
+ url = res.split("#")[-1]
return url
- def handleErrors(self, response, separator):
- self.logDebug("Checking response [%s]" % response)
- if "ERROR:Session timed out" in response:
+
+ def handleErrors(self, res, separator):
+ self.logDebug("Checking response [%s]" % res)
+ if "ERROR:Session timed out" in res:
self.retry()
- elif "ERROR" in response:
- msg = response.split(separator)[-1]
+ elif "ERROR" in res:
+ msg = res.split(separator)[-1]
self.fail(msg)
- def handleCaptchaErrors(self, response):
- self.logDebug("Result of captcha resolving [%s]" % response)
- if "SUCCESS" in response:
+
+ def handleCaptchaErrors(self, res):
+ self.logDebug("Result of captcha resolving [%s]" % res)
+ if "SUCCESS" in res:
self.correctCaptcha()
return True
- elif "ERROR:SESSION ERROR" in response:
+ elif "ERROR:SESSION ERROR" in res:
self.retry()
- self.logDebug("Wrong captcha")
+
self.invalidCaptcha()