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

import re

from urllib import unquote

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


class DepositfilesCom(SimpleHoster):
    __name__    = "DepositfilesCom"
    __type__    = "hoster"
    __version__ = "0.54"

    __pattern__ = r'https?://(?:www\.)?(depositfiles\.com|dfiles\.(eu|ru))(/\w{1,3})?/files/(?P<ID>\w+)'
    __config__  = [("use_premium", "bool", "Use premium account if available", True)]

    __description__ = """Depositfiles.com hoster plugin"""
    __license__     = "GPLv3"
    __authors__     = [("spoob", "<EMAIL>"),
                       ("zoidberg", "<EMAIL>"),
                       ("<NAME>", "<EMAIL>")]


    NAME_PATTERN    = r'<script type="text/javascript">eval\( unescape\(\'(?P<N>.*?)\''
    SIZE_PATTERN    = r': <b>(?P<S>[\d.,]+)&nbsp;(?P<U>[\w^_]+)</b>'
    OFFLINE_PATTERN = r'<span class="html_download_api-not_exists"></span>'

    NAME_REPLACEMENTS = [(r'\%u([0-9A-Fa-f]{4})', lambda m: unichr(int(m.group(1), 16))),
                              (r'.*<b title="(?P<N>.+?)".*', "\g<N>")]
    URL_REPLACEMENTS  = [(__pattern__ + ".*", "https://dfiles.eu/files/\g<ID>")]

    COOKIES = [("dfiles.eu", "lang_current", "en")]

    WAIT_PATTERN = r'(?:download_waiter_remain">|html_download_api-limit_interval">|>Please wait|>Try in).+'
    ERROR_PATTER = r'File is checked, please try again in a minute'

    LINK_FREE_PATTERN    = r'<form id="downloader_file_form" action="(http://.+?\.(dfiles\.eu|depositfiles\.com)/.+?)" method="post"'
    LINK_PREMIUM_PATTERN = r'class="repeat"><a href="(.+?)"'
    LINK_MIRROR_PATTERN  = r'class="repeat_mirror"><a href="(.+?)"'


    def handleFree(self, pyfile):
        self.html = self.load(pyfile.url, post={'gateway_result': "1"})

        self.checkErrors()

        m = re.search(r"var fid = '(\w+)';", self.html)
        if m is None:
            self.retry(wait_time=5)
        params = {'fid': m.group(1)}
        self.logDebug("FID: %s" % params['fid'])

        self.wait()
        recaptcha = ReCaptcha(self)
        captcha_key = recaptcha.detect_key()
        if captcha_key is None:
            return

        self.html = self.load("https://dfiles.eu/get_file.php", get=params)

        if '<input type=button value="Continue" onclick="check_recaptcha' in self.html:
            params['response'], params['challenge'] = recaptcha.challenge(captcha_key)
            self.html = self.load("https://dfiles.eu/get_file.php", get=params)

        m = re.search(self.LINK_FREE_PATTERN, self.html)
        if m:
            if 'response' in params:
                self.correctCaptcha()

            self.link = unquote(m.group(1))


    def handlePremium(self, pyfile):
        if '<span class="html_download_api-gold_traffic_limit">' in self.html:
            self.logWarning(_("Download limit reached"))
            self.retry(25, 60 * 60, "Download limit reached")
<commit_msg>Update DepositfilesCom.py<commit_after># -*- coding: utf-8 -*-

import re

from urllib import unquote

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


class DepositfilesCom(SimpleHoster):
    __name__    = "DepositfilesCom"
    __type__    = "hoster"
    __version__ = "0.54"

    __pattern__ = r'https?://(?:www\.)?(depositfiles\.com|dfiles\.(eu|ru))(/\w{1,3})?/files/(?P<ID>\w+)'
    __config__  = [("use_premium", "bool", "Use premium account if available", True)]

    __description__ = """Depositfiles.com hoster plugin"""
    __license__     = "GPLv3"
    __authors__     = [("spoob", "<EMAIL>"),
                       ("zoidberg", "<EMAIL>"),
                       ("<NAME>", "<EMAIL>")]


    NAME_PATTERN    = r'<script type="text/javascript">eval\( unescape\(\'(?P<N>.*?)\''
    SIZE_PATTERN    = r': <b>(?P<S>[\d.,]+)&nbsp;(?P<U>[\w^_]+)</b>'
    OFFLINE_PATTERN = r'<span class="html_download_api-not_exists"></span>'

    NAME_REPLACEMENTS = [(r'\%u([0-9A-Fa-f]{4})', lambda m: unichr(int(m.group(1), 16))),
                              (r'.*<b title="(?P<N>.+?)".*', "\g<N>")]
    URL_REPLACEMENTS  = [(__pattern__ + ".*", "https://dfiles.eu/files/\g<ID>")]

    COOKIES = [("dfiles.eu", "lang_current", "en")]

    WAIT_PATTERN = r'(?:download_waiter_remain">|html_download_api-limit_interval">|>Please wait|>Try in).+'
    ERROR_PATTER = r'File is checked, please try again in a minute'

    LINK_FREE_PATTERN    = r'<form id="downloader_file_form" action="(http://.+?\.(dfiles\.eu|depositfiles\.com)/.+?)" method="post"'
    LINK_PREMIUM_PATTERN = r'class="repeat"><a href="(.+?)"'
    LINK_MIRROR_PATTERN  = r'class="repeat_mirror"><a href="(.+?)"'


    def handleFree(self, pyfile):
        self.html = self.load(pyfile.url, post={'gateway_result': "1"})

        self.checkErrors()

        m = re.search(r"var fid = '(\w+)';", self.html)
        if m is None:
            self.retry(wait_time=5)
        params = {'fid': m.group(1)}
        self.logDebug("FID: %s" % params['fid'])

        self.setWait(60)
        self.wait()

        recaptcha = ReCaptcha(self)
        captcha_key = recaptcha.detect_key()
        if captcha_key is None:
            return

        self.html = self.load("https://dfiles.eu/get_file.php", get=params)

        if '<input type=button value="Continue" onclick="check_recaptcha' in self.html:
            params['response'], params['challenge'] = recaptcha.challenge(captcha_key)
            self.html = self.load("https://dfiles.eu/get_file.php", get=params)

        m = re.search(self.LINK_FREE_PATTERN, self.html)
        if m:
            if 'response' in params:
                self.correctCaptcha()

            self.link = unquote(m.group(1))


    def handlePremium(self, pyfile):
        if '<span class="html_download_api-gold_traffic_limit">' in self.html:
            self.logWarning(_("Download limit reached"))
            self.retry(25, 60 * 60, "Download limit reached")

{'fraction_non_alphanumeric': 0.18596955658504302, 'fraction_numerical': 0.007941760423560556, 'mean_word_length': 2.9100905562742563, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 49, 'https://': 6, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2480156', 'n_tokens_mistral': 2247, 'n_tokens_neox': 2097, 'n_words': 362}