From 25ab9093d84cbeb86f7b626d7251f4a0180b32bf Mon Sep 17 00:00:00 2001 From: fragonib Date: Sun, 24 Apr 2011 17:40:11 +0200 Subject: UploadStation & BitshareCom: Improved debugging --- module/plugins/hoster/UploadStationCom.py | 117 ++++++++++++++++-------------- 1 file changed, 64 insertions(+), 53 deletions(-) (limited to 'module/plugins/hoster/UploadStationCom.py') diff --git a/module/plugins/hoster/UploadStationCom.py b/module/plugins/hoster/UploadStationCom.py index 2723ae2ef..19c2d078d 100644 --- a/module/plugins/hoster/UploadStationCom.py +++ b/module/plugins/hoster/UploadStationCom.py @@ -12,29 +12,28 @@ from module.plugins.ReCaptcha import ReCaptcha from module.network.RequestFactory import getURL def unicode2str(unitext): - return unicodedata.normalize('NFKD', unitext).encode('ascii', 'ignore') - + return unicodedata.normalize('NFKD', unitext).encode('ascii', 'ignore') + def getInfo(urls): result = [] for url in urls: - # Get html - html = getURL(url) - pattern = r'''

File not available

|The file could not be found\. Please check the download link''' - if re.search(pattern, html): + # Get file info html + html = getURL(url) + if re.search(UploadStationCom.FILE_OFFLINE_PATTERN, html): result.append((url, 0, 1, url)) continue # Name - pattern = r'''
(.*?)
''' - name = re.search(pattern, html).group(1) + name = re.search(UploadStationCom.FILE_TITLE_PATTERN, html).group(1) + name = unicode2str(name) # Unicode BUG workaround # Size - pattern = r'''
File size: (.*?) (KB|MB|GB)''' - m = re.search(pattern, html) + m = re.search(UploadStationCom.FILE_SIZE_PATTERN, html) value = float(m.group(1)) - pow = {'KB' : 1, 'MB' : 2, 'GB' : 3}[m.group(2)] + units = m.group(2) + pow = {'KB' : 1, 'MB' : 2, 'GB' : 3}[units] size = int(value*1024**pow) # Return info @@ -46,16 +45,27 @@ def getInfo(urls): class UploadStationCom(Hoster): __name__ = "UploadStationCom" __type__ = "hoster" - __pattern__ = r"http://(www\.)?uploadstation\.com/file/[A-Za-z0-9]+" - __version__ = "0.2" + __pattern__ = r"http://(www\.)?uploadstation\.com/file/(?P[A-Za-z0-9]+)" + __version__ = "0.3" __description__ = """UploadStation.Com File Download Hoster""" __author_name__ = ("fragonib") __author_mail__ = ("fragonib[AT]yahoo[DOT]es") + + FILE_OFFLINE_PATTERN = r'''

File not available

|The file could not be found\. Please check the download link''' + FILE_TITLE_PATTERN = r'''
(.*?)
''' + FILE_SIZE_PATTERN = r'''
File size: (.*?) (KB|MB|GB)''' + CAPTCHA_PRESENT_TOKEN = '