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/BezvadataCz.py | 65 ++++++++----------- module/plugins/hoster/DataportCz.py | 43 ++++--------- module/plugins/hoster/DepositfilesCom.py | 50 ++++----------- module/plugins/hoster/FilejungleCom.py | 44 +++---------- module/plugins/hoster/FilepostCom.py | 42 +++--------- module/plugins/hoster/FlyshareCz.py | 32 +++------ module/plugins/hoster/FourSharedCom.py | 99 +++++++++------------------- module/plugins/hoster/HellshareCz.py | 55 ++++------------ module/plugins/hoster/HellspyCz.py | 28 ++------ module/plugins/hoster/IfileIt.py | 57 +++++----------- module/plugins/hoster/IfolderRu.py | 34 +++------- module/plugins/hoster/MediafireCom.py | 50 ++------------- module/plugins/hoster/MegasharesCom.py | 63 +++++------------- module/plugins/hoster/MultishareCz.py | 47 +++----------- module/plugins/hoster/QuickshareCz.py | 34 ++-------- module/plugins/hoster/SendspaceCom.py | 53 +++------------ module/plugins/hoster/ShareRapidCom.py | 32 ++------- module/plugins/hoster/StahnuTo.py | 51 ++------------- module/plugins/hoster/UlozTo.py | 45 +++---------- module/plugins/hoster/UloziskoSk.py | 74 +++++++-------------- module/plugins/hoster/UploadkingCom.py | 46 +++---------- module/plugins/internal/SimpleHoster.py | 107 +++++++++++++++++++++++++++++++ 22 files changed, 365 insertions(+), 786 deletions(-) create mode 100644 module/plugins/internal/SimpleHoster.py (limited to 'module/plugins') diff --git a/module/plugins/hoster/BezvadataCz.py b/module/plugins/hoster/BezvadataCz.py index 71622885a..4c198d95f 100644 --- a/module/plugins/hoster/BezvadataCz.py +++ b/module/plugins/hoster/BezvadataCz.py @@ -17,50 +17,37 @@ """ import re -from module.plugins.Hoster import Hoster +from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo +from module.network.RequestFactory import getURL -class BezvadataCz(Hoster): +def getInfo(urls): + result = [] + + for url in urls: + file_info = parseFileInfo(BezvadataCz, url, getURL(url, decode=True)) + result.append(file_info) + + yield result + +class BezvadataCz(SimpleHoster): __name__ = "BezvadataCz" __type__ = "hoster" __pattern__ = r"http://(\w*\.)*bezvadata.cz/stahnout/.*" - __version__ = "0.2" + __version__ = "0.21" __description__ = """BezvaData.cz""" __author_name__ = ("zoidberg") __author_mail__ = ("zoidberg@mujmail.cz") - ID_PATTERN = r'' - HASH_PATTERN = r'' - FILENAME_PATTERN = r'BezvaData \| Sthnout soubor ([^<]+)' - OFFLINE_PATTERN = r'BezvaData \| Soubor nenalezen' - - def setup(self): - self.multiDL = False - - def process(self, pyfile): - self.html = self.load(pyfile.url, decode = True) - - if re.search(self.OFFLINE_PATTERN, self.html) is not None: - self.offline() - - found = re.search(self.FILENAME_PATTERN, self.html) - if found is None: - self.fail("Parse error (FILENAME)") - pyfile.name = found.group(1) - - found = re.search(self.ID_PATTERN, self.html) - if found is None: - self.fail("Parse error (ID)") - souborId = found.group(1) - - found = re.search(self.HASH_PATTERN, self.html) - if found is None: - self.fail("Parse error (HASH)") - souborHash = found.group(1) - - self.logDebug("URL:"+pyfile.url+" ID:"+souborId+" HASH:"+souborHash) - - self.download(pyfile.url, post = { - "souborId": souborId, - "souborHash": souborHash, - "_send": 'STAHNOUT SOUBOR' - }) \ No newline at end of file + FILE_NAME_PATTERN = r'

Soubor: ([^<]+)

' + FILE_SIZE_PATTERN = r'
  • Velikost: ([0-9.]+) ([kKMG]i?B)
  • ' + FILE_OFFLINE_PATTERN = r'BezvaData \| Soubor nenalezen' + DOWNLOAD_FORM_PATTERN = r'
    ' + + def handleFree(self): + found = re.search(self.DOWNLOAD_FORM_PATTERN, self.html) + if found is None: self.parseError("Download form") + url = "http://bezvadata.cz" + found.group(1) + self.logDebug("Download form: %s" % url) + + self.download(url, post = {"stahnoutSoubor": "St%C3%A1hnout"}, cookies = True) + \ No newline at end of file diff --git a/module/plugins/hoster/DataportCz.py b/module/plugins/hoster/DataportCz.py index 896c4b47a..ed4ffa07c 100644 --- a/module/plugins/hoster/DataportCz.py +++ b/module/plugins/hoster/DataportCz.py @@ -17,59 +17,38 @@ """ 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(url, decode=True) - if re.search(DataportCz.FILE_OFFLINE_PATTERN, html): - # File offline - result.append((url, 0, 1, url)) - else: - # Get file info - found = re.search(DataportCz.FILE_NAME_PATTERN, html) - if found is not None: - name = found.group(1) - result.append((name, 0, 2, url)) + file_info = parseFileInfo(DataportCz, url, getURL(url, decode=True)) + result.append(file_info) + yield result - -class DataportCz(Hoster): + +class DataportCz(SimpleHoster): __name__ = "DataportCz" __type__ = "hoster" __pattern__ = r"http://.*dataport.cz/file/.*" - __version__ = "0.3a" - __description__ = """dataport.cz""" + __version__ = "0.32" + __description__ = """Dataport.cz plugin - free only""" __author_name__ = ("zoidberg") FILE_NAME_PATTERN = r'

    ([^<]+)

    ' + FILE_SIZE_PATTERN = r'Velikost souboru:\s*([0-9.]+)([kKMG]i?B)' URL_PATTERN = r']*class="ui-state-default button hover ui-corner-all ">' NO_SLOTS_PATTERN = r']*class="ui-state-default button hover ui-corner-all ui-state-disabled">' FILE_OFFLINE_PATTERN = r'

    Soubor nebyl nalezen

    ' - - def setup(self): - self.multiDL = False - - def process(self, pyfile): - - self.html = self.load(pyfile.url, decode=True) - - if re.search(self.FILE_OFFLINE_PATTERN, self.html): - self.offline() - + + def handleFree(self): if re.search(self.NO_SLOTS_PATTERN, self.html): self.setWait(900, True) self.wait() self.retry(12, 0, "No free slots") - found = re.search(self.FILE_NAME_PATTERN, self.html) - if found is None: - self.fail("Parse error (NAME)") - pyfile.name = found.group(1) - found = re.search(self.URL_PATTERN, self.html) if found is None: self.fail("Parse error (URL)") diff --git a/module/plugins/hoster/DepositfilesCom.py b/module/plugins/hoster/DepositfilesCom.py index 81e6aa4d6..b02445005 100644 --- a/module/plugins/hoster/DepositfilesCom.py +++ b/module/plugins/hoster/DepositfilesCom.py @@ -2,8 +2,8 @@ # -*- coding: utf-8 -*- import re -import urllib -from module.plugins.Hoster import Hoster +from urllib import unquote +from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo from module.network.RequestFactory import getURL from module.plugins.ReCaptcha import ReCaptcha @@ -11,31 +11,21 @@ def getInfo(urls): result = [] for url in urls: - html = getURL(re.sub(r"\.com(/.*?)?/files", ".com/en/files", url), decode=True) - if re.search(DepositfilesCom.FILE_OFFLINE_PATTERN, html): - # File offline - result.append((url, 0, 1, url)) - else: - # Get file info - name, size = url, 0 - - found = re.search(DepositfilesCom.FILE_INFO_PATTERN, html) - if found is not None: - name, size, units = found.groups() - size = float(size) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[units] - result.append((name, size, 2, url)) + file_info = parseFileInfo(DepositfilesCom, url, getURL(re.sub(r"\.com(/.*?)?/files", ".com/en/files", url), decode=True)) + result.append(file_info) + yield result -class DepositfilesCom(Hoster): +class DepositfilesCom(SimpleHoster): __name__ = "DepositfilesCom" __type__ = "hoster" __pattern__ = r"http://[\w\.]*?depositfiles\.com(/\w{1,3})?/files/[\w]+" - __version__ = "0.34" + __version__ = "0.35" __description__ = """Depositfiles.com Download Hoster""" __author_name__ = ("spoob", "zoidberg") __author_mail__ = ("spoob@pyload.org", "zoidberg@mujmail.cz") - FILE_INFO_PATTERN = r'File name: .*\s*File size: ([0-9.]+) (KB|MB|GB)' + FILE_INFO_PATTERN = r'File name: .*\s*File size: ([0-9.]+) ([kKMG]i?B)' FILE_OFFLINE_PATTERN = r'' RECAPTCHA_PATTERN = r"Recaptcha.create\('([^']+)', this\);" DOWNLOAD_LINK_PATTERN = r'.*?', self.html).group(1) + self.getFileInfo() if self.account: self.handlePremium() @@ -70,8 +49,6 @@ class DepositfilesCom(Hoster): def handleFree(self): - self.html = self.load(self.pyfile.url, post={"gateway_result":"1"}) - if re.search(r'File is checked, please try again in a minute.', self.html) is not None: self.log.info("DepositFiles.com: The file is being checked. Waiting 1 minute.") self.setWait(61) @@ -112,8 +89,9 @@ class DepositfilesCom(Hoster): for i in range(5): self.html = self.load("http://depositfiles.com/get_file.php", get = params) + if '\s*
    \s*Please wait for (\d+) seconds to download the next file\.' - def setup(self): - self.multiDL = False - - def process(self, pyfile): - self.html = self.load(pyfile.url) - self.getFileInfo(pyfile) - self.handleFree(pyfile) - - def getFileInfo(self, pyfile): - if re.search(self.FILE_OFFLINE_PATTERN, self.html): self.offline() - - found = re.search(self.FILE_INFO_PATTERN, self.html) - if not found: self.fail("Parse error (file info)") - pyfile.name, size, units = found.groups() - pyfile.size = float(size) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[units] - - def handleFree(self, pyfile): - file_id = re.search(self.__pattern__, pyfile.url).group(1) + def handleFree(self): + file_id = re.search(self.__pattern__, self.pyfile.url).group(1) url = "http://www.filejungle.com/f/%s" % file_id self.logDebug("File ID: %s" % file_id) @@ -80,7 +54,7 @@ class FilejungleCom(Hoster): if not found: self.fail("Captcha key not found") captcha_key = found.group(1) - json_response = self.load(pyfile.url, post = {"checkDownload" : "check"}, decode = True) + json_response = self.load(self.pyfile.url, post = {"checkDownload" : "check"}, decode = True) self.logDebug(json_response) if r'"success":"showCaptcha"' in json_response: recaptcha = ReCaptcha(self) diff --git a/module/plugins/hoster/FilepostCom.py b/module/plugins/hoster/FilepostCom.py index 319d85214..779eef1d2 100644 --- a/module/plugins/hoster/FilepostCom.py +++ b/module/plugins/hoster/FilepostCom.py @@ -17,7 +17,7 @@ """ import re -from module.plugins.Hoster import Hoster +from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo from module.network.RequestFactory import getURL from module.plugins.ReCaptcha import ReCaptcha from module.common.json_layer import json_loads @@ -27,26 +27,16 @@ def getInfo(urls): result = [] for url in urls: - html = getURL(url, decode=True) - if re.search(FilepostCom.FILE_OFFLINE_PATTERN, html): - # File offline - result.append((url, 0, 1, url)) - else: - # Get file info - name, size = url, 0 - - found = re.search(FilepostCom.FILE_INFO_PATTERN, html) - if found is not None: - name, size, units = found.groups() - size = float(size) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[units] - result.append((name, size, 2, url)) + file_info = parseFileInfo(FilepostCom, url, getURL(url, decode=True)) + result.append(file_info) + yield result -class FilepostCom(Hoster): +class FilepostCom(SimpleHoster): __name__ = "FilepostCom" __type__ = "hoster" __pattern__ = r"https?://(?:www\.)?filepost\.com/files/([^/]+).*" - __version__ = "0.2" + __version__ = "0.22" __description__ = """Filepost.com plugin - free only""" __author_name__ = ("zoidberg") __author_mail__ = ("zoidberg@mujmail.cz") @@ -56,25 +46,9 @@ class FilepostCom(Hoster): RECAPTCHA_KEY_PATTERN = r"Captcha.init\({\s*key:\s*'([^']+)'" FLP_TOKEN_PATTERN = r"store.set\('flp_token', '([^']+)'\);" - def setup(self): - self.multiDL = False - - def process(self, pyfile): - self.html = self.load(pyfile.url) - self.getFileInfo(pyfile) - self.handleFree(pyfile) - - def getFileInfo(self, pyfile): - if re.search(self.FILE_OFFLINE_PATTERN, self.html): self.offline() - - found = re.search(self.FILE_INFO_PATTERN, self.html) - if not found: self.fail("Parse error (file info)") - pyfile.name, size, units = found.groups() - pyfile.size = float(size) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[units] - - def handleFree(self, pyfile): + def handleFree(self): # Find token and captcha key - file_id = re.search(self.__pattern__, pyfile.url).group(1) + file_id = re.search(self.__pattern__, self.pyfile.url).group(1) found = re.search(self.FLP_TOKEN_PATTERN, self.html) if not found: self.fail("Parse error (token)") flp_token = found.group(1) diff --git a/module/plugins/hoster/FlyshareCz.py b/module/plugins/hoster/FlyshareCz.py index eb07f3d9e..fc7e9f13b 100644 --- a/module/plugins/hoster/FlyshareCz.py +++ b/module/plugins/hoster/FlyshareCz.py @@ -17,31 +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(url, decode=True) - if re.search(FlyshareCz.FILE_OFFLINE_PATTERN, html): - # File offline - result.append((url, 0, 1, url)) - else: - # Get file info - found = re.search(FlyshareCz.FILE_NAME_PATTERN, html) - if found is not None: - name = found.group(1) - result.append((name, 0, 2, url)) + file_info = parseFileInfo(FlyshareCz, url, getURL(url, decode=True)) + result.append(file_info) + yield result - -class FlyshareCz(Hoster): +class FlyshareCz(SimpleHoster): __name__ = "FlyshareCz" __type__ = "hoster" __pattern__ = r"http://.*flyshare.cz/stahni/.*" - __version__ = "0.3" + __version__ = "0.31" __description__ = """flyshare.cz""" __author_name__ = ("zoidberg") @@ -49,9 +41,6 @@ class FlyshareCz(Hoster): ERR_PATTERN = r'

    Chyba: ([^<]+)

    ' FILE_OFFLINE_PATTERN = r'

    Chyba: File is not available on the server

    ' - def setup(self): - self.multiDL = False - def process(self, pyfile): self.html = self.load(pyfile.url, decode=True) @@ -65,12 +54,11 @@ class FlyshareCz(Hoster): else: self.fail(err_dsc) - found = re.search(self.FILE_NAME_PATTERN, self.html) - if found is None: - self.fail("Parse error") - pyfile.name = found.group(1) + self.getFileInfo() + self.handleFree() - self.download(pyfile.url, post={ + def handleFree(self): + self.download(self.pyfile.url, post={ "wmod_command": "wmod_fileshare3:startDownload", "method": "free" }) 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 diff --git a/module/plugins/hoster/HellshareCz.py b/module/plugins/hoster/HellshareCz.py index c067dc40d..d2f5c8e40 100644 --- a/module/plugins/hoster/HellshareCz.py +++ b/module/plugins/hoster/HellshareCz.py @@ -18,42 +18,27 @@ import re import datetime -from math import ceil -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(url, decode=True) - if re.search(HellshareCz.FILE_OFFLINE_PATTERN, html): - # File offline - result.append((url, 0, 1, url)) - else: - # Get file info - found = re.search(HellshareCz.FILE_SIZE_PATTERN, html) - if found is not None: - size, units = found.groups() - size = float(size) * 1024 ** {'kB': 1, 'KB': 1, 'MB': 2, 'GB': 3}[units] - - found = re.search(HellshareCz.FILE_NAME_PATTERN, html) - if found is not None: - name = found.group(1) - - if found or size > 0: - result.append((name, 0, 2, url)) + file_info = parseFileInfo(HellshareCz, url, getURL(url, decode=True)) + result.append(file_info) + yield result -class HellshareCz(Hoster): +class HellshareCz(SimpleHoster): __name__ = "HellshareCz" __type__ = "hoster" __pattern__ = r"http://(?:.*\.)*hellshare\.(?:cz|com|sk|hu)/[^?]*/(\d+).*" - __version__ = "0.73" + __version__ = "0.74" __description__ = """Hellshare.cz""" __author_name__ = ("zoidberg") - FREE_URL_PATTERN = r'

    I\'ll wait.*\s*]*action="(http://free\d*\.helldata[^"]*)"' PREMIUM_URL_PATTERN = r"launchFullDownload\('([^']*)'\);" FILE_NAME_PATTERN = r'

    ([^<]+)

    ' FILE_SIZE_PATTERN = r'Size\s*([0-9.]*) (kB|KB|MB|GB)' @@ -73,7 +58,7 @@ class HellshareCz(Hoster): pyfile.url = re.search(r'([^?]*)', pyfile.url).group(1) self.html = self.load(pyfile.url, decode = True) - self.getFileInfo(pyfile) + self.getFileInfo() if "do=relatedFileDownloadButton" in self.html: found = re.search(self.__pattern__, self.pyfile.url) @@ -87,22 +72,6 @@ class HellshareCz(Hoster): else: self.handleFree() - def getFileInfo(self, pyfile): - #marks the file as "offline" when the pattern was found on the html-page - if re.search(self.FILE_OFFLINE_PATTERN, self.html) is not None: - self.offline() - - # parse the name from the site and set attribute in pyfile - found = re.search(self.FILE_NAME_PATTERN, self.html) - if found is None: - self.fail("Parse error (Filename") - pyfile.name = found.group(1) - - found = re.search(self.FILE_SIZE_PATTERN, self.html) - if found is not None: - size, units = found.groups() - pyfile.size = float(size) * 1024 ** {'kB': 1, 'KB': 1, 'MB': 2, 'GB': 3}[units] - def handleFree(self): # hellshare is very generous if "You exceeded your today's limit for free download. You can download only 1 files per 24 hours." in self.html: @@ -114,23 +83,23 @@ class HellshareCz(Hoster): # parse free download url found = re.search(self.FREE_URL_PATTERN, self.html) - if found is None: self.fail("Parse error (URL)") + if found is None: self.parseError("Free URL)") parsed_url = found.group(1) self.logDebug("Free URL: %s" % parsed_url) # decrypt captcha found = re.search(self.CAPTCHA_PATTERN, self.html) - if found is None: self.fail("Parse error (Captcha)") + if found is None: self.parseError("Captcha") captcha_url = found.group(1) captcha = self.decryptCaptcha(captcha_url) self.logDebug('CAPTCHA_URL:' + captcha_url + ' CAPTCHA:' + captcha) - + self.download(parsed_url, post = {"captcha" : captcha, "submit" : "Download"}) # check download check = self.checkDownload({ - "wrong_captcha": "

    Incorrectly copied code from the image

    " + "wrong_captcha": re.compile(self.FREE_URL_PATTERN) }) if check == "wrong_captcha": diff --git a/module/plugins/hoster/HellspyCz.py b/module/plugins/hoster/HellspyCz.py index fb7fa41dc..e1077a0cb 100644 --- a/module/plugins/hoster/HellspyCz.py +++ b/module/plugins/hoster/HellspyCz.py @@ -17,39 +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(url, decode=True) - if re.search(HellspyCz.FILE_OFFLINE_PATTERN, html): - # File offline - result.append((url, 0, 1, url)) - else: - # Get file info - found = re.search(HellspyCz.FILE_NAME_PATTERN, html) - if found is not None: - name = found.group(1) - found = re.search(HellspyCz.FILE_CREDITS_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(HellspyCz, url, getURL(url, decode=True)) + result.append(file_info) + yield result -class HellspyCz(Hoster): +class HellspyCz(SimpleHoster): __name__ = "HellspyCz" __type__ = "hoster" __pattern__ = r"http://(?:\w*\.)*hellspy\.(?:cz|com|sk|hu)(/\S+/\d+)/?.*" - __version__ = "0.2" + __version__ = "0.21" __description__ = """HellSpy.cz""" __author_name__ = ("zoidberg") __author_mail__ = ("zoidberg@mujmail.cz") diff --git a/module/plugins/hoster/IfileIt.py b/module/plugins/hoster/IfileIt.py index 2b70729a9..3bc60220a 100644 --- a/module/plugins/hoster/IfileIt.py +++ b/module/plugins/hoster/IfileIt.py @@ -17,62 +17,39 @@ """ import re - +from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo from module.common.json_layer import json_loads -from module.common.JsEngine import JsEngine from module.plugins.ReCaptcha import ReCaptcha -from module.plugins.Hoster import Hoster from module.network.RequestFactory import getURL def getInfo(urls): result = [] for url in urls: - html = getURL(url, decode=True) - if re.search(IfileIt.FILE_OFFLINE_PATTERN, html): - # File offline - result.append((url, 0, 1, url)) - else: - # Get file info - name, size = url, 0 - - found = re.search(IfileIt.FILE_INFO_PATTERN, html) - if found is not None: - name, size, units = found.groups() - size = float(size) * 1024 ** {'kB': 1, 'MB': 2, 'GB': 3}[units] - result.append((name, size, 2, url)) + file_info = parseFileInfo(IfileIt, url, getURL(url, decode=True)) + result.append(file_info) + yield result - -class IfileIt(Hoster): +class IfileIt(SimpleHoster): __name__ = "IfileIt" __type__ = "hoster" - __pattern__ = r"http://(?:\w*\.)*ifile\.it/.*" - __version__ = "0.2" + __pattern__ = r"http://(?:\w*\.)*ifile\.it/(\w+).*" + __version__ = "0.22" __description__ = """Ifile.it""" __author_name__ = ("zoidberg") - EVAL_PATTERN = r'(eval\(function\(p,a,c,k,e,d\).*)' - DEC_PATTERN = r"function requestBtn_clickEvent[^}]*url:\s*([^,]+)" + #EVAL_PATTERN = r'(eval\(function\(p,a,c,k,e,d\).*)' + #DEC_PATTERN = r"requestBtn_clickEvent[^}]*url:\s*([^,]+)" DOWNLOAD_LINK_PATTERN = r' If it doesn\'t,
    ' RECAPTCHA_KEY_PATTERN = r"var __recaptcha_public\s*=\s*'([^']+)';" - FILE_INFO_PATTERN = r']*>\s*(.*?)\s* \s*\s*([0-9.]+)\s*([kKMG]i?B)\s*\s*' FILE_OFFLINE_PATTERN = r'$\("#errorPnl"\)\.empty\(\)\.append\( "no such file" \);' - - def process(self, pyfile): - self.html = self.load(pyfile.url) - - found = re.search(self.FILE_INFO_PATTERN, self.html) - pyfile.name = found.group(1) - pyfile.size = pyfile.size = float(found.group(2)) * 1024 ** {'kB': 1, 'MB': 2, 'GB': 3}[found.group(3)] - - eval_string = re.search(self.EVAL_PATTERN, self.html).group(1) - dec_string = re.search(self.DEC_PATTERN, self.html).group(1) - - js = JsEngine() - json_url = js.eval(eval_string + ";" + dec_string) - self.logDebug(json_url) - + + def handleFree(self): + ukey = re.search(self.__pattern__, self.pyfile.url).group(1) + json_url = 'http://ifile.it/download-request2.json?ukey=' + ukey + json_response = json_loads(self.load(json_url)) self.logDebug(json_response) if json_response["captcha"]: @@ -98,8 +75,8 @@ class IfileIt(Hoster): self.fail("Incorrect captcha") # load twice - self.html = self.load(pyfile.url) - self.html = self.load(pyfile.url) + self.html = self.load(self.pyfile.url) + self.html = self.load(self.pyfile.url) download_url = re.search(self.DOWNLOAD_LINK_PATTERN, self.html).group(1) self.download(download_url) \ No newline at end of file diff --git a/module/plugins/hoster/IfolderRu.py b/module/plugins/hoster/IfolderRu.py index c0e45a87a..8a8e18282 100644 --- a/module/plugins/hoster/IfolderRu.py +++ b/module/plugins/hoster/IfolderRu.py @@ -18,39 +18,28 @@ import re from urllib import quote -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(url, decode=True) - if re.search(IfolderRu.FILE_OFFLINE_PATTERN, html): - # File offline - result.append((url, 0, 1, url)) - else: - # Get file info - found = re.search(IfolderRu.FILE_NAME_PATTERN, html) - if found is not None: - name = found.group(1) - found = re.search(IfolderRu.FILE_SIZE_PATTERN, html) - if found is not None: - size = float(found.group(1)) * 1024 ** {u'Кб': 1, u'Мб': 2, u'Гб': 3}[found.group(2)] - result.append((name, size, 2, url)) + file_info = parseFileInfo(IfolderRu, url, getURL(url, decode=True)) + result.append(file_info) + yield result -class IfolderRu(Hoster): +class IfolderRu(SimpleHoster): __name__ = "IfolderRu" __type__ = "hoster" __pattern__ = r"http://(?:\w*\.)?ifolder.ru/(\d+).*" - __version__ = "0.31" + __version__ = "0.32" __description__ = """ifolder.ru""" __author_name__ = ("zoidberg") __author_mail__ = ("zoidberg@mujmail.cz") - + SIZE_UNITS = {u'Кб': 1, u'Мб': 2, u'Гб': 3} FILE_NAME_PATTERN = ur'(?:
    )?Название:(?:)? ([^<]+)<(?:/div|br)>' FILE_SIZE_PATTERN = ur'(?:
    )?Размер:(?:)? ([0-9.]+) ([^<]+)<(?:/div|br)>' SESSION_ID_PATTERN = r']+)>' @@ -69,14 +58,7 @@ class IfolderRu(Hoster): def process(self, pyfile): file_id = re.search(self.__pattern__, pyfile.url).group(1) self.html = self.load("http://ifolder.ru/%s" % file_id, cookies=True, decode=True) - if re.search(self.FILE_OFFLINE_PATTERN, self.html): self.offline() - - found = re.search(self.FILE_NAME_PATTERN, self.html) - if not found: self.fail("Parse error (File name)") - pyfile.name = found.group(1) - found = re.search(self.FILE_SIZE_PATTERN, self.html) - if not found: self.fail("Parse error (File size)") - pyfile.size = float(found.group(1)) * 1024 ** {u'Кб': 1, u'Мб': 2, u'Гб': 3}[found.group(2)] + self.getFileInfo() url = "http://ints.ifolder.ru/ints/?ifolder.ru/%s?ints_code=" % file_id self.html = self.load(url, cookies=True, decode=True) diff --git a/module/plugins/hoster/MediafireCom.py b/module/plugins/hoster/MediafireCom.py index e06447c7c..15fc9f3c6 100644 --- a/module/plugins/hoster/MediafireCom.py +++ b/module/plugins/hoster/MediafireCom.py @@ -17,7 +17,7 @@ """ import re -from module.plugins.Hoster import Hoster +from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo from module.network.RequestFactory import getURL from module.plugins.ReCaptcha import ReCaptcha @@ -25,35 +25,19 @@ def getInfo(urls): result = [] for url in urls: - html = getURL(url, decode=True) - if re.search(MediafireCom.FILE_OFFLINE_PATTERN, html): - # File offline - result.append((url, 0, 1, url)) - else: - # Get file info - name, size = url, 0 - - found = re.search(MediafireCom.FILE_SIZE_PATTERN, html) - if found is not None: - size, units = found.group(1), found.group(2).replace('k','K') - size = float(size) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[units] - - found = re.search(MediafireCom.FILE_NAME_PATTERN, html) - if found is not None: - name = found.group(1) - - if found or size > 0: - result.append((name, size, 2, url)) + file_info = parseFileInfo(MediafireCom, url, getURL(url, decode=True)) + result.append(file_info) + yield result def replace_eval(js_expr): return js_expr.replace(r'eval("', '').replace(r"\'", r"'").replace(r'\"', r'"') -class MediafireCom(Hoster): +class MediafireCom(SimpleHoster): __name__ = "MediafireCom" __type__ = "hoster" __pattern__ = r"http://(?:\w*\.)*mediafire\.com/.*" - __version__ = "0.61" + __version__ = "0.64" __description__ = """Mediafire.com plugin - free only""" __author_name__ = ("zoidberg") __author_mail__ = ("zoidberg@mujmail.cz") @@ -72,29 +56,9 @@ class MediafireCom(Hoster): FINAL_LINK_PATTERN = r'parent.document.getElementById\(\'(\w{32})\'\).*(http://[^"]+)" \+(\w+)\+ "([^"]+)">' FILE_NAME_PATTERN = r'' - FILE_SIZE_PATTERN = r'
    \(([0-9.]+) (kB|KB|MB|GB)\)
    ' + FILE_SIZE_PATTERN = r'' FILE_OFFLINE_PATTERN = r'class="error_msg_title"> Invalid or Deleted File.
    ' - def setup(self): - self.multiDL = False - - def process(self, pyfile): - self.html = self.load(pyfile.url, decode=True) - self.getFileInfo(pyfile) - self.handleFree() - - def getFileInfo(self, pyfile): - if re.search(self.FILE_OFFLINE_PATTERN, self.html): self.offline() - - found = re.search(self.FILE_NAME_PATTERN, self.html) - if not found: self.fail("Parse error (file name)") - pyfile.name = found.group(1) - - found = re.search(self.FILE_SIZE_PATTERN, self.html) - if found: - size, units = found.group(1), found.group(2).replace('k','K') - pyfile.size = float(size) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[units] - def handleFree(self): found = re.search(self.RECAPTCHA_PATTERN, self.html) if found: diff --git a/module/plugins/hoster/MegasharesCom.py b/module/plugins/hoster/MegasharesCom.py index 0a326c268..3c17eb979 100644 --- a/module/plugins/hoster/MegasharesCom.py +++ b/module/plugins/hoster/MegasharesCom.py @@ -18,40 +18,23 @@ import re from time import time -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(url, decode=True) - if re.search(MegasharesCom.FILE_OFFLINE_PATTERN, html): - # File offline - result.append((url, 0, 1, url)) - else: - # Get file info - name, size = url, 0 - - found = re.search(MegasharesCom.FILE_SIZE_PATTERN, html) - if found is not None: - size, units = found.groups() - size = float(size) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[units] - - found = re.search(MegasharesCom.FILE_NAME_PATTERN, html) - if found is not None: - name = found.group(1) - - if found or size > 0: - result.append((name, size, 2, url)) + file_info = parseFileInfo(MegasharesCom, url, getURL(url, decode=True)) + result.append(file_info) + yield result - -class MegasharesCom(Hoster): +class MegasharesCom(SimpleHoster): __name__ = "MegasharesCom" __type__ = "hoster" __pattern__ = r"http://(\w+\.)?megashares.com/.*" - __version__ = "0.1" + __version__ = "0.12" __description__ = """megashares.com plugin - free only""" __author_name__ = ("zoidberg") __author_mail__ = ("zoidberg@mujmail.cz") @@ -59,35 +42,23 @@ class MegasharesCom(Hoster): FILE_NAME_PATTERN = '

    ]*title="([^"]+)">' FILE_SIZE_PATTERN = 'Filesize: ([0-9.]+) (KB|MB|GB)
    ' DOWNLOAD_URL_PATTERN = '
    ' + FILE_SIZE_PATTERN = r'
    \s*File Size:\s*([0-9.]+)([kKMG]i?B)\s*
    ' FILE_OFFLINE_PATTERN = r'
    Sorry, the file you requested is not available.
    ' CAPTCHA_PATTERN = r'' USER_CAPTCHA_PATTERN = r'' - - def setup(self): - self.multiDL = False - - def process(self, pyfile): - self.html = self.load(pyfile.url, decode=True) - - if re.search(self.FILE_OFFLINE_PATTERN, self.html) is not None: - self.offline() - - found = re.search(self.FILE_NAME_PATTERN, self.html) - if found is None: self.fail("Parse error (file name)") - pyfile.name = found.group(1) - - found = re.search(self.FILE_SIZE_PATTERN, self.html) - if found is None: self.fail("Parse error (file size)") - pyfile.size = float(found.group(1)) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[found.group(2)] - + + def handleFree(self): params = {} for i in range(3): found = re.search(self.DOWNLOAD_URL_PATTERN, self.html) @@ -100,7 +67,7 @@ class SendspaceCom(Hoster): params = {'download': "Regular Download"} self.logDebug(params) - self.html = self.load(pyfile.url, post = params) + self.html = self.load(self.pyfile.url, post = params) else: self.fail("Download link not found") diff --git a/module/plugins/hoster/ShareRapidCom.py b/module/plugins/hoster/ShareRapidCom.py index 46818a84c..17c981b61 100644 --- a/module/plugins/hoster/ShareRapidCom.py +++ b/module/plugins/hoster/ShareRapidCom.py @@ -5,7 +5,7 @@ import re from pycurl import HTTPHEADER from module.network.RequestFactory import getRequest from module.network.HTTPRequest import BadHeader -from module.plugins.Hoster import Hoster +from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo def getInfo(urls): result = [] @@ -16,34 +16,18 @@ def getInfo(urls): h.c.setopt(HTTPHEADER, ["Accept: text/html"]) html = h.load(url, cookies = True, decode = True) - if re.search(ShareRapidCom.FILE_OFFLINE_PATTERN, html): - # File offline - result.append((url, 0, 1, url)) - else: - # Get file info - name, size = url, 0 - - found = re.search(ShareRapidCom.FILE_SIZE_PATTERN, html) - if found is not None: - size, units = found.groups() - size = float(size) * 1024 ** {'kB': 1, 'MB': 2, 'GB': 3}[units] - - found = re.search(ShareRapidCom.FILE_NAME_INFO_PATTERN, html) - if found is not None: - name = found.group(1) - - if found or size > 0: - result.append((name, size, 2, url)) + file_info = parseFileInfo(ShareRapidCom, url, getURL(url, decode=True)) + result.append(file_info) finally: h.close() yield result -class ShareRapidCom(Hoster): +class ShareRapidCom(SimpleHoster): __name__ = "ShareRapidCom" __type__ = "hoster" __pattern__ = r"http://(?:www\.)?((share(-?rapid\.(biz|com|cz|info|eu|net|org|pl|sk)|-(central|credit|free|net)\.cz|-ms\.net)|(s-?rapid|rapids)\.(cz|sk))|(e-stahuj|mediatack|premium-rapidshare|rapidshare-premium|qiuck)\.cz|kadzet\.com|stahuj-zdarma\.eu|strelci\.net|universal-share\.com)/(stahuj/.+)" - __version__ = "0.42" + __version__ = "0.44" __description__ = """Share-rapid.com plugin - premium only""" __author_name__ = ("MikyWoW", "zoidberg") __author_mail__ = ("MikyWoW@seznam.cz", "zoidberg@mujmail.cz") @@ -71,14 +55,12 @@ class ShareRapidCom(Hoster): self.account.relogin(self.user) self.retry(3, 0, str(e)) - size, units = re.search(self.FILE_SIZE_PATTERN, self.html).groups() - pyfile.size = float(size) * 1024 ** {'kB': 1, 'MB': 2, 'GB': 3}[units] + self.getFileInfo() found = re.search(self.DOWNLOAD_URL_PATTERN, self.html) if found is not None: link, pyfile.name = found.groups() - self.logInfo("Downloading file: %s (%s %s)" % (pyfile.name, size, units)) - self.logInfo("Premium link: %s" % link) + self.logDebug("Premium link: %s" % link) self.download(link) else: self.logError("Download URL not found") 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'

    Tento soubor neexistuje nebo byl odstraněn!

    ' CAPTCHA_PATTERN = r'' - 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, diff --git a/module/plugins/hoster/UlozTo.py b/module/plugins/hoster/UlozTo.py index b16240ab7..b9ec4c5d7 100644 --- a/module/plugins/hoster/UlozTo.py +++ b/module/plugins/hoster/UlozTo.py @@ -17,7 +17,7 @@ """ 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): @@ -25,43 +25,19 @@ def getInfo(urls): for url in urls: try: - html = getURL(url, decode=True) - - if re.search(UlozTo.FILE_OFFLINE_PATTERN, html): - # File offline - result.append((url, 0, 1, url)) - else: - # Get file info - name = '' - found = re.search(UlozTo.FILE_NAME_PATTERN, html) - if found is not None: - name = found.group(1) - else: - found = re.search(UlozTo.LIVE_NAME_PATTERN, html) - if found is not None: - name = found.group(1) - - if name: - found = re.search(UlozTo.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)) - except Exception: + file_info = parseFileInfo(IfileIt, url, getURL(url, decode=True)) + result.append(file_info) + except Exception, e: + self.logError(e) result.append((url, 0, 1, url)) yield result - -class UlozTo(Hoster): +class UlozTo(SimpleHoster): __name__ = "UlozTo" __type__ = "hoster" __pattern__ = r"http://(\w*\.)?(uloz\.to|ulozto\.(cz|sk|net)|bagruj.cz|zachowajto.pl)/.*" - __version__ = "0.7" + __version__ = "0.71" __description__ = """uloz.to""" __config__ = [("reuseCaptcha", "bool", "Reuse captcha", "True"), ("captchaUser", "str", "captcha_user", ""), @@ -76,7 +52,7 @@ class UlozTo(Hoster): PASSWD_PATTERN = r'' LIVE_URL_PATTERN = r'
    ' + FILE_SIZE_PATTERN = r'
    \s*
    [^<]*\s+([0-9.]+)\s([kKMG]i?B)\s*
    \s*
    ' VIPLINK_PATTERN = r'
    ' def setup(self): @@ -84,10 +60,7 @@ class UlozTo(Hoster): def process(self, pyfile): self.html = self.load(pyfile.url, decode=True) - - #marks the file as "offline" when the pattern was found on the html-page - if re.search(self.FILE_OFFLINE_PATTERN, self.html): - self.offline() + self.getFileInfo() if re.search(self.VIPLINK_PATTERN, self.html): self.html = self.load(pyfile.url, get={"disclaimer": "1"}) diff --git a/module/plugins/hoster/UloziskoSk.py b/module/plugins/hoster/UloziskoSk.py index e439a0f87..1fd15502d 100644 --- a/module/plugins/hoster/UloziskoSk.py +++ b/module/plugins/hoster/UloziskoSk.py @@ -17,84 +17,58 @@ """ 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(url, decode=True) - if re.search(UloziskoSk.FILE_OFFLINE_PATTERN, html): - # File offline - result.append((url, 0, 1, url)) - else: - # Get file info - name, size = url, 0 - - found = re.search(UloziskoSk.FILE_SIZE_PATTERN, html) - if found is not None: - size, units = found.groups() - size = float(size) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[units] - - found = re.search(UloziskoSk.FILE_NAME_PATTERN, html) - if found is not None: - name = found.group(1) - - if found or size > 0: - result.append((name, size, 2, url)) + file_info = parseFileInfo(UloziskoSk, url, getURL(url, decode=True)) + result.append(file_info) + yield result - -class UloziskoSk(Hoster): +class UloziskoSk(SimpleHoster): __name__ = "UloziskoSk" __type__ = "hoster" __pattern__ = r"http://(\w*\.)?ulozisko.sk/.*" - __version__ = "0.2" + __version__ = "0.22" __description__ = """Ulozisko.sk""" __author_name__ = ("zoidberg") URL_PATTERN = r'' ID_PATTERN = r'' - FILE_NAME_PATTERN = r'' - FILE_SIZE_PATTERN = ur'Veľkosť súboru: ([0-9.]+) (KB|MB|GB)
    ' + FILE_NAME_PATTERN = r'
    ([^<]+)
    ' + FILE_SIZE_PATTERN = ur'Veľkosť súboru: ([0-9.]+) ([kKMG]i?B)
    ' CAPTCHA_PATTERN = r'' FILE_OFFLINE_PATTERN = ur'Zadaný súbor neexistuje z jedného z nasledujúcich dôvodov:' - - def setup(self): - self.multiDL = False + IMG_PATTERN = ur'PRE ZVÄČŠENIE KLIKNITE NA OBRÁZOK
    ' def process(self, pyfile): self.html = self.load(pyfile.url, decode=True) + self.getFileInfo() + + found = re.search(self.IMG_PATTERN, self.html) + if found: + url = "http://ulozisko.sk" + found.group(1) + self.download(url) + else: + self.handleFree() - if re.search(self.FILE_OFFLINE_PATTERN, self.html) is not None: - self.offline() - + def handleFree(self): found = re.search(self.URL_PATTERN, self.html) - if found is None: - self.fail("Parse error (URL)") + if found is None: raise PluginParseError('URL') parsed_url = 'http://www.ulozisko.sk' + found.group(1) - found = re.search(self.FILE_NAME_PATTERN, self.html) - if found is None: - self.fail("Parse error (FILENAME)") - pyfile.name = found.group(1) - - found = re.search(self.FILE_SIZE_PATTERN, self.html) - if found is not None: - size, units = found.groups() - pyfile.size = float(size) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[units] - found = re.search(self.ID_PATTERN, self.html) - if found is None: - self.fail("Parse error (ID)") + if found is None: raise PluginParseError('ID') id = found.group(1) - self.logDebug('URL:' + parsed_url + ' NAME:' + pyfile.name + ' ID:' + id) + self.logDebug('URL:' + parsed_url + ' ID:' + id) found = re.search(self.CAPTCHA_PATTERN, self.html) - if found is None: - self.fail("Parse error (CAPTCHA)") + if found is None: raise PluginParseError('CAPTCHA') captcha_url = 'http://www.ulozisko.sk' + found.group(1) captcha = self.decryptCaptcha(captcha_url, cookies=True) @@ -104,6 +78,6 @@ class UloziskoSk(Hoster): self.download(parsed_url, post={ "antispam": captcha, "id": id, - "name": pyfile.name, + "name": self.pyfile.name, "but": "++++STIAHNI+S%DABOR++++" - }) + }) \ No newline at end of file diff --git a/module/plugins/hoster/UploadkingCom.py b/module/plugins/hoster/UploadkingCom.py index d29a06e48..a706e95bc 100644 --- a/module/plugins/hoster/UploadkingCom.py +++ b/module/plugins/hoster/UploadkingCom.py @@ -17,60 +17,34 @@ """ 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(url, decode=True) - if re.search(UploadkingCom.FILE_OFFLINE_PATTERN, html): - # File offline - result.append((url, 0, 1, url)) - else: - # Get file info - name, size = url, 0 - - found = re.search(UploadkingCom.FILE_INFO_PATTERN, html) - if found is not None: - name, size, units = found.groups() - size = float(size) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[units] - result.append((name, size, 2, url)) + file_info = parseFileInfo(UploadkingCom, url, getURL(url, decode=False)) + result.append(file_info) + yield result -class UploadkingCom(Hoster): +class UploadkingCom(SimpleHoster): __name__ = "UploadkingCom" __type__ = "hoster" __pattern__ = r"http://(?:www\.)?uploadking\.com/\w{10}" - __version__ = "0.1" + __version__ = "0.12" __description__ = """UploadKing.com plugin - free only""" __author_name__ = ("zoidberg") __author_mail__ = ("zoidberg@mujmail.cz") - FILE_INFO_PATTERN = r'File(?:name)?:\s*<(?:b|/font>]*)>([^<]+)(?:
    )?

    ]*>(?:Files|S)ize:\s*<(?:b|/font>]*)>([0-9.]+) (KB|MB|GB)' + FILE_INFO_PATTERN = r'File(?:name)?:\s*<(?:b|/font>]*)>([^<]+)(?:)?]*>(?:Files|S)ize:\s*<(?:b|/font>]*)>([0-9.]+) ([kKMG]i?B)' FILE_OFFLINE_PATTERN = r'
    ]*>Unfortunately, this file is unavailable
    ' FILE_URL_PATTERN = r'id="dlbutton">
    . + + @author: zoidberg +""" + +from module.plugins.Hoster import Hoster +from module.utils import html_unescape +from re import search + +def parseFileInfo(self, url = '', html = ''): + if not html and hasattr(self, "html"): html = self.html + name, size, status, found = '', 0, 0, 0 + + if hasattr(self, "FILE_OFFLINE_PATTERN") and search(self.FILE_OFFLINE_PATTERN, html): + # File offline + status = 1 + elif hasattr(self, "FILE_INFO_PATTERN"): + found = search(self.FILE_INFO_PATTERN, html) + if found: + name, size, units = found.groups() + else: + if hasattr(self, "FILE_NAME_PATTERN"): + found = search(self.FILE_NAME_PATTERN, html) + if found: + name = found.group(1) + + if hasattr(self, "FILE_SIZE_PATTERN"): + found = search(self.FILE_SIZE_PATTERN, html) + if found: + size, units = found.groups() + + if size: + # File online, return name and size + for r in self.SIZE_REPLACEMENTS: + size = size.replace(r, self.SIZE_REPLACEMENTS[r]) + size = float(size) * 1024 ** self.SIZE_UNITS[units] + status = 2 + + if not name: name = url + + return (name, size, status, url) + +class PluginParseError(Exception): + def __init__(self, msg): + self.value = 'Parse error (%s) - plugin may be out of date' % msg + def __str__(self): + return repr(self.value) + +class SimpleHoster(Hoster): + __name__ = "SimpleHoster" + __version__ = "0.1" + __pattern__ = None + __type__ = "hoster" + __description__ = """Base hoster plugin""" + __author_name__ = ("zoidberg") + __author_mail__ = ("zoidberg@mujmail.cz") + + SIZE_UNITS = {'kB': 1, 'KB': 1, 'KiB': 1, 'MB': 2, 'MiB': 2, 'GB': 3, 'GiB': 3} + SIZE_REPLACEMENTS = {',': '', ' ': ''} + + def setup(self): + self.resumeDownload = self.multiDL = True if self.account else False + + def process(self, pyfile): + self.html = self.load(pyfile.url, decode = True) + self.getFileInfo() + if self.account: + self.handlePremium() + else: + self.handleFree() + + def getFileInfo(self): + self.logDebug("URL: %s" % self.pyfile.url) + name, size, status, url = parseFileInfo(self) + if status == 1: + self.offline() + elif status == 0: + self.parseError('File info') + + if not name: + name = html_unescape(urlparse(pyfile.url).path.split("/")[-1]) + + self.logDebug("FILE NAME: %s FILE SIZE: %s" % (name, size)) + self.pyfile.name, self.pyfile.size = name, size + + def handleFree(self): + self.fail("Free download not implemented") + + def handlePremium(self): + self.fail("Premium download not implemented") + + def parseError(self, msg): + raise PluginParseError(msg) \ No newline at end of file -- cgit v1.2.3