From e3a62f8a2e9dcb4212f6fa8e1a94f832ad66d35a Mon Sep 17 00:00:00 2001 From: zoidberg10 Date: Sun, 13 Nov 2011 00:47:02 +0100 Subject: Move getFileInfo to SimpleHoster.py; update Mediafire --- module/plugins/hoster/FourSharedCom.py | 99 +++++++++++----------------------- 1 file changed, 32 insertions(+), 67 deletions(-) (limited to 'module/plugins/hoster/FourSharedCom.py') diff --git a/module/plugins/hoster/FourSharedCom.py b/module/plugins/hoster/FourSharedCom.py index 03da15fb0..1c12a2d34 100644 --- a/module/plugins/hoster/FourSharedCom.py +++ b/module/plugins/hoster/FourSharedCom.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from module.plugins.Hoster import Hoster +from module.plugins.internal.SimpleHoster import SimpleHoster from module.network.RequestFactory import getURL import re @@ -9,82 +9,47 @@ def getInfo(urls): result = [] for url in urls: - html = getURL(url, decode=True) - if re.search(FourSharedCom.FILE_OFFLINE_PATTERN, html): - # File offline - result.append((url, 0, 1, url)) - else: - # Get file info - name, size = url, 0 - - found = re.search(FourSharedCom.FILE_SIZE_PATTERN, html) - if found is not None: - size, units = float(found.group(1).replace(',','')), found.group(2) - size = size * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[units] - - found = re.search(FourSharedCom.FILE_NAME_PATTERN, html) - if found is not None: - name = re.sub(r"&#(\d+).", lambda m: unichr(int(m.group(1))), found.group(1)) - - if found or size > 0: - result.append((name, size, 2, url)) + name, size, status, url = parseFileInfo(FourSharedCom, url, getURL(url, decode=True)) + if status == 2: + name = re.sub(r"&#(\d+).", lambda m: unichr(int(m.group(1))), name) + result.append(name, size, status, url) + yield result - -class FourSharedCom(Hoster): +class FourSharedCom(SimpleHoster): __name__ = "FourSharedCom" __type__ = "hoster" __pattern__ = r"http://[\w\.]*?4shared(-china)?\.com/(account/)?(download|get|file|document|photo|video|audio)/.+?/.*" - __version__ = "0.2" + __version__ = "0.21" __description__ = """4Shared Download Hoster""" __author_name__ = ("jeix", "zoidberg") __author_mail__ = ("jeix@hasnomail.de", "zoidberg@mujmail.cz") FILE_NAME_PATTERN = '' - FILE_SIZE_PATTERN = '' - FILE_OFFLINE_PATTERN = 'The file link that you requested is not valid\.' - - def setup(self): - self.multiDL = False + FILE_SIZE_PATTERN = '' + FILE_OFFLINE_PATTERN = 'The file link that you requested is not valid\.|This file was deleted.' + FREE_LINK_PATTERN = '\s*' in line: - wait = int(line.split(">")[1].split("<")[0]) - - self.setWait(wait) - self.wait() - - if link: - self.download(link) - else: - self.offline() \ No newline at end of file + self.getFileInfo() + pyfile.name = re.sub(r"&#(\d+).", lambda m: unichr(int(m.group(1))), pyfile.name) + self.handleFree() + + def handleFree(self): + found = re.search(self.FREE_LINK_PATTERN, self.html) + if not found: raise PluginParseError('Free download button') + link = found.group(1) + + self.html = self.load(link) + + found = re.search(self.DOWNLOAD_URL_PATTERN, self.html) + if not found: raise PluginParseError('Download link') + link = found.group(1) + + self.setWait(20) + self.wait() + self.download(link) + + \ No newline at end of file -- cgit v1.2.3