Пример #1
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
    def getVideoLinks(self, videoUrl):
        printDBG("MRPiracyGQ.getVideoLinks [%s]" % videoUrl)
        errorMsgTab = []
        urlTab = []
        
        # mark requested link as used one
        if len(self.cacheLinks.keys()):
            for key in self.cacheLinks:
                for idx in range(len(self.cacheLinks[key])):
                    if videoUrl in self.cacheLinks[key][idx]['url']:
                        if not self.cacheLinks[key][idx]['name'].startswith('*'):
                            self.cacheLinks[key][idx]['name'] = '*' + self.cacheLinks[key][idx]['name']
                        break

        if self.cm.isValidUrl(videoUrl):
            return self.up.getVideoLinkExt(videoUrl)

        playerData = strwithmeta(videoUrl).meta
        linkId = ''
        imdbId = ''
        try:
            tmp = []
            for it in ['playertype', 'episodio', 'id']:
                tmp.append(playerData.get(it, ''))
            imdbId = self.cm.ph.getSearchGroups(playerData['ref_url'], '''imdb=(tt[0-9]+)''')[0]
            tmp.insert(0, imdbId)
            linkId = '_'.join(tmp)
        except Exception:
            printExc()
        
        printDBG(">>> linkId[%s]" % linkId)
        hostUrl = MRPiracyGQ.LINKS_CACHE.get(linkId, '')
        if hostUrl == '' and config.plugins.iptvplayer.mrpiracy_linkcache.value:
            hostUrl = ReadTextFile(GetCacheSubDir('mrpiracy', linkId))[1]
        
        if hostUrl == '':
            try:
                jscode = playerData.pop('jscode', '')
                jscode += '''var iptv_fake_element={hide:function(){},show:function(){},addClass:function(){},removeClass:function(){}};playertype="iptv_player_data";var iptv_player_data=''' + json.dumps(playerData) + ''';$=function(){return 1==arguments.length&&arguments[0].endsWith(playertype)?{data:function(a){return iptv_player_data[a]}}:iptv_fake_element},$.ajax=function(){print(JSON.stringify(arguments[0]))},''' + playerData['callback'] + '''(iptv_player_data.sitekey);'''
                ret = iptv_js_execute(jscode)
                data = ret['data'].strip()
                data = byteify(json.loads(data))
                
                url = self.getFullUrl(data['url'])
                post_data = data['data']
                urlParams = dict(self.defaultParams)
                urlParams['header'] = dict(self.AJAX_HEADER)
                urlParams['header']['Referer'] = playerData['ref_url']

                if 'sitekey' in playerData:
                    errorMsgTab = [_('Link protected with google recaptcha v2.')]
                    recaptcha = UnCaptchaReCaptcha(lang=GetDefaultLang())
                    recaptcha.HTTP_HEADER['Referer'] = playerData['ref_url']
                    recaptcha.HTTP_HEADER['User-Agent'] = self.USER_AGENT
                    token = recaptcha.processCaptcha(playerData['sitekey'])
                    if token == '':
                        recaptcha = None
                        if config.plugins.iptvplayer.mrpiracy_bypassrecaptcha.value == '9kw.eu':
                            recaptcha = UnCaptchaReCaptcha_9kw()
                        elif config.plugins.iptvplayer.mrpiracy_bypassrecaptcha.value == '2captcha.com':
                            recaptcha = UnCaptchaReCaptcha_2captcha()
                        
                        if recaptcha != None:
                            token = recaptcha.processCaptcha(playerData['sitekey'], playerData['ref_url'])
                        else:
                            errorMsgTab.append(_('You can use \"%s\" or \"%s\" services to workaround this protection.') % ("http://2captcha.com/", "https://9kw.eu/", )) 
                            errorMsgTab.append(_('Go to the host configuration available under blue button.'))
                    
                    printDBG('> token "%s" ' % token)
                    post_data['token'] = token
                    
                sts, data = self.getPage(url, urlParams, post_data)
                printDBG("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$")
                printDBG(data)
                printDBG("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$")
                tmp = re.compile('''['"](https?://[^'^"]+?)['"]''').findall(data)
                for item in tmp:
                    if 1 == self.up.checkHostSupport(item):
                        hostUrl = item
                
                if hostUrl == '':
                    url = self.getFullUrl(self.cm.ph.getSearchGroups(data, '<iframe[^>]+?src="([^"]+?)"', 1, ignoreCase=True)[0])
                    if url != '':
                        urlParams = dict(self.defaultParams)
                        urlParams['header'] = dict(urlParams['header'])
                        urlParams['header']['Referer'] = playerData['ref_url']
                        sts, data = self.getPage(url, urlParams)
                        hostUrl = self.cm.ph.getSearchGroups(data, '''location\.href=['"]([^'^"]+?)['"]''')[0]
            except Exception:
                printExc()
    
        if self.cm.isValidUrl(hostUrl):
            if linkId != '':
                if config.plugins.iptvplayer.mrpiracy_linkcache.value and linkId not in MRPiracyGQ.LINKS_CACHE:
                    WriteTextFile(GetCacheSubDir('mrpiracy', linkId), hostUrl)
                MRPiracyGQ.LINKS_CACHE[linkId] = hostUrl
            
            urlTab = self.up.getVideoLinkExt(hostUrl)

        if 0 == len(urlTab):
            SetIPTVPlayerLastHostError('\n'.join(errorMsgTab)) 
        else:
            subUrl = 'https://cdn.mrpiracy.xyz/subs/%s.srt' % imdbId
            sts, data = self.getPage(subUrl)
            if sts and '00:'in data:
                for idx in range(len(urlTab)):
                    urlTab[idx]['url'] = strwithmeta(urlTab[idx]['url'])
                    if 'external_sub_tracks' not in urlTab[idx]['url'].meta: urlTab[idx]['url'].meta['external_sub_tracks'] = []
                    urlTab[idx]['url'].meta['external_sub_tracks'].append({'title':'', 'url':subUrl, 'lang':'pt', 'format':'srt'})
        return urlTab
