Example #1
0
    def tryTologin(self):
        printDBG('tryTologin start')
        connFailed = _('Connection to server failed!')

        sts, data = self.getPage(self.getMainUrl())
        if not sts:
            return False, connFailed

        if 'logout.php' in data:
            return True, 'OK'

        login = config.plugins.iptvplayer.mrpiracy_login.value
        passwd = config.plugins.iptvplayer.mrpiracy_password.value

        post_data = {
            'email': login,
            'password': passwd,
            'lembrar_senha': 'lembrar'
        }

        sitekey = self.cm.ph.getSearchGroups(data, 'fallback\?k=([^"]+?)"')[0]
        if sitekey != '':
            recaptcha = UnCaptchaReCaptcha_fallback(lang=GetDefaultLang())
            recaptcha.HTTP_HEADER['Referer'] = self.getMainUrl()
            recaptcha.HTTP_HEADER['User-Agent'] = self.USER_AGENT
            token = recaptcha.processCaptcha(sitekey)
            if token == '':
                return False, 'NOT OK'
            post_data.update({
                'g-recaptcha-response': token,
                'g-recaptcha-response2': token,
                'url': '/'
            })

        data = self.cm.ph.getDataBeetwenMarkers(data, '<form', '</form>',
                                                False)[1]
        url = self.getFullUrl(
            self.cm.ph.getSearchGroups(data,
                                       '''action=['"]([^'^"]+?)['"]''')[0])

        params = dict(self.defaultParams)
        params['header'] = dict(self.HEADER)
        params['header']['Referer'] = self.getMainUrl()

        # login
        sts, data = self.cm.getPage(url, params, post_data)
        if not sts:
            return False, connFailed

        if 'logout.php' in data:
            return True, 'OK'
        else:
            return False, 'NOT OK'
Example #2
0
 def processCaptcha(self, sitekey, refUrl, bypassCaptchaService=None, userAgent=None, baseErrMsgTab=None, beQuaiet=False):
     if isinstance(baseErrMsgTab, list):
         errorMsgTab = list(baseErrMsgTab)
     else:
         errorMsgTab = [_('Link protected with Google ReCaptcha v2')]
     
     if userAgent == None:
         try:
             userAgent = self.USER_AGENT
         except Exception:
             pass
     
     if userAgent == None:
         try:
             userAgent = self.defaultParams['header']['User-Agent']
         except Exception:
             pass
     
     recaptcha = UnCaptchaReCaptcha_fallback(lang=GetDefaultLang())
     recaptcha.HTTP_HEADER['Referer'] = refUrl
     if userAgent != None:
         recaptcha.HTTP_HEADER['User-Agent'] = userAgent
     token = recaptcha.processCaptcha(sitekey)
     
     if token == '':
         recaptcha = None
         if config.plugins.iptvplayer.captcha_bypass.value != '' and bypassCaptchaService == None:
             bypassCaptchaService = config.plugins.iptvplayer.captcha_bypass.value
         if bypassCaptchaService == '9kw.eu':
             recaptcha = UnCaptchaReCaptcha_9kw()
         elif bypassCaptchaService == '2captcha.com':
             recaptcha = UnCaptchaReCaptcha_2captcha()
         elif config.plugins.iptvplayer.myjd_login.value != '' and config.plugins.iptvplayer.myjd_password.value != '':
             recaptcha = UnCaptchaReCaptcha_myjd()
         
         if recaptcha != None:
             token = recaptcha.processCaptcha(sitekey, refUrl)
         else:
             errorMsgTab.append(_('Please visit %s to learn how to redirect this task to the external device.') % 'http://zadmario.gitlab.io/captcha.html')
             if not beQuaiet:
                 self.sessionEx.waitForFinishOpen(MessageBox, '\n'.join(errorMsgTab), type=MessageBox.TYPE_ERROR, timeout=20)
             if bypassCaptchaService != None:
                 errorMsgTab.append(_(' or '))
                 errorMsgTab.append(_('You can use \"%s\" or \"%s\" services for automatic solution.') % ("http://2captcha.com/", "https://9kw.eu/", ) + ' ' + _('Go to the host configuration available under blue button.'))
     return token, errorMsgTab
