<commit_before># -*- coding: utf-8 -*-

import re

from random import random

from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo


class MultishareCz(SimpleHoster):
    __name__    = "MultishareCz"
    __type__    = "hoster"
    __version__ = "0.37"

    __pattern__ = r'http://(?:www\.)?multishare\.cz/stahnout/(?P<ID>\d+)'

    __description__ = """MultiShare.cz hoster plugin"""
    __license__     = "GPLv3"
    __authors__     = [("zoidberg", "<EMAIL>")]


    SIZE_REPLACEMENTS = [('&nbsp;', '')]

    MULTI_HOSTER = True

    INFO_PATTERN    = ur'(?:<li>Název|Soubor): <strong>(?P<N>[^<]+)</strong><(?:/li><li|br)>Velikost: <strong>(?P<S>[^<]+)</strong>'
    OFFLINE_PATTERN = ur'<h1>Stáhnout soubor</h1><p><strong>Požadovaný soubor neexistuje.</strong></p>'


    def handleFree(self):
        self.download("http://www.multishare.cz/html/download_free.php?ID=%s" % self.info['pattern']['ID'])


    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?ID=%s" % self.info['pattern']['ID'])


    def handleMulti(self, pyfile):
        self.html = self.load('http://www.multishare.cz/html/mms_ajax.php', post={"link": pyfile.url}, decode=True)

        self.checkInfo()

        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": pyfile.url}

        self.logDebug(url, params)

        self.link = True
        self.download(url, get=params)


    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)<commit_msg>[MultishareCz] Parse download content-disposition<commit_after># -*- coding: utf-8 -*-

import re

from random import random

from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo


class MultishareCz(SimpleHoster):
    __name__    = "MultishareCz"
    __type__    = "hoster"
    __version__ = "0.38"

    __pattern__ = r'http://(?:www\.)?multishare\.cz/stahnout/(?P<ID>\d+)'

    __description__ = """MultiShare.cz hoster plugin"""
    __license__     = "GPLv3"
    __authors__     = [("zoidberg", "<EMAIL>")]


    SIZE_REPLACEMENTS = [('&nbsp;', '')]

    MULTI_HOSTER = True

    INFO_PATTERN    = ur'(?:<li>Název|Soubor): <strong>(?P<N>[^<]+)</strong><(?:/li><li|br)>Velikost: <strong>(?P<S>[^<]+)</strong>'
    OFFLINE_PATTERN = ur'<h1>Stáhnout soubor</h1><p><strong>Požadovaný soubor neexistuje.</strong></p>'


    def handleFree(self):
        self.download("http://www.multishare.cz/html/download_free.php?ID=%s" % self.info['pattern']['ID'])


    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?ID=%s" % self.info['pattern']['ID'])


    def handleMulti(self, pyfile):
        self.html = self.load('http://www.multishare.cz/html/mms_ajax.php', post={"link": pyfile.url}, decode=True)

        self.checkInfo()

        if not self.checkCredit():
            self.fail(_("Not enough credit left to download file"))

        self.download("http://dl%d.mms.multishare.cz/html/mms_process.php" % round(random() * 10000 * random()),
                      get={'u_ID'  : self.acc_info['u_ID'],
                           'u_hash': self.acc_info['u_hash'],
                           'link'  : pyfile.url},
                      disposition=True)


    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)
{'fraction_non_alphanumeric': 0.17404403244495945, 'fraction_numerical': 0.009269988412514484, 'mean_word_length': 3.1340996168582373, 'pattern_counts': {'":': 5, '<': 43, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 8, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 15, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7541868', 'n_tokens_mistral': 1563, 'n_tokens_neox': 1463, 'n_words': 239}