diff options
Diffstat (limited to 'module/plugins/hoster/FourSharedCom.py')
-rw-r--r-- | module/plugins/hoster/FourSharedCom.py | 40 |
1 files changed, 13 insertions, 27 deletions
diff --git a/module/plugins/hoster/FourSharedCom.py b/module/plugins/hoster/FourSharedCom.py index 4680088d9..5d10204a7 100644 --- a/module/plugins/hoster/FourSharedCom.py +++ b/module/plugins/hoster/FourSharedCom.py @@ -1,26 +1,14 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo -from module.network.RequestFactory import getURL +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo import re -def getInfo(urls): - result = [] - - for url in urls: - 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(SimpleHoster): __name__ = "FourSharedCom" __type__ = "hoster" __pattern__ = r"http://[\w\.]*?4shared(-china)?\.com/(account/)?(download|get|file|document|photo|video|audio)/.+?/.*" - __version__ = "0.22" + __version__ = "0.23" __description__ = """4Shared Download Hoster""" __author_name__ = ("jeix", "zoidberg") __author_mail__ = ("jeix@hasnomail.de", "zoidberg@mujmail.cz") @@ -28,28 +16,26 @@ class FourSharedCom(SimpleHoster): FILE_NAME_PATTERN = '<meta name="title" content="(?P<N>[^"]+)" />' FILE_SIZE_PATTERN = '<span title="Size: (?P<S>[0-9,.]+) (?P<U>[kKMG])i?B">' FILE_OFFLINE_PATTERN = 'The file link that you requested is not valid\.|This file was deleted.' - FREE_LINK_PATTERN = '<a href="([^"]+)" class="dbtn"' + DOWNLOAD_BUTTON_PATTERN = '<a href="([^"]+)"\s*class="dbtn' DOWNLOAD_URL_PATTERN = "<div class=\"(?:dl|xxlarge bold)\">\s*<a href='([^']+)'" - - def process(self, pyfile): - self.html = self.load(pyfile.url, decode=True) - self.getFileInfo() - pyfile.name = re.sub(r"&#(\d+).", lambda m: unichr(int(m.group(1))), pyfile.name) - self.handleFree() + + NAME_REPLACEMENTS = [(r"&#(\d+).", lambda m: unichr(int(m.group(1))))] def handleFree(self): - found = re.search(self.FREE_LINK_PATTERN, self.html) - if not found: raise PluginParseError('Free download button') - link = found.group(1) - + found = re.search(self.DOWNLOAD_BUTTON_PATTERN, self.html) + if found: + link = found.group(1) + else: + link = re.sub(r'/(download|get|file|document|photo|video|audio)/', r'/get/', self.pyfile.url) + self.html = self.load(link) found = re.search(self.DOWNLOAD_URL_PATTERN, self.html) - if not found: raise PluginParseError('Download link') + if not found: self.parseError('Download link') link = found.group(1) self.setWait(20) self.wait() self.download(link) -
\ No newline at end of file +getInfo = create_getInfo(FourSharedCom)
\ No newline at end of file |