Example #3
0
    def processCaptcha(self,
                       sitekey,
                       refUrl,
                       bypassCaptchaService=None,
                       userAgent=None,
                       baseErrMsgTab=None,
                       beQuiet=False,
                       captchaType="v2",
                       challengeForm=""):

        recaptcha = None
        token = ""

        #captcha name
        if captchaType == "h":
            captchaName = 'hCaptcha'
        elif captchaType == "v3":
            captchaName = 'ReCaptcha v3'
        else:
            captchaName = 'ReCaptcha v2'

        # read error messages in input

        if isinstance(baseErrMsgTab, list):
            errorMsgTab = list(baseErrMsgTab)
        else:
            errorMsgTab = [_('Link protected with %s') % captchaName]

        if bypassCaptchaService:
            printDBG("Captcha_Helper_Max.bypassCaptchaService in input: %s " %
                     bypassCaptchaService)
            # service selected in input
            bypassCaptchaService = bypassCaptchaService.lower()

            if '2captcha' in bypassCaptchaService:
                if captchaType == "h":
                    recaptcha = UnCaptchahCaptcha_2captcha()
                elif captchaType == "v3":
                    recaptcha = UnCaptchaReCaptchav3_2captcha()
                else:
                    recaptcha = UnCaptchaReCaptcha_2captcha()
            elif '9kw' in bypassCaptchaService:
                if captchaType == "h" or captchaType == "v3":
                    errorMsgTab = [
                        _('Solution of %s with %s has not been implemented yet'
                          ) % (captchaName, bypassCaptchaService)
                    ]
                else:
                    recaptcha = UnCaptchaReCaptcha_9kw()
            elif 'myjd' in bypassCaptchaService:
                if captchaType == "h" or captchaType == "v3":
                    errorMsgTab = [
                        _('Solution of %s with %s has not been implemented yet'
                          ) % (captchaName, bypassCaptchaService)
                    ]
                else:
                    recaptcha = UnCaptchaReCaptcha_myjd()

            # call selected captcha solver
            if recaptcha:
                token = recaptcha.processCaptcha(sitekey, refUrl)

            return token, errorMsgTab

        else:
            printDBG("Captcha_Helper_Max: No bypassCaptchaService in input")

            # follow general settings
            captchaOrder = config.plugins.iptvplayer.captcha_bypass_order.value
            captchaFree = config.plugins.iptvplayer.captcha_bypass_free.value
            captchaPay = config.plugins.iptvplayer.captcha_bypass_pay.value

            printDBG(
                "Captcha_Helper_Max: captchaOrder: '%s', captchaFree: '%s', captchaPay: '%s'"
                % (captchaOrder, captchaFree, captchaPay))

            if not captchaOrder:
                # try with internal render
                printDBG("Captcha_Helper_Max: try with internal render")
                if captchaType == "h":
                    recaptcha = UnCaptchahCaptcha()
                    token = recaptcha.processCaptcha(
                        challenge_form=challengeForm, referer=refUrl)
                    return token, errorMsgTab
                elif captchaType != "v3":
                    printDBG(
                        "Captcha_Helper_Max: try with internal render Recaptcha v2"
                    )
                    recaptcha = UnCaptchaReCaptcha_fallback(
                        lang=GetDefaultLang())
                    if userAgent != None:
                        recaptcha.HTTP_HEADER['User-Agent'] = userAgent
                    token = recaptcha.processCaptcha(sitekey)

            if token:
                # success with internal solver
                printDBG(
                    "Captcha_Helper_Max: exit from internal solver ---> token: %s"
                    % token)

                return token, errorMsgTab

            # no success... try external services
            recaptcha = None

            if not captchaFree and not captchaPay:
                # no external services to use
                errorMsgTab.append(
                    _('Please visit %s to learn how to redirect this task to the external device.'
                      ) % 'http://www.iptvplayer.gitlab.io/captcha.html')
                if not beQuiet:
                    self.sessionEx.waitForFinishOpen(
                        MessageBox,
                        '\n'.join(errorMsgTab),
                        type=MessageBox.TYPE_ERROR,
                        timeout=20)
                if bypassCaptchaService != None:
                    errorMsgTab.append(_(' or '))
                    errorMsgTab.append(
                        _('You can use \"%s\" or \"%s\" services for automatic solution.'
                          ) % (
                              "http://2captcha.com/",
                              "https://9kw.eu/",
                          ) + ' ' +
                        _('Go to the host configuration available under blue button.'
                          ))

                return token, errorMsgTab

            if ("free" in captchaOrder or not captchaOrder) and captchaFree:
                # try free external solver (ex. myjdownloader)
                printDBG(
                    "Captcha_Helper_Max: try with external free service: %s " %
                    captchaFree)
                if ('myjd' in captchaFree.lower()) and captchaType == "v2":
                    printDBG("Captcha_Helper_Max: myjd 1")
                    if config.plugins.iptvplayer.myjd_login.value != '' and config.plugins.iptvplayer.myjd_password.value != '':
                        printDBG("Captcha_Helper_Max: myjd 2")
                        recaptcha = UnCaptchaReCaptcha_myjd()
                        printDBG("Captcha_Helper_Max: myjd 3")

                    else:
                        errorMsgTab.append(
                            _('If you want to use MyJDownloader, fill login and password in settings menu'
                              ))

                if recaptcha:
                    printDBG("Captcha_Helper_Max: myjd 4")
                    token = recaptcha.processCaptcha(sitekey, refUrl)
                    printDBG("Captcha_Helper_Max: myjd 5")

            if token:
                # success with free external services
                printDBG(
                    "Captcha_Helper_Max: exit after external free solver ---> token: %s"
                    % token)

                return token, errorMsgTab

            recaptcha = None
            if ("pay" in captchaOrder or not captchaOrder) and captchaPay:
                # try with a paid service
                printDBG(
                    "Captcha_Helper_Max: try with external free service: %s " %
                    captchaPay)

                if '2captcha' in captchaPay and captchaType == "h":
                    recaptcha = UnCaptchahCaptcha_2captcha()
                elif '2captcha' in captchaPay and captchaType == "v3":
                    recaptcha = UnCaptchaReCaptchav3_2captcha()
                elif '2captcha' in captchaPay:
                    recaptcha = UnCaptchaReCaptcha_2captcha()
                elif '9kw' in captchaPay:
                    if captchaType == "h" or captchaType == "v3":
                        errorMsgTab = [
                            _('Solution of %s with %s has not been implemented yet'
                              ) % (captchaName, bypassCaptchaService)
                        ]
                    else:
                        recaptcha = UnCaptchaReCaptcha_9kw()

                if recaptcha:
                    token = recaptcha.processCaptcha(sitekey, refUrl)

                if token:
                    printDBG(
                        "Captcha_Helper_Max: exit after external paid solver ---> token: %s"
                        % token)
                    return token, errorMsgTab

            else:
                # no paid services
                errorMsgTab.append(
                    _('You can use \"%s\" or \"%s\" services for automatic solution.'
                      ) % (
                          "http://2captcha.com/",
                          "https://9kw.eu/",
                      ) + ' ' +
                    _('Go to the host configuration available under blue button.'
                      ))

        return token, errorMsgTab