From 4133fb008c9cb7c13a6a741986549c3b6e5e79a2 Mon Sep 17 00:00:00 2001 From: fragonib Date: Thu, 21 Apr 2011 21:25:41 +0200 Subject: UploadStation: Fixes & Refactoring --- module/plugins/hoster/UploadStationCom.py | 114 ++++++++++++++++++------------ 1 file changed, 67 insertions(+), 47 deletions(-) (limited to 'module/plugins/hoster') diff --git a/module/plugins/hoster/UploadStationCom.py b/module/plugins/hoster/UploadStationCom.py index 7d28f0065..2723ae2ef 100644 --- a/module/plugins/hoster/UploadStationCom.py +++ b/module/plugins/hoster/UploadStationCom.py @@ -11,6 +11,9 @@ from module.plugins.ReCaptcha import ReCaptcha from module.network.RequestFactory import getURL +def unicode2str(unitext): + return unicodedata.normalize('NFKD', unitext).encode('ascii', 'ignore') + def getInfo(urls): result = [] @@ -30,71 +33,78 @@ def getInfo(urls): # Size pattern = r'''
File size: (.*?) (KB|MB|GB)''' m = re.search(pattern, html) - units = float(m.group(1)) + value = float(m.group(1)) pow = {'KB' : 1, 'MB' : 2, 'GB' : 3}[m.group(2)] - size = int(units*1024**pow) + size = int(value*1024**pow) # Return info result.append((name, size, 2, url)) yield result + class UploadStationCom(Hoster): __name__ = "UploadStationCom" __type__ = "hoster" __pattern__ = r"http://(www\.)?uploadstation\.com/file/[A-Za-z0-9]+" - __version__ = "0.1" + __version__ = "0.2" __description__ = """UploadStation.Com File Download Hoster""" __author_name__ = ("fragonib") __author_mail__ = ("fragonib[AT]yahoo[DOT]es") def setup(self): self.multiDL = False - self.file_id = re.search(r"uploadstation\.com/file/([a-zA-Z0-9]+)(http:.*)?", self.pyfile.url).group(1) - self.pyfile.url = "http://www.uploadstation.com/file/" + self.file_id + self.fileId = re.search(r"uploadstation\.com/file/([a-zA-Z0-9]+)(http:.*)?", self.pyfile.url).group(1) + self.pyfile.url = "http://www.uploadstation.com/file/" + self.fileId def process(self, pyfile): - self.html = self.load(self.pyfile.url, ref=False, cookies=False if self.account else True, utf8=True) + + # Get URL + self.html = self.load(self.pyfile.url, ref=False, cookies=True, utf8=True) - pattern = r'''

File not available

|The file could not be found\. Please check the download link''' - if re.search(pattern, self.html): + # Is offline? + pattern = r'''

File not available

|The file could not be found\. Please check the download link''' + m = re.search(pattern, self.html) + if m is not None: self.offline() + # Title pattern = r'''
(.*?)
''' title = re.search(pattern, self.html).group(1) - self.pyfile.name = unicodedata.normalize('NFKD', title).encode('ascii','ignore') + self.pyfile.name = unicode2str(title) + # Free account self.handleFree() def handleFree(self): - - self.html = self.load(self.pyfile.url) # Not needed yet - #jsPage = re.search(r"\"(/landing/.*?/download_captcha\.js)\"", self.html) - #jsPage = self.load("http://uploadstation.com" + jsPage.group(1)) + #pattern = r'''\"(/landing/.*?/download_captcha\.js)\"''' + #jsPage = re.search(pattern, self.html).group(1) + #self.jsPage = self.load("http://uploadstation.com" + jsPage) - self.action = self.load(self.pyfile.url, post={"checkDownload" : "check"}) - if "success\":\"showCaptcha\"" in self.action: - self.handleErrors() + # Check download + response = self.load(self.pyfile.url, post={"checkDownload" : "check"}) + if not '"success":"showCaptcha"' in response: + self.handleErrors(response) - if r'