From a7b4722ad786597a2d420fe429cd25b695b71559 Mon Sep 17 00:00:00 2001 From: fragonib Date: Mon, 18 Apr 2011 23:31:40 +0200 Subject: UploadStation: New plugin --- module/plugins/hoster/UploadStationCom.py | 139 ++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 module/plugins/hoster/UploadStationCom.py (limited to 'module/plugins/hoster') diff --git a/module/plugins/hoster/UploadStationCom.py b/module/plugins/hoster/UploadStationCom.py new file mode 100644 index 000000000..7d28f0065 --- /dev/null +++ b/module/plugins/hoster/UploadStationCom.py @@ -0,0 +1,139 @@ +# -*- coding: utf-8 -*- +from __future__ import with_statement + +import re +import unicodedata + +from os import remove + +from module.plugins.Hoster import Hoster +from module.plugins.ReCaptcha import ReCaptcha + +from module.network.RequestFactory import getURL + +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): + result.append((url, 0, 1, url)) + continue + + # Name + pattern = r'''
(.*?)
''' + name = re.search(pattern, html).group(1) + + # Size + pattern = r'''
File size: (.*?) (KB|MB|GB)''' + m = re.search(pattern, html) + units = float(m.group(1)) + pow = {'KB' : 1, 'MB' : 2, 'GB' : 3}[m.group(2)] + size = int(units*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" + __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 + + def process(self, pyfile): + self.html = self.load(self.pyfile.url, ref=False, cookies=False if self.account else 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): + self.offline() + + pattern = r'''
(.*?)
''' + title = re.search(pattern, self.html).group(1) + self.pyfile.name = unicodedata.normalize('NFKD', title).encode('ascii','ignore') + + 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)) + + self.action = self.load(self.pyfile.url, post={"checkDownload" : "check"}) + if "success\":\"showCaptcha\"" in self.action: + self.handleErrors() + + if r'