From cfdfa4771cd1037363c9937d6bf86f3ab6580b98 Mon Sep 17 00:00:00 2001 From: Stefano Date: Tue, 3 Sep 2013 14:49:34 +0200 Subject: BitshareCom: fixes see #227 --- module/plugins/hoster/BitshareCom.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'module/plugins/hoster/BitshareCom.py') diff --git a/module/plugins/hoster/BitshareCom.py b/module/plugins/hoster/BitshareCom.py index 82c2fe9cb..2b3f7777f 100644 --- a/module/plugins/hoster/BitshareCom.py +++ b/module/plugins/hoster/BitshareCom.py @@ -11,20 +11,20 @@ class BitshareCom(SimpleHoster): __name__ = "BitshareCom" __type__ = "hoster" __pattern__ = r"http://(www\.)?bitshare\.com/(files/(?P[a-zA-Z0-9]+)(/(?P.*?)\.html)?|\?f=(?P[a-zA-Z0-9]+))" - __version__ = "0.48" + __version__ = "0.49" __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_NAME_PATTERN = r'Download:\s*[\d.]+) (?P\w+)' + FILE_INFO_PATTERN = r'Downloading (?P.+) - (?P[\d.]+) (?P\w+)' FILE_AJAXID_PATTERN = r'var ajaxdl = "(.*?)";' CAPTCHA_KEY_PATTERN = r"http://api\.recaptcha\.net/challenge\?k=(.*?) " TRAFFIC_USED_UP = r"Your Traffic is used up for today. Upgrade to premium to continue!" def setup(self): + self.req.cj.setCookie(self.HOSTER_DOMAIN, "language_selection", "EN") self.multiDL = self.premium self.chunkLimit = 1 @@ -40,15 +40,14 @@ class BitshareCom(SimpleHoster): self.logDebug("File id is [%s]" % self.file_id) # Load main page - self.req.cj.setCookie(self.HOSTER_DOMAIN, "language_selection", "EN") self.html = self.load(self.pyfile.url, ref=False, decode=True) # Check offline - if re.search(self.FILE_OFFLINE_PATTERN, self.html) is not None: + if re.search(self.FILE_OFFLINE_PATTERN, self.html): self.offline() # Check Traffic used up - if re.search(BitshareCom.TRAFFIC_USED_UP, self.html) is not None: + if re.search(self.TRAFFIC_USED_UP, self.html): self.logInfo("Your Traffic is used up for today. Wait 1800 seconds or reconnect!") self.logDebug("Waiting %d seconds." % 1800) self.setWait(1800, True) @@ -57,14 +56,14 @@ class BitshareCom(SimpleHoster): self.retry() # File name - m = re.search(BitshareCom.__pattern__, self.pyfile.url) - name1 = m.group('name') if m is not None else None - m = re.search(BitshareCom.FILE_INFO_PATTERN, self.html) - name2 = m.group('name') if m is not None else None + m = re.search(self.__pattern__, self.pyfile.url) + name1 = m.group('name') if m else None + m = re.search(self.FILE_INFO_PATTERN, self.html) + name2 = m.group('N') if m else None self.pyfile.name = max(name1, name2) # Ajax file id - self.ajaxid = re.search(BitshareCom.FILE_AJAXID_PATTERN, self.html).group(1) + self.ajaxid = re.search(self.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 @@ -104,7 +103,7 @@ class BitshareCom(SimpleHoster): # Resolve captcha if captcha == 1: self.logDebug("File is captcha protected") - id = re.search(BitshareCom.CAPTCHA_KEY_PATTERN, self.html).group(1) + id = re.search(self.CAPTCHA_KEY_PATTERN, self.html).group(1) # Try up to 3 times for i in range(3): self.logDebug("Resolving ReCaptcha with key [%s], round %d" % (id, i + 1)) -- cgit v1.2.3