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.py53
1 files changed, 35 insertions, 18 deletions
diff --git a/module/plugins/hoster/BitshareCom.py b/module/plugins/hoster/BitshareCom.py
index 794e978b2..f5d59d428 100644
--- a/module/plugins/hoster/BitshareCom.py
+++ b/module/plugins/hoster/BitshareCom.py
@@ -2,6 +2,7 @@
from __future__ import with_statement
import re
+from pycurl import FOLLOWLOCATION
from module.plugins.Hoster import Hoster
from module.plugins.ReCaptcha import ReCaptcha
@@ -45,22 +46,24 @@ class BitshareCom(Hoster):
__name__ = "BitshareCom"
__type__ = "hoster"
__pattern__ = r"http://(www\.)?bitshare\.com/(files/(?P<id1>[a-zA-Z0-9]+)(/(?P<name>.*?)\.html)?|\?f=(?P<id2>[a-zA-Z0-9]+))"
- __version__ = "0.41"
+ __version__ = "0.45"
__description__ = """Bitshare.Com File Download Hoster"""
__author_name__ = ("paulking", "fragonib")
__author_mail__ = (None, "fragonib[AT]yahoo[DOT]es")
HOSTER_DOMAIN = "bitshare.com"
FILE_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_INFO_PATTERN = r'<h1>Downloading\s(?P<name>.+?)\s-\s(?P<size>[\d.]+)\s(?P<units>..)yte</h1>'
+ FILE_INFO_PATTERN = r'<h1>(Downloading|Streaming)\s(?P<name>.+?)\s-\s(?P<size>[\d.]+)\s(?P<units>..)yte</h1>'
FILE_AJAXID_PATTERN = r'var ajaxdl = "(.*?)";'
CAPTCHA_KEY_PATTERN = r"http://api\.recaptcha\.net/challenge\?k=(.*?) "
def setup(self):
- self.multiDL = False
+ self.multiDL = self.premium
self.chunkLimit = 1
def process(self, pyfile):
+ if self.premium:
+ self.account.relogin(self.user)
self.pyfile = pyfile
@@ -71,7 +74,7 @@ class BitshareCom(Hoster):
# Load main page
self.req.cj.setCookie(self.HOSTER_DOMAIN, "language_selection", "EN")
- self.html = self.load(self.pyfile.url, ref=False, decode=True)
+ self.html = self.load(self.pyfile.url, ref=False, decode=True, cookies = False)
# Check offline
if re.search(self.FILE_OFFLINE_PATTERN, self.html) is not None:
@@ -87,12 +90,20 @@ class BitshareCom(Hoster):
# Ajax file id
self.ajaxid = re.search(BitshareCom.FILE_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)
- # Handle free downloading
- self.handleFree()
-
- def handleFree(self):
-
+
+ def getDownloadUrl(self):
+ # Return location if direct download is active
+ if self.premium:
+ header = self.load(self.pyfile.url, cookies = True, just_header = True)
+ if 'location' in header:
+ return header['location']
+
# Get download info
self.logDebug("Getting download info")
response = self.load("http://bitshare.com/files-ajax/" + self.file_id + "/request.html",
@@ -107,8 +118,13 @@ class BitshareCom(Hoster):
# Waiting
if wait > 0:
self.logDebug("Waiting %d seconds." % wait)
- self.setWait(wait, True)
- self.wait()
+ if wait < 120:
+ self.setWait(wait, False)
+ self.wait()
+ else:
+ self.setWait(wait - 55, True)
+ self.wait()
+ self.retry()
# Resolve captcha
if captcha == 1:
@@ -131,15 +147,14 @@ class BitshareCom(Hoster):
post={"request" : "getDownloadURL", "ajaxid" : self.ajaxid})
self.handleErrors(response, '#')
url = response.split("#")[-1]
-
- # Request download URL
- # This may either download our file or forward us to an error page
- self.logDebug("Downloading file with url [%s]" % url)
- self.download(url)
+ return url
+
def handleErrors(self, response, separator):
self.logDebug("Checking response [%s]" % response)
- if "ERROR" in response:
+ if "ERROR:Session timed out" in response:
+ self.retry()
+ elif "ERROR" in response:
msg = response.split(separator)[-1]
self.fail(msg)
@@ -148,5 +163,7 @@ class BitshareCom(Hoster):
if "SUCCESS" in response:
self.correctCaptcha()
return True
+ elif "ERROR:SESSION ERROR" in response:
+ self.retry()
self.logDebug("Wrong captcha")
- self.invalidCaptcha() \ No newline at end of file
+ self.invalidCaptcha()