diff options
Diffstat (limited to 'module/plugins/hoster/MultishareCz.py')
-rw-r--r-- | module/plugins/hoster/MultishareCz.py | 62 |
1 files changed, 53 insertions, 9 deletions
diff --git a/module/plugins/hoster/MultishareCz.py b/module/plugins/hoster/MultishareCz.py index bf1d9f3bf..e2150a3aa 100644 --- a/module/plugins/hoster/MultishareCz.py +++ b/module/plugins/hoster/MultishareCz.py @@ -17,28 +17,72 @@ """ import re +from random import random from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class MultishareCz(SimpleHoster): __name__ = "MultishareCz" __type__ = "hoster" __pattern__ = r"http://(\w*\.)?multishare.cz/stahnout/.*" - __version__ = "0.32" + __version__ = "0.33" __description__ = """MultiShare.cz""" __author_name__ = ("zoidberg") - FILE_ID_PATTERN = r'/stahnout/(\d+)/' - FILE_INFO_PATTERN = ur'<ul class="no-padding"><li>Název: <strong>(?P<N>[^<]+)</strong></li><li>Velikost: <strong>(?P<S>[^&]+) (?P<U>[^<]+)</strong>' + FILE_ID_PATTERN = r'/stahnout/(?P<ID>\d+)/' + FILE_INFO_PATTERN = ur'(?:<li>Název|Soubor): <strong>(?P<N>[^<]+)</strong><(?:/li><li|br)>Velikost: <strong>(?P<S>[^<]+)</strong>' FILE_OFFLINE_PATTERN = ur'<h1>Stáhnout soubor</h1><p><strong>Požadovaný soubor neexistuje.</strong></p>' + FILE_SIZE_REPLACEMENTS = [(' ', '')] + + def process(self, pyfile): + if re.match(self.__pattern__, pyfile.url): + self.html = self.load(pyfile.url, decode = True) + self.getFileInfo() + if self.premium: + self.handlePremium() + else: + self.handleFree() + else: + self.handleOverriden() def handleFree(self): - found = re.search(self.FILE_ID_PATTERN, pyfile.url) - if found is None: - self.fail("Parse error (ID)") - file_id = found.group(1) - self.download("http://www.multishare.cz/html/download_free.php", get={ - "ID": file_id + "ID": self.getFileID() + }) + + def handlePremium(self): + if not self.checkCredit(): + self.logWarning("Not enough credit left to download file") + self.resetAccount() + + self.download("http://www.multishare.cz/html/download_premium.php", get={ + "ID": self.getFileID() }) + + def handleOverriden(self): + if not self.premium: + self.fail("Only premium users can download from other hosters") + + self.html = self.load('http://www.multishare.cz/html/mms_ajax.php', post = {"link": self.pyfile.url}, decode = True) + self.getFileInfo() + + if not self.checkCredit(): + self.fail("Not enough credit left to download file") + + url = "http://dl%d.mms.multishare.cz/html/mms_process.php" % round(random()*10000*random()) + params = {"u_ID" : self.acc_info["u_ID"], "u_hash" : self.acc_info["u_hash"], "link" : self.pyfile.url} + self.logDebug(url, params) + self.download(url, get = params) + + def getFileID(self): + found = re.search(self.FILE_ID_PATTERN, self.pyfile.url) + if not found: self.fail("Parse error (ID)") + + return found.group('ID') + + def checkCredit(self): + self.acc_info = self.account.getAccountInfo(self.user, True) + self.logInfo("User %s has %i MB left" % (self.user, self.acc_info["trafficleft"]/1024)) + + return self.pyfile.size / 1024 <= self.acc_info["trafficleft"] getInfo = create_getInfo(MultishareCz)
\ No newline at end of file |