diff options
Diffstat (limited to 'module/plugins/hoster/StahnuTo.py')
-rw-r--r-- | module/plugins/hoster/StahnuTo.py | 51 |
1 files changed, 7 insertions, 44 deletions
diff --git a/module/plugins/hoster/StahnuTo.py b/module/plugins/hoster/StahnuTo.py index 0413853dd..fb17fad7c 100644 --- a/module/plugins/hoster/StahnuTo.py +++ b/module/plugins/hoster/StahnuTo.py @@ -17,40 +17,23 @@ """ import re -from module.plugins.Hoster import Hoster +from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo from module.network.RequestFactory import getURL def getInfo(urls): result = [] for url in urls: - html = getURL("http://stahnu.to/?file=" + re.search(StahnuTo.__pattern__, url).group(3), decode=True) - if re.search(StahnuTo.FILE_OFFLINE_PATTERN, html): - # File offline - result.append((url, 0, 1, url)) - else: - # Get file info - found = re.search(StahnuTo.FILE_NAME_PATTERN, html) - if found is not None: - name = found.group(1) - - found = re.search(StahnuTo.FILE_SIZE_PATTERN, html) - if found is not None: - size = float(found.group(1)) - units = found.group(2) - - pow = {'kB': 1, 'Mb': 2, 'Gb': 3}[units] - size = int(size * 1024 ** pow) - - result.append((name, size, 2, url)) + file_info = parseFileInfo(StahnuTo, url, getURL("http://stahnu.to/?file=" + re.search(StahnuTo.__pattern__, url).group(3), decode=True)) + result.append(file_info) + yield result - -class StahnuTo(Hoster): +class StahnuTo(SimpleHoster): __name__ = "StahnuTo" __type__ = "hoster" __pattern__ = r"http://(\w*\.)?stahnu.to/(files/get/|.*\?file=)([^/]+).*" - __version__ = "0.1" + __version__ = "0.11" __description__ = """stahnu.to""" __author_name__ = ("zoidberg") @@ -60,35 +43,15 @@ class StahnuTo(Hoster): #FILE_OFFLINE_PATTERN = r'<h2 align="center">Tento soubor neexistuje nebo byl odstraněn! </h2>' CAPTCHA_PATTERN = r'<img src="captcha/captcha.php" id="captcha" /></td>' - def setup(self): self.multiDL = True def process(self, pyfile): found = re.search(self.__pattern__, pyfile.url) - if found is None: - self.fail("Wrong URL") file_id = found.group(3) self.html = self.load("http://stahnu.to/?file=" + file_id, decode=True) - - if re.search(self.FILE_OFFLINE_PATTERN, self.html): - self.offline() - - found = re.search(self.FILE_NAME_PATTERN, self.html) - if found is None: - self.fail("Parse error (NAME)") - pyfile.name = found.group(1) - - """ - captcha = self.decryptCaptcha("http://stahnu.to/captcha/captcha.php", cookies=True) - - self.html = self.load("http://stahnu.to/?file=" + file_id, cookies=True, post={ - if re.search(self.CAPTCHA_PATTERN, self.html) is not None: - self.invalidCaptcha() - self.retry() - - """ + self.getFileInfo() self.download("http://stahnu.to/files/gen/" + file_id, post={ "file": file_id, |