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

import re

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


class IfolderRu(SimpleHoster):
    __name__    = "IfolderRu"
    __type__    = "hoster"
    __version__ = "0.39"

    __pattern__ = r'http://(?:www\.)?(?:ifolder\.ru|rusfolder\.(?:com|net|ru))/(?:files/)?(?P<ID>\d+)'
    __config__  = [("use_premium", "bool", "Use premium account if available", True)]

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


    SIZE_REPLACEMENTS = [(u'Кб', 'KB'), (u'Мб', 'MB'), (u'Гб', 'GB')]

    NAME_PATTERN    = ur'(?:<div><span>)?Название:(?:</span>)? <b>(?P<N>[^<]+)</b><(?:/div|br)>'
    SIZE_PATTERN    = ur'(?:<div><span>)?Размер:(?:</span>)? <b>(?P<S>[^<]+)</b><(?:/div|br)>'
    OFFLINE_PATTERN = ur'<p>Файл номер <b>[^<]*</b> (не найден|удален) !!!</p>'

    SESSION_ID_PATTERN = r'<a href=(http://ints\.(?:rusfolder\.com|ifolder\.ru)/ints/sponsor/\?bi=\d*&session=([^&]+)&u=[^>]+)>'
    INTS_SESSION_PATTERN = r'\(\'ints_session\'\);\s*if\(tag\)\{tag\.value = "([^"]+)";\}'
    HIDDEN_INPUT_PATTERN = r'var v = .*?name=\'(.+?)\' value=\'1\''

    LINK_FREE_PATTERN = r'<a id="download_file_href" href="([^"]+)"'

    WRONG_CAPTCHA_PATTERN = ur'<font color=Red>неверный код,<br>введите еще раз</font><br>'


    def setup(self):
        self.resumeDownload = self.multiDL = bool(self.account)
        self.chunkLimit     = 1


    def handleFree(self, pyfile):
        self.html = self.load("http://rusfolder.com/%s" % self.info['pattern']['ID'], decode=True)
        self.getFileInfo()

        url = re.search(r"location\.href = '(http://ints\..*?=)'", self.html).group(1)
        self.html = self.load(url, decode=True)

        url, session_id = re.search(self.SESSION_ID_PATTERN, self.html).groups()
        self.html = self.load(url, decode=True)

        url = "http://ints.rusfolder.com/ints/frame/?session=%s" % session_id
        self.html = self.load(url)

        self.wait(31, False)

        captcha_url = "http://ints.rusfolder.com/random/images/?session=%s" % session_id
        for _i in xrange(5):
            self.html = self.load(url)
            action, inputs = self.parseHtmlForm('ID="Form1"')
            inputs['ints_session'] = re.search(self.INTS_SESSION_PATTERN, self.html).group(1)
            inputs[re.search(self.HIDDEN_INPUT_PATTERN, self.html).group(1)] = '1'
            inputs['confirmed_number'] = self.decryptCaptcha(captcha_url, cookies=True)
            inputs['action'] = '1'
            self.logDebug(inputs)

            self.html = self.load(url, decode=True, post=inputs)
            if self.WRONG_CAPTCHA_PATTERN in self.html:
                self.invalidCaptcha()
            else:
                break
        else:
            self.fail(_("Invalid captcha"))

        self.link = re.search(self.LINK_PATTERN, self.html).group(1)


getInfo = create_getInfo(IfolderRu)<commit_msg>ifolder issue #1291<commit_after># -*- coding: utf-8 -*-

import re

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


class IfolderRu(SimpleHoster):
    __name__    = "IfolderRu"
    __type__    = "hoster"
    __version__ = "0.39"

    __pattern__ = r'http://(?:www|files\.)?(?:ifolder\.ru|metalarea\.org|rusfolder\.(?:com|net|ru))/(?:files/)?(?P<ID>\d+)'
    __config__  = [("use_premium", "bool", "Use premium account if available", True)]

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


    SIZE_REPLACEMENTS = [(u'Кб', 'KB'), (u'Мб', 'MB'), (u'Гб', 'GB')]

    NAME_PATTERN    = ur'(?:<div><span>)?Название:(?:</span>)? <b>(?P<N>[^<]+)</b><(?:/div|br)>'
    SIZE_PATTERN    = ur'(?:<div><span>)?Размер:(?:</span>)? <b>(?P<S>[^<]+)</b><(?:/div|br)>'
    OFFLINE_PATTERN = ur'<p>Файл номер <b>[^<]*</b> (не найден|удален) !!!</p>'

    SESSION_ID_PATTERN = r'<input type="hidden" name="session" value="([^"]+)"'
    INTS_SESSION_PATTERN = r'\(\'ints_session\'\);\s*if\(tag\)\{tag\.value = "([^"]+)";\}'
    HIDDEN_INPUT_PATTERN = r'var v = .*?name=\'(.+?)\' value=\'1\''

    LINK_FREE_PATTERN = r'<a href="([^"]+)" class="downloadbutton_files"'

    WRONG_CAPTCHA_PATTERN = ur'<font color=Red>неверный код,<br>введите еще раз</font><br>'


    def setup(self):
        self.resumeDownload = self.multiDL = bool(self.account)
        self.chunkLimit     = 1


    def handleFree(self, pyfile):
        url = "http://rusfolder.com/%s" % self.info['pattern']['ID']
        self.html = self.load("http://rusfolder.com/%s" % self.info['pattern']['ID'], decode=True)
        self.getFileInfo()

        session_id = re.search(self.SESSION_ID_PATTERN, self.html).groups()

        captcha_url = "http://ints.rusfolder.com/random/images/?session=%s" % session_id
        for _i in xrange(5):
            action, inputs = self.parseHtmlForm('id="download-step-one-form"')
            inputs['confirmed_number'] = self.decryptCaptcha(captcha_url, cookies=True)
            inputs['action'] = '1'
            self.logDebug(inputs)

            self.html = self.load(url, decode=True, post=inputs)
            if self.WRONG_CAPTCHA_PATTERN in self.html:
                self.invalidCaptcha()
            else:
                break
        else:
            self.fail(_("Invalid captcha"))

        self.link = re.search(self.LINK_FREE_PATTERN, self.html).group(1)


getInfo = create_getInfo(IfolderRu)

{'fraction_non_alphanumeric': 0.2074235807860262, 'fraction_numerical': 0.005640465793304222, 'mean_word_length': 3.086988847583643, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5696626', 'n_tokens_mistral': 2146, 'n_tokens_neox': 2008, 'n_words': 294}