Пример #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
Пример #4
0
    def getVideoLinks(self, videoUrl):
        printDBG("BSTO.getVideoLinks [%s]" % videoUrl)
        urlTab = []

        key = strwithmeta(videoUrl).meta.get('links_key', '')
        if key in self.cacheLinks:
            for idx in range(len(self.cacheLinks[key])):
                if self.cacheLinks[key][idx][
                        'url'] == videoUrl and not self.cacheLinks[key][idx][
                            'name'].startswith('*'):
                    self.cacheLinks[key][idx][
                        'name'] = '*' + self.cacheLinks[key][idx]['name']

        sts, data = self.getPage(videoUrl)
        if not sts: return []

        errorMsgTab = []

        baseUrl = self.cm.ph.getSearchGroups(
            data, '''href=['"][^'^"]*?(/out/[^'^"]+?)['"]''')[0]
        url = self.getFullUrl(baseUrl)
        prevUrl = url

        linkId = self.cm.ph.getSearchGroups(url, '''/out/([0-9]+)''')[0]
        hostUrl = BSTO.LINKS_CACHE.get(linkId, '')
        if hostUrl == '' and config.plugins.iptvplayer.bsto_linkcache.value:
            hostUrl = ReadTextFile(GetCacheSubDir('bs.to', linkId))[1]

        if hostUrl == '':
            sts, data = self.cm.getPage(prevUrl, self.defaultParams)
            if not sts: return []
            url = data.meta['url']

            if url == prevUrl:
                sitekey = self.cm.ph.getSearchGroups(
                    data, '''['"]sitekey['"]\s*?:\s*?['"]([^'^"]+?)['"]''')[0]
                if sitekey != '' and 'bitte das Captcha' in data:
                    errorMsgTab = [
                        _('Link protected with google recaptcha v2.')
                    ]
                    recaptcha = None
                    if config.plugins.iptvplayer.bsto_bypassrecaptcha.value == '9kw.eu':
                        recaptcha = UnCaptchaReCaptcha_9kw()
                    elif config.plugins.iptvplayer.bsto_bypassrecaptcha.value == '2captcha.com':
                        recaptcha = UnCaptchaReCaptcha_2captcha()

                    if recaptcha != None:
                        token = recaptcha.processCaptcha(sitekey, prevUrl)
                        if token != '':
                            sts, data = self.cm.getPage(
                                url + '?token=' + token, self.defaultParams)
                            if not sts: return []
                            url = data.meta['url']

            if 1 != self.up.checkHostSupport(url):
                url = baseUrl.replace('/out/', '/watch/')[1:]

                hostUrl = ''
                try:
                    sts, data = self.cm.getPage(self.getFullUrl('/api/' + url),
                                                self.getHeaders(url))
                    if not sts: return []

                    data = byteify(json.loads(data))
                    printDBG(data)

                    hostUrl = data['fullurl']
                except Exception:
                    printExc()
            else:
                hostUrl = url

        if 1 != self.up.checkHostSupport(hostUrl):
            SetIPTVPlayerLastHostError('\n'.join(errorMsgTab))
        elif self.cm.isValidUrl(hostUrl):
            BSTO.LINKS_CACHE[linkId] = hostUrl
            if config.plugins.iptvplayer.bsto_linkcache.value:
                WriteTextFile(GetCacheSubDir('bs.to', linkId), hostUrl)
            urlTab = self.up.getVideoLinkExt(hostUrl)

        return urlTab