From 0f43585db0bdde5671e601ca6089d8ae3950a67b Mon Sep 17 00:00:00 2001 From: Stefano Date: Wed, 17 Jul 2013 12:31:05 +0200 Subject: BitshareCom: fixed #188 --- module/plugins/hoster/BitshareCom.py | 46 ++++++------------------------------ 1 file changed, 7 insertions(+), 39 deletions(-) (limited to 'module/plugins/hoster/BitshareCom.py') diff --git a/module/plugins/hoster/BitshareCom.py b/module/plugins/hoster/BitshareCom.py index 8b81c28cd..5e117ff45 100644 --- a/module/plugins/hoster/BitshareCom.py +++ b/module/plugins/hoster/BitshareCom.py @@ -2,58 +2,24 @@ from __future__ import with_statement import re -from pycurl import FOLLOWLOCATION -from module.plugins.Hoster import Hoster +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo from module.plugins.internal.CaptchaService import ReCaptcha -from module.network.RequestFactory import getRequest -def getInfo(urls): - result = [] - - for url in urls: - - # Get file info html - req = getRequest() - req.cj.setCookie(BitshareCom.HOSTER_DOMAIN, "language_selection", "EN") - html = req.load(url) - req.close() - - # Check online - if re.search(BitshareCom.FILE_OFFLINE_PATTERN, html): - result.append((url, 0, 1, url)) - continue - - # Name - name1 = re.search(BitshareCom.__pattern__, url).group('name') - m = re.search(BitshareCom.FILE_INFO_PATTERN, html) - name2 = m.group('name') - name = max(name1, name2) - - # Size - value = float(m.group('size')) - units = m.group('units') - pow = {'KB' : 1, 'MB' : 2, 'GB' : 3}[units] - size = int(value*1024**pow) - - # Return info - result.append((name, size, 2, url)) - - yield result - -class BitshareCom(Hoster): +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.47" + __version__ = "0.48" __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'

(Downloading|Streaming)\s(?P.+?)\s-\s(?P[\d.]+)\s(?P..)yte

' + FILE_NAME_PATTERN = r'Download:\s*[\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!" @@ -177,3 +143,5 @@ class BitshareCom(Hoster): self.retry() self.logDebug("Wrong captcha") self.invalidCaptcha() + +getInfo = create_getInfo(BitshareCom) -- cgit v1.2.3