Пример #1
0
    def _getUrl(self, jsCode, url='', data='', timestamp=''):
        printDBG("AnimeTo._getUrl url[%s], data[%s], timestamp[%s]" %
                 (url, data, timestamp))
        try:
            if False:
                tmp = EncodeGzipped('')
                tmp = self._cryptoJS_AES(
                    tmp, ''.join(GetPluginDir().split('/')[-5:]), False)
                tmp = hexlify(tmp)
                printDBG("$$$: " + tmp)
            else:
                tmp = 'ed3cfec3d06c36b40958c04b3cdfac405d3f49f2c8414537917d63db171714e2a14761c2f7f1aab84c0b91e47562fc4c7050284e95372807978603d115ec9b1e11accaf3493e91005f13a0e82bb461408027ae9d30572987a821eee530a9488927ac26a7c114b0a33bf76a472b3f9c583e856d754ecd11f5caf780f441c263b422db5ca8fb561144184049da10df93f1009fc9081ff0ffe77e341d53d94dd9a3c816713fb09b6b656c3b24185199f23c34bad676acfb1a9d91b7ae892d3e71b9ccc7368dffed08b276d9dd6987833f3cf1430ad9126e0661132db4c19bd12a8f5bcb64a4e938e0889bfcf4a636ca6e9b2e5eae05896ab902673be34cf82feaa357178ee32ee1b78796ea75d00b6181adebd500d071c35bd6aebc9e5650092d7c95d029713ed76f6d11d3e1153c759afa494f9461bfca8e6a30ddf3d7ecabb5a78aa62d37c78f90fb6df5f5138dd1c6415719c58f103335e6c6451b7b8de48bd80646d1d9b542977b4ff5d6332cdaf4f68e0fe24eea5b0d86039d6e66b558d011e29c2e946683739cc2c0619aa65de58ca5fed484b8db9f3eea0866e6f21ba839d4c177bc2efcd85aa6055520176c67528ccc1f5e9880e833d24ed9b84a7e24f315de0d6eaa38320f5daff8d42ed6edce911ded996ca077bf2b3acc76d5ceea0a6c590b4f58566f55c35d670b95b22881214b11e6779c43a3729a5acc36187f3e88cf9baf82782aa61868ae21b7a778e4d228ff1deb7475e56a74efae1334d8ffb12c428aaf7d6e10fb64464eac3d2c3a3b112920f7193ea57efc0095614c28fdd81143ab42fa21d61610f6062072a2abfd6dc702c22af67552c4c8c5cd347bc40597641c5fd69c2aa68641ee3960b323a5332326cb4505e52cff439dda63b78682dab7002d362835f189afb2535da6e3336f583602051e5693e7f286ca20507f8ef90c6a1c6fde24843a3bbd417ab463cd7d8105bc77f1e514a76cf5b81d95e80dd62892aeebf6b9e443bca6fb83e21890222bd65ae1ddb9eac051c29b78f43b'
                tmp = self._cryptoJS_AES(
                    unhexlify(tmp), ''.join(GetPluginDir().split('/')[-5:]))
                tmp = DecodeGzipped(tmp)
        except Exception:
            printExc()

        retUrl = ''
        jscode = [
            'iptv_ts=%s;' % timestamp, tmp, jsCode,
            'iptv_arg = {url:"%s", "data":"%s"}; iptv_call(iptv_arg); print(JSON.stringify(iptv_arg));'
            % (url, data)
        ]
        ret = js_execute('\n'.join(jscode), {'timeout_sec': 15})
        if ret['sts'] and 0 == ret['code']:
            data = ret['data'].strip()
            try:
                data = json_loads(data)
                retUrl = data['url']
                if data['data'] != '':
                    retUrl += '&' + data['data']
            except Exception:
                printExc()
        return retUrl
Пример #2
0
    def getVideoLinks(self, videoUrl):
        printDBG("Cinemay.getVideoLinks [%s]" % videoUrl)
        videoUrl = strwithmeta(videoUrl)
        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

        params = dict(self.defaultParams)
        params['header'] = dict(params['header'])
        params['header']['Referer'] = videoUrl.meta.get('Referer', '')

        sts, data = self.getPage(self.getFullUrl('/image/logo.png'), params)
        if not sts:
            return []

        if 1 != self.up.checkHostSupport(videoUrl):
            sts, data = self.getPage(videoUrl, params)
            if not sts:
                return []
            scripts = []
            tmp = self.cm.ph.getAllItemsBeetwenNodes(data, ('<script', '>'),
                                                     ('</script', '>'), False)
            for item in tmp:
                if 'eval(' not in item:
                    continue
                scripts.append(item.strip())
            try:
                jscode = base64.b64decode(
                    '''dmFyIGRvY3VtZW50PXt9LHdpbmRvdz10aGlzO3dpbmRvdy5sb2NhdGlvbj17aG9zdG5hbWU6IiVzIn0sZG9jdW1lbnQud3JpdGU9ZnVuY3Rpb24obil7cHJpbnQobil9Ow=='''
                ) % (self.up.getDomain(videoUrl, True))
                ret = js_execute(jscode + '\n'.join(scripts))
                if ret['sts'] and 0 == ret['code']:
                    data = ret['data'].strip()
                    videoUrl = self.cm.ph.getSearchGroups(
                        data,
                        '''url['"]?=['"]?([^'^"^>]+?)['">]''')[0].strip()
            except Exception:
                printExc()

        if 0 and 1 != self.up.checkHostSupport(videoUrl):
            params = dict(self.defaultParams)
            params['header'] = dict(params['header'])
            params['header']['Referer'] = videoUrl.meta.get('Referer', '')
            params['max_data_size'] = 0
            self.getPage(videoUrl, params)
            videoUrl = self.cm.meta.get('url', '')

        urlTab = self.up.getVideoLinkExt(videoUrl)

        return urlTab
Пример #3
0
    def getPage(self, url, addParams={}, post_data=None):
        if addParams == {}:
            addParams = dict(self.defaultParams)
        addParams['cloudflare_params'] = {
            'cookie_file': self.COOKIE_FILE,
            'User-Agent': self.HTTP_HEADER['User-Agent']
        }
        sts, data = self.cm.getPageCFProtection(url, addParams, post_data)
        if sts:
            if 'sucuri_cloudproxy' in data:
                cookieItems = {}
                jscode = self.cm.ph.getDataBeetwenNodes(
                    data, ('<script', '>'), ('</script', '>'), False)[1]
                if 'eval' in jscode:
                    jscode = '%s\n%s' % (base64.b64decode(
                        '''dmFyIGlwdHZfY29va2llcz1bXSxkb2N1bWVudD17fTtPYmplY3QuZGVmaW5lUHJvcGVydHkoZG9jdW1lbnQsImNvb2tpZSIse2dldDpmdW5jdGlvbigpe3JldHVybiIifSxzZXQ6ZnVuY3Rpb24obyl7bz1vLnNwbGl0KCI7IiwxKVswXS5zcGxpdCgiPSIsMiksb2JqPXt9LG9ialtvWzBdXT1vWzFdLGlwdHZfY29va2llcy5wdXNoKG9iail9fSk7dmFyIHdpbmRvdz10aGlzLGxvY2F0aW9uPXt9O2xvY2F0aW9uLnJlbG9hZD1mdW5jdGlvbigpe3ByaW50KEpTT04uc3RyaW5naWZ5KGlwdHZfY29va2llcykpfTs='''
                    ), jscode)
                    ret = js_execute(jscode)
                    if ret['sts'] and 0 == ret['code']:
                        cookies = byteify(json.loads(ret['data'].strip()))
                        for cookie in cookies:
                            cookieItems.update(cookie)
                self.defaultParams['cookie_items'] = cookieItems
                addParams = dict(self.defaultParams)
                addParams['cloudflare_params'] = {
                    'cookie_file': self.COOKIE_FILE,
                    'User-Agent': self.HTTP_HEADER['User-Agent']
                }
                removeCookieItems = False
                sts, data = self.cm.getPageCFProtection(
                    url, addParams, post_data)

        return sts, data
Пример #4
0
    def parser_(self, baseUrl):
        printDBG("parser baseUrl[%s]" % baseUrl)
        videoTab = []
        HTTP_HEADER = self.cm.getDefaultHeader(browser='chrome')
        defaultParams = {'header': HTTP_HEADER}
        sts, data = self.cm.getPage(baseUrl, defaultParams)
        if not sts: return []
        Liste_els = re.findall('(eval.*?)</script>', data, re.S)

        ################Methode1##############
        #data = unpackJSPlayerParams(Liste_els[0].strip(), VIDUPME_decryptPlayerParams,1)
        ####################################

        ################Methode2################
        jscode = [
            'window=this; function jwplayer() {return {setup:function(){print(JSON.stringify(arguments[0]))}}}'
        ]
        jscode.append(Liste_els[0].strip())
        ret = js_execute('\n'.join(jscode))
        data = ret['data']
        ####################################

        Liste_els = re.findall('file.*?:"(.*?)"', data, re.S)
        if Liste_els:
            videoTab.append({'url': Liste_els[0], 'name': 'Samaup'})
        return videoTab
Пример #5
0
    def getPage(self, baseUrl, addParams={}, post_data=None):
        if addParams == {}:
            addParams = dict(self.defaultParams)

        origBaseUrl = baseUrl
        baseUrl = self.cm.iriToUri(baseUrl)

        addParams['cloudflare_params'] = {'cookie_file': self.COOKIE_FILE, 'User-Agent': self.USER_AGENT}
        sts, data = self.cm.getPageCFProtection(baseUrl, addParams, post_data)
        if sts and 'aes.min.js' in data:
            jscode = ['var document={};document.location={};']
            tmp = self.cm.ph.getAllItemsBeetwenNodes(data, ('<script', '>'), ('</script', '>'))
            for item in tmp:
                scriptUrl = self.cm.getFullUrl(self.cm.ph.getSearchGroups(item, '''src=['"]([^'^"]+?)['"]''')[0], self.cm.meta['url'])
                if scriptUrl != '':
                    sts2, item = self.cm.getPage(scriptUrl, addParams, post_data)
                    if sts2:
                        jscode.append(item)
                else:
                    item = self.cm.ph.getDataBeetwenNodes(item, ('<script', '>'), ('</script', '>'), False)[1]
                    if item != '':
                        jscode.append(item)
            jscode.append('print(JSON.stringify(document));')
            ret = ret = js_execute('\n'.join(jscode), {'timeout_sec': 15})
            if ret['sts'] and 0 == ret['code']:
                try:
                    tmp = byteify(json.loads(ret['data']))
                    item = tmp['cookie'].split(';', 1)[0].split('=', 1)
                    self.defaultParams['cookie_items'] = {item[0]: item[1]}
                    addParams['cookie_items'] = self.defaultParams['cookie_items']
                    sts, data = self.cm.getPage(baseUrl, addParams, post_data)
                except Exception:
                    printExc()
        return sts, data
Пример #6
0
 def fillServerApiData(self):
     printDBG('EuroSportPlayer.fillServerApiData')
     if self.serverApiData != {}:
         return
     
     serverApiData = {}
     sts, data = self.getPage(self.getMainUrl())
     if not sts: return False
     
     jscode = ['var window={};function getStartupDeviceTypeString(){return "desktop";}\nwindow.requirejs_data={};requirejs=function(){if (2 == arguments.length) {window.requirejs_data.siteScripts=arguments[0];arguments[1]()} else {window.requirejs_data.scripts=arguments[0];}};requirejs.config=function(){window.requirejs_data.config=arguments[0];};']
     markers = ['window.server_path','window.i18n_dictionary','window.locale','window.SPORTS_BY_ID','window.bamTrackingConfig','window.specialEvents','requirejs']
     data = self.cm.ph.getAllItemsBeetwenNodes(data, ('<script', '>'), ('</script', '>'), False)
     for item in data:
         for m in markers:
             if m in item:
                 jscode.append(item)
                 break
     jscode.append('\nprint(JSON.stringify(window));')
     ret = js_execute( '\n'.join(jscode) )
     if ret['sts'] and 0 == ret['code']:
         data = ret['data'].strip()
         try:
             serverApiData = json_loads(data)
             clientId = serverApiData['server_path']['sdk']['clientId']
             env = serverApiData['server_path']['sdk']['environment']
             url = 'https://bam-sdk-configs.mlbam.net/v0.1/%s/browser/v2.1/windows/chrome/%s.json' % (clientId, env)
             sts, data = self.getPage(url)
             if not sts: return False
             serverApiData['prod'] = json_loads(data)
         except Exception:
             printExc()
             return
     
     self.serverApiData = serverApiData
Пример #7
0
    def exploreItem(self, cItem):
        printDBG("UstreamTV.exploreItem cItem: %s" % cItem)

        url = cItem['url']

        resp = self.session.get(url)
        if not resp:
            return
        data = resp.content

        funcs = self.cm.ph.getAllItemsBeetwenMarkers(
            data, 'eval(function(p,a,c,k,e,d)', '</script>')
        videolink = None
        for func in funcs:
            func = func.replace('</script>', '')
            func = func.replace('eval', 'console.log')

            ret = js_execute(func)
            data = ret['data']

            if 'jdtk=' in data:
                #printDBG("UstreamTV.exploreItem data: %s" % data)
                filename = self.cm.ph.getSearchGroups(
                    data, '''file_name="([^"]+?)"''')[0]
                token = self.cm.ph.getSearchGroups(data,
                                                   '''jdtk="([^"]+?)"''')[0]
                host = self.cm.ph.getSearchGroups(data,
                                                  '''host_tmg="([^"]+?)"''')[0]
                adresa = self.cm.ph.getSearchGroups(data,
                                                    '''adresa="([^"]+?)"''')[0]
                videolink = 'http://' + host + "/" + filename + "?token=" + token

                import math
                import time

                mytimez = math.floor(int(time.time() * 1000) / 1000)

                l1 = "https://cdn.ustream.to/ts_count/%s-tmg.txt?%s" % (
                    adresa, str(mytimez))
                resp = self.session.get(l1)
                if not resp:
                    return
                ts_count = resp.content
                #printDBG("UstreamTV.exploreItem ts_count: %s" % ts_count)

                l2 = "https://cdn.ustream.to/ts_count/%s-sequence.txt?%s" % (
                    adresa, str(mytimez))
                resp = self.session.get(l2)
                if not resp:
                    return
                sequence = resp.content
                #printDBG("UstreamTV.exploreItem sequence: %s" % sequence)

                videolink += "&sequence=" + sequence

                params = dict(cItem)
                params.update(
                    {'url': strwithmeta(videolink, {'Referer': cItem['url']})})
                self.addVideo(params)
                break
Пример #8
0
    def getVideoLinks(self, videoUrl):
        printDBG("TantiFilmOrg.getVideoLinks [%s]" % videoUrl)
        urlTab = []

        # mark requested link as used one
        if len(self.cacheLinks.keys()):
            key = self.cacheLinks.keys()[0]
            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
        tries = 0
        while tries < 4:
            tries += 1
            printDBG(">> tries [%d]" % tries)
            if not self.cm.isValidUrl(videoUrl):
                break
            if 1 != self.up.checkHostSupport(videoUrl):
                addParams = dict(self.defaultParams)
                addParams['with_metadata'] = True
                sts, data = self.getPage(videoUrl, addParams)
                if sts:
                    videoUrl = data.meta['url']
                    jscode = [
                        'var document={},window=this;function typeOf(r){return{}.toString.call(r).match(/\s(\w+)/)[1].toLowerCase()}function jQuery(){return"function"==typeOf(arguments[0])&&arguments[0](),jQuery}jQuery.ready=jQuery,jQuery.attr=function(r,t){"src"==r&&print(t)},$=jQuery;'
                    ]
                    tmp = self.cm.ph.getAllItemsBeetwenNodes(
                        data, ('<script', '>'), ('</script', '>'), False)
                    for item in tmp:
                        jscode.append(item)
                    ret = js_execute('\n'.join(jscode))
                    if ret['sts'] and 0 == ret['code']:
                        data = ret['data'].strip()
                        if self.cm.isValidUrl(data):
                            videoUrl = data

            if 'hostvid.xyz' in self.up.getDomain(videoUrl):
                sts, data = self.getPage(videoUrl)
                if not sts: return []
                videoUrl = self.cm.ph.getSearchGroups(
                    data,
                    '''<iframe[^>]+?src=['"]([^'^"]+?)['"]''',
                    ignoreCase=True)[0]
            if self.cm.isValidUrl(videoUrl):
                urlTab = self.up.getVideoLinkExt(videoUrl)
                if len(urlTab):
                    break
            try:
                data = self.cm.ph.getSearchGroups(
                    data,
                    '''<iframe[^>]+?src=['"]([^'^"]+?)['"]''',
                    ignoreCase=True)[0]
                if self.cm.isValidUrl(data):
                    videoUrl = data
            except Exception:
                printExc()
                break
        return urlTab
Пример #9
0
    def getLinksForVideo(self, cItem):
        printDBG("ustvgo.getLinksForVideo [%s]" % cItem)

        sts, data = self.getPage(cItem['url'])
        if not sts: return

        if 'player.setup' not in data:
            url = self.getFullUrl(
                self.cm.ph.getSearchGroups(
                    data, '''src=['"]([^"^']+?player2?\.php[^"^']*?)['"]''', 1,
                    True)[0])
            sts, data = self.getPage(url)
            if not sts: return


#        jsfunc = self.cm.ph.getDataBeetwenMarkers(data, 'var setup', '}', False)[1]
        jsfunc = self.cm.ph.getSearchGroups(data, '''source:\s([^,]+?),''', 1,
                                            True)[0]
        if jsfunc == '':
            jsfunc = self.cm.ph.getSearchGroups(data, '''file:\s([^,]+?),''',
                                                1, True)[0]
        jscode = [
            base64.b64decode(
                '''dmFyIHBsYXllcj17fTtmdW5jdGlvbiBzZXR1cChlKXt0aGlzLm9iaj1lfWZ1bmN0aW9uIGp3cGxheWVyKCl7cmV0dXJuIHBsYXllcn1wbGF5ZXIuc2V0dXA9c2V0dXAsZG9jdW1lbnQ9e30sZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQ9ZnVuY3Rpb24oZSl7cmV0dXJue2lubmVySFRNTDppbnRlckh0bWxFbGVtZW50c1tlXX19Ow=='''
            )
        ]
        interHtmlElements = {}
        tmp = ph.findall(data, ('<span', '>', 'display:none'),
                         '</span>',
                         flags=ph.START_S)
        for idx in range(1, len(tmp), 2):
            elemId = self.cm.ph.getSearchGroups(tmp[idx - 1],
                                                '''id=([^>]+?)>''', 1, True)[0]
            interHtmlElements[elemId] = tmp[idx].strip()
        jscode.append('var interHtmlElements=%s;' %
                      json_dumps(interHtmlElements))
        data = self.cm.ph.getAllItemsBeetwenNodes(data, ('<script', '>'),
                                                  ('</script', '>'), False)
        for item in data:
            if jsfunc in item:
                data = item
        tmp = re.compile('''(var\s.+?\s\[.+?\];)''').findall(data)
        jscode.append('\n'.join(tmp))
        tmp = self.cm.ph.getDataBeetwenNodes(data, ('function', '{', jsfunc),
                                             '}')[1]
        jscode.append(tmp)
        jscode.append('print(%s);' % jsfunc)
        ret = js_execute('\n'.join(jscode))
        if ret['sts'] and 0 == ret['code']:
            url = "".join(ret['data'].split())
            url = strwithmeta(
                url, {
                    'User-Agent': self.USER_AGENT,
                    'Origin': self.MAIN_URL,
                    'Referer': cItem['url']
                })
            return getDirectM3U8Playlist(url)
        else:
            return []
Пример #10
0
    def getPage(self, baseUrl, addParams={}, post_data=None):
        if addParams == {}:
            addParams = dict(self.defaultParams)

        def _getFullUrl(url):
            if url == '':
                return ''

            if self.cm.isValidUrl(url):
                return url
            else:
                return urlparse.urljoin(baseUrl, url)

        addParams['cloudflare_params'] = {'domain': self.up.getDomain(baseUrl), 'cookie_file': self.COOKIE_FILE, 'User-Agent': self.USER_AGENT, 'full_url_handle': _getFullUrl}

        url = baseUrl
        urlParams = deepcopy(addParams)
        urlData = deepcopy(post_data)
        unloadUrl = None #
        tries = 0
        removeCookieItems = False
        while tries < 20:
            tries += 1
            sts, data = self.cm.getPageCFProtection(url, urlParams, urlData)
            if not sts:
                return sts, data

            if unloadUrl != None:
                self.cm.getPageCFProtection(unloadUrl, urlParams)
                unloadUrl = None

            if 'sucuri_cloudproxy' in data:
                cookieItems = {}
                jscode = self.cm.ph.getDataBeetwenNodes(data, ('<script', '>'), ('</script', '>'), False)[1]
                if 'eval' in jscode:
                    jscode = '%s\n%s' % (base64.b64decode('''dmFyIGlwdHZfY29va2llcz1bXSxkb2N1bWVudD17fTtPYmplY3QuZGVmaW5lUHJvcGVydHkoZG9jdW1lbnQsImNvb2tpZSIse2dldDpmdW5jdGlvbigpe3JldHVybiIifSxzZXQ6ZnVuY3Rpb24obyl7bz1vLnNwbGl0KCI7IiwxKVswXS5zcGxpdCgiPSIsMiksb2JqPXt9LG9ialtvWzBdXT1vWzFdLGlwdHZfY29va2llcy5wdXNoKG9iail9fSk7dmFyIHdpbmRvdz10aGlzLGxvY2F0aW9uPXt9O2xvY2F0aW9uLnJlbG9hZD1mdW5jdGlvbigpe3ByaW50KEpTT04uc3RyaW5naWZ5KGlwdHZfY29va2llcykpfTs='''), jscode)
                    ret = js_execute(jscode)
                    if ret['sts'] and 0 == ret['code']:
                        try:
                            cookies = byteify(json_loads(ret['data'].strip()))
                            for cookie in cookies:
                                cookieItems.update(cookie)
                        except Exception:
                            printExc()
                self.defaultParams['cookie_items'] = cookieItems
                urlParams['cookie_items'] = cookieItems
                removeCookieItems = False
                sts, data = self.cm.getPageCFProtection(url, urlParams, urlData)

            # remove not needed used cookie
            if removeCookieItems:
                self.defaultParams.pop('cookie_items', None)
            self.cm.clearCookie(self.COOKIE_FILE, removeNames=['___utmvc'])
            #printDBG(data)
            return sts, data

        return self.cm.getPageCFProtection(baseUrl, addParams, post_data)
Пример #11
0
    def getLinksForVideo(self, cItem):
        linksTab = self.cacheLinks.get(cItem['url'], [])
        if linksTab: return linksTab

        url_data = cItem['url'].split('?', 1)
        if len(url_data) != 2: return []

        query = {}
        url_data[1] = url_data[1].split('&')
        for item in url_data[1]:
            item = item.split('=', 1)
            if len(item) != 2: continue
            query[item[0]] = item[1]
        url_data[1] = query

        url_data[1]['server'] = 'alternate'
        url_data[1]['referrer'] = 'link'
        url = self.joinLink(url_data)

        sts, data = self.getPage(url)
        if sts:
            e = '1' #ph.clean_html(ph.find(data, ('<span', '>', 'serverActive'), '</a>')[1])
            data = self.getFunctionCode(data, 'function streams(')
            jscode = 'efun=function(){},elem={slideToggle:efun,toggleClass:efun,hide:efun,removeAttr:efun,attr:efun},$=function(){return elem},$.post=function(){print(arguments[0])};document={"querySelector":function(){return {"textContent":"'
            jscode += e + '"};}};streams();' + data
            ret = js_execute(jscode)
            if ret['sts'] and 0 == ret['code']:
                url = self.getFullUrl(ret['data'].strip(), self.cm.meta['url'])
                sts, data = self.getPage(url)
                if sts:
                    printDBG(">>>")
                    printDBG(data)
                    data = ph.find(data, ('<ul', '>'), '</ul>', flags=0)[1].split('</li>')
                    for item in data:
                        tmp = ph.find(item, 'show_player(', ')', flags=0)[1].replace('\\"', '"').replace("\\'", "'")
                        url = self.getFullUrl(ph.search(item, '''['"]((?:https?:)?//[^'^"]+?)['"]''')[0])
                        if not url: url = ph.search(item, ph.A)[1]
                        if url:
                            name = []
                            item = ph.findall(item, ('<span', '>'), '</span>', flags=0)
                            for t in item:
                                t = ph.clean_html(t)
                                if t: name.append(t)
                            linksTab.append({'name':' | '.join(name), 'url':url, 'need_resolve':1})

        url_data[1]['server'] = '1'
        url_data[1]['referrer'] = 'link'
        url = self.joinLink(url_data)
        linksTab.insert(0, {'name':'Server 1', 'url':url, 'need_resolve':1})

        if len(linksTab):
            self.cacheLinks[cItem['url']] = linksTab

        return linksTab
Пример #12
0
        def _findHostingLinks(data, linkTab, premium):
            if premium:
                jscode = [base64.b64decode('''dmFyIGRvY3VtZW50PXt9LHdpbmRvdz10aGlzLGVsZW1lbnQ9ZnVuY3Rpb24obil7dGhpcy5odG1sPWZ1bmN0aW9uKG4pe3ByaW50KG4pfSx0aGlzLmhpZGU9ZnVuY3Rpb24oKXt9fSwkPWZ1bmN0aW9uKG4pe3JldHVybiBuZXcgZWxlbWVudChuKX07''')]
                tmp = self.cm.ph.getAllItemsBeetwenNodes(data, ('<script', '>'), ('</script', '>'), False)
                for item in tmp:
                    if 'function ShowPlayer(' in item:
                        jscode.append(item)
                        break
                jscode = '\n'.join(jscode)

            playersData = self.cm.ph.getDataBeetwenMarkers(data, '<ul class="players"', '</ul>', False)[1]

            playersData = playersData.split('</li>')
            if len(playersData):
                del playersData[-1]
            players = []
            for item in playersData:
                item = self.cm.ph.getDataBeetwenMarkers(item, '<li>', '</a>', False)[1]
                title = self.cleanHtmlStr(item)
                id = self.cm.ph.getSearchGroups(item, 'href="#([^"]+?)"')[0]
                tmp = reTitleObj.findall(item)
                title += ' ' + ' '.join(tmp)
                players.append({'title': title, 'id': id})

            tmp = self.cm.ph.getDataBeetwenMarkers(data, '<div class="tab-content">', '<script>', False)[1]
            tmp = tmp.split('</div>')
            if len(tmp):
                del tmp[-1]
            for item in tmp:
                id = self.cm.ph.getSearchGroups(item, 'id="([^"]+?)"')[0]
                playerParams = self.cm.ph.getSearchGroups(item, '''ShowPlayer[^"^']*?['"]([^"^']+?)['"]\s*\,\s*['"]([^"^']+?)['"]''', 2)
                url = ''
                if premium and '' not in playerParams:
                    ret = js_execute(jscode + ('\nShowPlayer("%s","%s");' % (playerParams[0], playerParams[1])))
                    if ret['sts'] and 0 == ret['code']:
                        printDBG(ret['data'])
                        url = self.getFullUrl(self.cm.ph.getSearchGroups(ret['data'], '''<iframe[^>]+?src=['"]([^"^']+?)['"]''', ignoreCase=True)[0])
                else:
                    if '' not in playerParams:
                        url = baseVidUrl + '/'.join(playerParams)
                    if url == '':
                        url = self.cm.ph.getSearchGroups(item, 'src="([^"]+?)"')[0]

                url = self.getFullUrl(url)
                if url == '' or url.split('?', 1)[0].split('.')[-1].lower() in ['jpg', 'jepg', 'gif', 'png']:
                    continue
                for p in players:
                    if p['id'] == id:
                        if premium:
                            linkTab.append({'name': '[premium] %s' % p['title'], 'url': strwithmeta(url, {'Referer': cItem['url'], 'is_premium': True}), 'need_resolve': 1})
                        else:
                            linkTab.append({'name': p['title'], 'url': strwithmeta(url, {'Referer': cItem['url']}), 'need_resolve': 1})
                        break
Пример #13
0
 def _getPlayerData(self, data):
     printDBG(data)
     jscode = self.cm.ph.getDataBeetwenNodes(data, ('<script', '>'),
                                             ('</script', '>'), False)[1]
     jscode = 'var document={write:function(e){print(e)}};window=this,window.atob=function(e){e.length%4==3&&(e+="="),e.length%4==2&&(e+="=="),e=Duktape.dec("base64",e),decText="";for(var t=0;t<e.byteLength;t++)decText+=String.fromCharCode(e[t]);return decText};' + jscode
     ret = js_execute(jscode)
     if ret['sts'] and 0 == ret['code']:
         printDBG(ret['data'])
         return self.cm.ph.getSearchGroups(
             ret['data'], '''<iframe[^>]+?src=['"]([^"^']+?)['"]''', 1,
             True)[0].replace('&amp;', '&')
     return ''
Пример #14
0
    def getLinksForVideo(self, cItem):
        printDBG("eKinomaniak.getLinksForVideo [%s]" % cItem)

        cacheKey = cItem['url']
        cacheTab = self.cacheLinks.get(cacheKey, [])
        if len(cacheTab): return cacheTab

        self.cacheLinks = {}

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

        cUrl = cItem['url']
        url = cItem['url']

        retTab = []

        params['header']['Referer'] = cUrl
        sts, data = self.getPage(url, params)
        if not sts: return []

        sts, jscode = self.getPage('https://ekinomaniak.net/js/bootstrap.php',
                                   params)
        if not sts: return []

        cUrl = data.meta['url']
        self.setMainUrl(cUrl)
        data = self.cm.ph.getAllItemsBeetwenNodes(data, 'document.write(shwp',
                                                  ('</script', '>'))

        for item in data:
            printDBG("eKinomaniak.getLinksForVideo item[%s]" % item)
            shwp = self.cm.ph.getSearchGroups(item,
                                              '''shwp\(['"]([^"^']+?)['"]''',
                                              1, True)[0]
            tmp = jscode + ';var test="%s";print(shwp(test))' % shwp
            ret = js_execute(tmp)
            if ret['sts'] and 0 == ret['code']:
                data = ret['data'].strip()
                playerUrl = self.cm.ph.getSearchGroups(
                    data, '''src=['"]([^"^']+?)['"]''', 1, True)[0]
            else:
                continue
            retTab.append({
                'name': self.up.getHostName(playerUrl),
                'url': strwithmeta(playerUrl, {'Referer': url}),
                'need_resolve': 1
            })

        if len(retTab):
            self.cacheLinks[cacheKey] = retTab
        return retTab
Пример #15
0
    def getVideoLinks(self, videoUrl):
        printDBG("FilmeHD.getVideoLinks [%s]" % videoUrl)
        videoUrl = strwithmeta(videoUrl)
        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

        params = dict(self.defaultParams)
        params['header'] = dict(params['header'])
        params['header']['Referer'] = str(
            videoUrl.meta.get('Referer', self.getMainUrl()))

        sts, data = self.getPage(videoUrl, params)
        if not sts:
            return urlTab

        url = self.getFullUrl(
            self.cm.ph.getSearchGroups(
                data, '''<iframe[^>]+?src=['"]([^"^']+?)['"]''', 1, True)[0])
        if url == '':
            jscode = [
                'window=this,window.outerWidth=640,window.innerWidth=640;var document=this;document.write=function(text){var startRe=new RegExp("(<script[^>]*?>)","i").exec(text),endRe=new RegExp("(</script[^>]*?>)","i").exec(text);null!=startRe&&null!=endRe?(text=text.replace(startRe[1],""),text=text.replace(endRe[1],""),text=text.replace(/var\s+/g,"this."),print(text),eval(text)):print(text)};'
            ]
            data = re.compile('''<script[^>]+?src=['"]([^'^"]+?)['"]''',
                              re.I).findall(data)
            for item in data:
                item = self.getFullUrl(item)
                sts, item = self.getPage(item, params)
                if sts:
                    jscode.append(item)

            ret = js_execute('\n'.join(jscode))
            if ret['sts'] and 0 == ret['code']:
                printDBG(ret['data'])
                url = self.getFullUrl(
                    self.cm.ph.getSearchGroups(
                        ret['data'], '''<iframe[^>]+?src=['"]([^"^']+?)['"]''',
                        1, True)[0].replace('&amp;', '&'))

        if url != '':
            urlTab = self.up.getVideoLinkExt(url)
        return urlTab
Пример #16
0
 def getLinksForVideo(self, cItem):
     printDBG("WRealu24TV.getLinksForVideo [%s]" % cItem)
     retTab = []
     hlsTab = []
     
     sts, data = self.getPage(cItem['url'])
     if not sts: return
     
     data = re.sub("<!--[\s\S]*?-->", "", data)
     cookieHeader = self.cm.getCookieHeader(self.COOKIE_FILE)
     
     data = self.cm.ph.getDataBeetwenMarkers(data, '<video', '</video>')[1]
     if 'document.write(' in data:
         jscode = ['var document = {};document.write=function(txt){print(txt);}']
         tmp = self.cm.ph.getAllItemsBeetwenNodes(data, ('<script', '>'), ('</script', '>'), False)
         for item in tmp:
             jscode.append(item)
         jscode = '\n'.join(jscode)
         ret = js_execute( jscode )
         if ret['sts'] and 0 == ret['code']:
             data = ret['data'].strip()
     
     data = self.cm.ph.getAllItemsBeetwenMarkers(data, '<source', '>')
     printDBG(data)
     for item in data:
         url = self.getFullUrl(self.cm.ph.getSearchGroups(item, '''src=['"]([^'^"]+?)['"]''')[0])
         if not self.cm.isValidUrl(url): continue
         type = self.cm.ph.getSearchGroups(item, '''type=['"]([^'^"]+?)['"]''')[0].lower()
         label = self.cm.ph.getSearchGroups(item, '''label=['"]([^'^"]+?)['"]''')[0]
         res = self.cm.ph.getSearchGroups(item, '''res=['"]([^'^"]+?)['"]''')[0]
         if label == '': label = res
         
         if 'mp4' in type:
             url = self.up.decorateUrl(url, {'Cookie':cookieHeader, 'User-Agent':self.USER_AGENT, 'Referer':cItem['url']})
             retTab.append({'name':label, 'url':url, 'res':res, 'need_resolve':0})
         elif 'mpegurl' in type:
             url = self.up.decorateUrl(url, {'iptv_proto':'m3u8', 'Origin':self.up.getDomain(cItem['url'], False), 'Cookie':cookieHeader, 'User-Agent':self.USER_AGENT, 'Referer':cItem['url']}) 
             hlsTab.extend(getDirectM3U8Playlist(url, checkContent=True, sortWithMaxBitrate=999999999))
         else:
             printDBG("Unknown source: [%s]" % item)
     
     if 1 < len(retTab):
         def __getLinkQuality( itemLink ):
             try: return int(itemLink['res'])
             except Exception: return 0
         oneLink = CSelOneLink(retTab, __getLinkQuality, 999999999)
         retTab = oneLink.getSortedLinks()
     
     retTab.extend(hlsTab)
     return retTab
Пример #17
0
    def getLinksForVideo(self, cItem):
        printDBG("MusicMp3Ru.getLinksForVideo [%s]" % cItem)

        if self.jscode == []:
            sts, data = self.getPage(self.getMainUrl())
            if not sts:
                return []
            scriptUrl = self.cm.ph.getSearchGroups(
                data,
                '''<script[^>]+?src=['"]([^'^"]*?/scripts\.js[^'^"]*?)['"]'''
            )[0]
            if scriptUrl == '':
                return []
            sts, data = self.getPage(self.getFullUrl(scriptUrl))
            if not sts:
                return []
            jscode = [
                'var iptvObj={%s};' %
                self.cm.ph.getDataBeetwenMarkers(data, 'boo:', '},')[1]
            ]
            jscode.append('var iptvArg="%s";')
            jscode.append('print(iptvObj["boo"](iptvArg));')
            self.jscode = jscode

        playbackUrl = cItem['url']
        rel = cItem['rel']
        id = cItem['id']
        cookieVal = self.cm.getCookieItem(self.COOKIE_FILE, 'SessionId')

        jscode = list(self.jscode)
        jscode[1] = jscode[1] % (id[5:] + cookieVal[8:])
        jscode = '\n'.join(jscode)
        ret = js_execute(jscode)
        if ret['sts'] and 0 == ret['code']:
            url = playbackUrl + '/' + ret['data'].strip() + "/" + rel
            return [{
                'name':
                'direct',
                'url':
                strwithmeta(
                    url, {
                        'User-Agent': self.USER_AGENT,
                        'Referer': self.getMainUrl(),
                        'Cookie': 'SessionId=%s;' % cookieVal
                    }),
                'need_resolve':
                0
            }]
        return []
Пример #18
0
    def _getAesPassword(self, cItem, forceRefresh=False):
        if Sport365LiveApi.CACHE_AES_PASSWORD != '' and not forceRefresh:
            return Sport365LiveApi.CACHE_AES_PASSWORD

        sts, data = self.getPage(
            self.getFullUrl('en/home/' + cItem['event_id']), self.http_params)
        if not sts:
            return []

        jsData = ''
        tmp = self.cm.ph.getAllItemsBeetwenMarkers(data, '<script',
                                                   '</script>')
        for item in tmp:
            if 'Contact' in item:
                item = self.cm.ph.getDataBeetwenReMarkers(
                    item, re.compile('<script[^>]+?>'),
                    re.compile('</script>'), False)[1]
                if 'Contact' in item:
                    jsData = 'try{ %s; } catch(e){ ; }\n' % (item)
                    break

        jsData2 = ''
        aes = ''
        data = re.compile(
            '''src=['"](http[^"^']*?/js/[0-9a-fA-F]{32}\.js[^'^"]*?)["']'''
        ).findall(data)[::-1]
        for commonUrl in data:
            sts, tmpData = self.getPage(commonUrl, self.http_params)
            if not sts:
                continue
            if tmpData.startswith(';eval('):
                try:
                    jscode = base64.b64decode(
                        '''dmFyIGRvY3VtZW50ID0ge307DQp2YXIgd2luZG93ID0gdGhpczsNCmRvY3VtZW50LndyaXRlID0gZnVuY3Rpb24oKXt9Ow0Kd2luZG93LmF0b2IgPSBmdW5jdGlvbigpe3JldHVybiAiIjt9Ow0KDQpmdW5jdGlvbiBkZWNyeXB0KCl7DQogICAgdmFyIHRleHQgPSBKU09OLnN0cmluZ2lmeSh7YWVzOmFyZ3VtZW50c1sxXX0pOw0KICAgIHByaW50KHRleHQpOw0KICAgIHJldHVybiAiIjsNCn0NCg0KdmFyIENyeXB0b0pTID0ge307DQpDcnlwdG9KUy5BRVMgPSB7fTsNCkNyeXB0b0pTLkFFUy5kZWNyeXB0ID0gZGVjcnlwdDsNCkNyeXB0b0pTLmVuYyA9IHt9Ow0KQ3J5cHRvSlMuZW5jLlV0ZjggPSAidXRmLTgiOw0K'''
                    )
                    jscode = '%s %s %s' % (jscode, tmpData, jsData)
                    ret = js_execute(jscode)
                    if ret['sts'] and 0 == ret['code']:
                        decoded = ret['data'].strip()
                        aes = json_loads(decoded)['aes']
                except Exception:
                    printExc()
                if aes != '':
                    break

        if aes != '':
            Sport365LiveApi.CACHE_AES_PASSWORD = aes
        return aes
Пример #19
0
 def uncensored(self, data):
     cookieItems = {}
     try:
         jscode = base64.b64decode('''dmFyIGRvY3VtZW50ID0ge307DQp2YXIgd2luZG93ID0gdGhpczsNCnZhciBsb2NhdGlvbiA9ICJodHRwczovLzlhbmltZS50by8iOw0KU3RyaW5nLnByb3RvdHlwZS5pdGFsaWNzPWZ1bmN0aW9uKCl7cmV0dXJuICI8aT48L2k+Ijt9Ow0KU3RyaW5nLnByb3RvdHlwZS5saW5rPWZ1bmN0aW9uKCl7cmV0dXJuICI8YSBocmVmPVwidW5kZWZpbmVkXCI+PC9hPiI7fTsNClN0cmluZy5wcm90b3R5cGUuZm9udGNvbG9yPWZ1bmN0aW9uKCl7cmV0dXJuICI8Zm9udCBjb2xvcj1cInVuZGVmaW5lZFwiPjwvZm9udD4iO307DQpBcnJheS5wcm90b3R5cGUuZmluZD0iZnVuY3Rpb24gZmluZCgpIHsgW25hdGl2ZSBjb2RlXSB9IjsNCkFycmF5LnByb3RvdHlwZS5maWxsPSJmdW5jdGlvbiBmaWxsKCkgeyBbbmF0aXZlIGNvZGVdIH0iOw0KZnVuY3Rpb24gZmlsdGVyKCkNCnsNCiAgICBmdW4gPSBhcmd1bWVudHNbMF07DQogICAgdmFyIGxlbiA9IHRoaXMubGVuZ3RoOw0KICAgIGlmICh0eXBlb2YgZnVuICE9ICJmdW5jdGlvbiIpDQogICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IoKTsNCiAgICB2YXIgcmVzID0gbmV3IEFycmF5KCk7DQogICAgdmFyIHRoaXNwID0gYXJndW1lbnRzWzFdOw0KICAgIGZvciAodmFyIGkgPSAwOyBpIDwgbGVuOyBpKyspDQogICAgew0KICAgICAgICBpZiAoaSBpbiB0aGlzKQ0KICAgICAgICB7DQogICAgICAgICAgICB2YXIgdmFsID0gdGhpc1tpXTsNCiAgICAgICAgICAgIGlmIChmdW4uY2FsbCh0aGlzcCwgdmFsLCBpLCB0aGlzKSkNCiAgICAgICAgICAgICAgICByZXMucHVzaCh2YWwpOw0KICAgICAgICB9DQogICAgfQ0KICAgIHJldHVybiByZXM7DQp9Ow0KT2JqZWN0LmRlZmluZVByb3BlcnR5KGRvY3VtZW50LCAiY29va2llIiwgew0KICAgIGdldCA6IGZ1bmN0aW9uICgpIHsNCiAgICAgICAgcmV0dXJuIHRoaXMuX2Nvb2tpZTsNCiAgICB9LA0KICAgIHNldCA6IGZ1bmN0aW9uICh2YWwpIHsNCiAgICAgICAgcHJpbnQodmFsKTsNCiAgICAgICAgdGhpcy5fY29va2llID0gdmFsOw0KICAgIH0NCn0pOw0KQXJyYXkucHJvdG90eXBlLmZpbHRlciA9IGZpbHRlcjsNCiVzDQoNCg==''') % (data)                     
         ret = js_execute( jscode )
         if ret['sts'] and 0 == ret['code']:
             printDBG(ret['data'])
             data = ret['data'].split('\n')
             for line in data:
                 line = line.strip()
                 if not line.endswith('=/'): continue
                 line = line.split(';')[0]
                 line = line.replace(' ', '').split('=')
                 if 2 != len(line): continue
                 cookieItems[line[0]] = line[1].split(';')[0]
     except Exception:
         printExc()
     return cookieItems
Пример #20
0
    def getVideoLink(self, cItem):
        printDBG("BeinmatchApi.getVideoLink")
        urlsTab = []

        jscode = [
            'window={open:function(){print(JSON.stringify(arguments));}};',
            self.getLinkJS, cItem['url']
        ]
        ret = js_execute('\n'.join(jscode))
        try:
            data = json_loads(ret['data'])
            url = self.getFullUrl(data['0'])
        except Exception:
            printExc()
            return urlsTab

        sts, data = self.getPage(url, self.http_params)
        if not sts:
            return urlsTab
        cUrl = self.cm.meta['url']
        printDBG(data)
        url = self.getFullUrl(
            ph.search(data, '''['"]([^'^"]+?\.m3u8(?:\?[^'^"]*?)?)['"]''')[0],
            cUrl)
        if url:
            url = strwithmeta(
                url, {
                    'Referer': cUrl,
                    'Origin': self.cm.getBaseUrl(cUrl)[:-1],
                    'User-Agent': self.HTTP_HEADER['User-Agent']
                })
            return getDirectM3U8Playlist(url,
                                         checkContent=True,
                                         sortWithMaxBitrate=999999999)
        data = ph.find(data, ('<div', '>', 'video-container'),
                       '</div>',
                       flags=0)[1]
        url = self.getFullUrl(ph.search(data, ph.IFRAME)[1])
        if 0 == self.up.checkHostSupport(url):
            sts, data = self.getPage(url, self.http_params)
            if not sts:
                return urlsTab
            url = self.getFullUrl(ph.search(data, ph.IFRAME)[1])
        return self.up.getVideoLinkExt(url)
Пример #21
0
    def _fillOneConfig(self, cItem, data=None):
        if data == None:
            sts, data = self.getPage(cItem['url'])
            if not sts:
                return

        jscode = []
        data = self.cm.ph.getAllItemsBeetwenNodes(data, ('<script', '>'), ('</script', '>'), False)
        for item in data:
            if '_oneconfig' in item:
                jscode.append(item)
                break
        jscode.append('print(JSON.stringify(_oneconfig));')
        ret = js_execute('\n'.join(jscode))
        if ret['sts'] and 0 == ret['code']:
            try:
                self.oneconfig.update(json_loads(ret['data'].strip(), '', True))
            except Exception:
                printExc()
Пример #22
0
    def listSearchResult(self, cItem, searchPattern, searchType):
        printDBG(
            "SeriesOnlineIO.listSearchResult cItem[%s], searchPattern[%s] searchType[%s]"
            % (cItem, searchPattern, searchType))
        if self.MAIN_URL == None:
            self.selectDomain()

        url = self.SEARCH_URL + '/' + urllib.quote_plus(searchPattern).replace(
            '+', '-')
        sts, data = self.getPage(url)
        if not sts:
            return
        cUrl = self.cm.meta['url']
        tmp = ''
        data = self.cm.ph.getAllItemsBeetwenMarkers(data, '<script>',
                                                    '</script>', False)
        for item in data:
            if '$.ajax(' in item:
                tmp = item
                break
        if tmp == '':
            return
        ret = js_execute(
            '$={}; $.ajax=function(setup){print(JSON.stringify(setup));}\n' +
            tmp)
        if ret['sts'] and 0 == ret['code']:
            decoded = ret['data'].strip()
            printDBG('DECODED DATA -> \n[%s]\n' % decoded)
            try:
                decoded = byteify(json.loads(decoded))
                searchUrl = self.getFullUrl(decoded.get('url', cUrl))
                if '?' not in searchUrl:
                    searchUrl += '?'
                if 'data' in decoded:
                    searchUrl += urllib.urlencode(decoded['data'])
                printDBG('searchUrl [%s]\n' % searchUrl)
                cItem = dict(cItem)
                cItem['url'] = searchUrl
                self.listItems(cItem, 'list_episodes')
            except Exception:
                printExc()
Пример #23
0
    def getVideoLinks(self, videoUrl):
        printDBG("EFilmyTv.getVideoLinks [%s]" % videoUrl)
        self.tryTologin()

        videoUrl = strwithmeta(videoUrl)
        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

        paramsUrl = dict(self.defaultParams)
        paramsUrl['header'] = dict(paramsUrl['header'])
        paramsUrl['header']['Referer'] = videoUrl.meta.get(
            'Referer', self.getMainUrl())
        sts, data = self.getPage(videoUrl, paramsUrl)
        if not sts:
            return urlTab
        cUrl = data.meta['url']

        ##############################################################################################
        while sts and 'generate_captcha' in data:
            captchaTitle = self.cm.ph.getAllItemsBeetwenMarkers(
                data, '<p', '</p>')

            if len(captchaTitle):
                captchaTitle = self.cleanHtmlStr(captchaTitle[-1])

            # parse form data
            data = self.cm.ph.getDataBeetwenMarkers(data, '<form',
                                                    '</form>')[1]
            imgUrl = self.getFullUrl(
                '/mirrory.php?cmd=generate_captcha&time=%s' % time.time(),
                cUrl)
            actionUrl = self.getFullUrl(
                self.cm.ph.getSearchGroups(data, 'action="([^"]+?)"')[0], cUrl)
            tmp = re.compile('''<input[^>]+?>''').findall(data)
            printDBG(tmp)
            captcha_post_data = {}
            for it in tmp:
                val = self.cm.ph.getSearchGroups(
                    it, '''\svalue=['"]?([^'^"^\s]+?)['"\s]''')[0].strip()
                name = self.cm.ph.getSearchGroups(
                    it, '''\sname=['"]([^'^"]+?)['"]''')[0]
                captcha_post_data[name] = val

            header = dict(self.HTTP_HEADER)
            header['Accept'] = 'image/png,image/*;q=0.8,*/*;q=0.5'
            params = dict(self.defaultParams)
            params.update({
                'maintype':
                'image',
                'subtypes': ['jpeg', 'png'],
                'check_first_bytes':
                ['\xFF\xD8', '\xFF\xD9', '\x89\x50\x4E\x47'],
                'header':
                header
            })
            filePath = GetTmpDir('.iptvplayer_captcha.jpg')
            rm(filePath)
            ret = self.cm.saveWebFile(filePath, imgUrl.replace('&amp;', '&'),
                                      params)
            if not ret.get('sts'):
                SetIPTVPlayerLastHostError(_('Fail to get "%s".') % imgUrl)
                return urlTab
            params = deepcopy(IPTVMultipleInputBox.DEF_PARAMS)
            params['accep_label'] = _('Send')
            params['title'] = _('Captcha')
            params['status_text'] = captchaTitle
            params['with_accept_button'] = True
            params['list'] = []
            item = deepcopy(IPTVMultipleInputBox.DEF_INPUT_PARAMS)
            item['label_size'] = (160, 75)
            item['input_size'] = (480, 25)
            item['icon_path'] = filePath
            item['title'] = _('Answer')
            item['input']['text'] = ''
            params['list'].append(item)

            ret = 0
            retArg = self.sessionEx.waitForFinishOpen(IPTVMultipleInputBox,
                                                      params)
            printDBG(retArg)
            if retArg and len(retArg) and retArg[0]:
                printDBG(retArg[0])
                captcha_post_data['captcha'] = retArg[0][0]
                paramsUrl['header']['Referer'] = cUrl
                sts, data = self.cm.getPage(actionUrl, paramsUrl,
                                            captcha_post_data)
                if sts:
                    cUrl = data.meta['url']
                else:
                    return urlTab
            else:
                return urlTab
        ##############################################################################################

        jscode = []
        tmp = self.cm.ph.getAllItemsBeetwenNodes(data, ('<script', '>'),
                                                 ('</script', '>'), False)
        for item in tmp:
            if 'eval(' in item:
                jscode.append(item)

        if len(jscode) > 0:
            jscode.insert(
                0,
                'var document={write:function(e){print(e)}};Base64={},Base64.decode=function(e){e.length%4==3&&(e+="="),e.length%4==2&&(e+="=="),e=Duktape.dec("base64",e),decText="";for(var t=0;t<e.byteLength;t++)decText+=String.fromCharCode(e[t]);return decText};'
            )
            ret = js_execute('\n'.join(jscode))
            if ret['sts'] and 0 == ret['code']:
                data = ret['data'].strip()
        if 'premium' in videoUrl.meta['f_type']:
            printDBG(data)
            errorMessage = self.cleanHtmlStr(
                self.cm.ph.getDataBeetwenNodes(data, ('<div', '>', 'toomany'),
                                               ('</div', '>'))[1].replace(
                                                   '<br>', '\n'))
            SetIPTVPlayerLastHostError(errorMessage)
            data = self.cm.ph.getDataBeetwenMarkers(data, 'clip:', '}')[1]
            videoUrl = self.cm.ph.getSearchGroups(
                data, '''\surl\s*?:\s*?['"](https?://[^'^"]+?)['"]''', 1,
                True)[0]
            if videoUrl != '':
                urlTab.append({
                    'name': 'direct_link',
                    'url': strwithmeta(videoUrl, {'Referer': cUrl})
                })
        else:
            videoUrl = self.getFullUrl(
                self.cm.ph.getSearchGroups(data, '''href=['"]([^'^"]+?)['"]''',
                                           1, True)[0], cUrl)
            if 'clipwatching' in videoUrl:
                videoUrl = self.getFullUrl(
                    self.cm.ph.getSearchGroups(
                        data, '''<iframe[^>]+?src=['"]([^"^']+?)['"]''', 1,
                        True)[0], cUrl)
            urlTab = self.up.getVideoLinkExt(
                strwithmeta(videoUrl, {'Referer': cUrl}))

        return urlTab
Пример #24
0
    def getLinksForVideo(self, cItem):
        printDBG("NuteczkiEU.getLinksForVideo [%s]" % cItem)
        self.tryTologin()

        urlTab = []

        sts, data = self.getPage(cItem['url'])
        if not sts: return []
        self.setMainUrl(self.cm.meta['url'])

        tmp = self.cm.ph.getAllItemsBeetwenNodes(data,
                                                 ('<div', '>', 'frame-fixer'),
                                                 ('</div', '>'),
                                                 caseSensitive=False)
        for idx in range(len(tmp)):
            url = self.getFullUrl(
                self.cm.ph.getSearchGroups(
                    tmp[idx], '''\sdata\-url=['"]([^"^']+?)['"]''', 1,
                    True)[0])
            if 1 != self.up.checkHostSupport(url):
                jscode = []
                jsData = self.cm.ph.getAllItemsBeetwenNodes(
                    tmp[idx], ('<script', '>'), ('</script', '>'),
                    caseSensitive=False)
                for jsItem in jsData:
                    if 'src=' in jsItem.lower():
                        scriptUrl = self.getFullUrl(
                            self.cm.ph.getSearchGroups(
                                jsItem,
                                '''<script[^>]+?src=['"]([^'^"]*?krakenfiles[^'^"]+?)['"]''',
                                1, True)[0], self.cm.meta['url'])
                        sts, jsItem = self.getPage(scriptUrl)
                        if sts and jsItem != '': jscode.append(jsItem)
                    else:
                        sts, jsItem = self.cm.ph.getDataBeetwenNodes(
                            jsItem, ('<script', '>'), ('</script', '>'),
                            False,
                            caseSensitive=False)
                        if sts: jscode.append(jsItem)
                if len(jscode):
                    jscode.insert(
                        0,
                        'window={}; window.location={}; window.location.protocol="%s"; var document={}; document.write=function(txt){print(txt);}'
                        % self.getMainUrl().split('//', 1)[0])
                    ret = js_execute('\n'.join(jscode), {'timeout_sec': 15})
                    if ret['sts'] and 0 == ret['code']:
                        printDBG(ret['data'])
                        data += ret['data'].strip()

            elif 'facebook' not in url.lower():
                name = _('Player %s: %s') % (idx + 1, self.up.getHostName(url))
                urlTab.append({'url': url, 'name': name, 'need_resolve': 1})

        tmp = self.cm.ph.getAllItemsBeetwenMarkers(data,
                                                   '<iframe',
                                                   '</iframe>',
                                                   caseSensitive=False)
        for idx in range(len(tmp)):
            url = self.getFullUrl(
                self.cm.ph.getSearchGroups(tmp[idx],
                                           '''\ssrc=['"]([^"^']+?)['"]''', 1,
                                           True)[0])
            if url == '' or 'facebook' in url.lower(): continue
            name = _('Player %s') % (idx + 1)
            urlTab.append({'url': url, 'name': name, 'need_resolve': 1})

        return urlTab
Пример #25
0
    def getLinksForVideo(self, cItem):
        printDBG("ArconaitvME.getLinksForVideo [%s]" % cItem)
        urlsTab = []
        sts, data = self.getPage(cItem['url'])
        if not sts:
            return urlsTab

        playerUrl = self.cm.ph.getSearchGroups(
            data,
            '''<source[^>]*?src=['"](https?:[^"^']+?\.m3u8[^"^']*?)['"]''',
            1,
            ignoreCase=True)[0]
        try:
            playerUrl = byteify(json.loads('"%s"' % playerUrl))
        except Exception:
            printExc()
        if not self.cm.isValidUrl(playerUrl):
            playerUrl = self.cm.ph.getSearchGroups(
                data,
                '''"sources"\s*:\s*[^\]]*?"src"\s*:\s*"(https?:[^"]+?\.m3u8[^"]*?)"''',
                1,
                ignoreCase=True)[0]
        try:
            playerUrl = byteify(json.loads('"%s"' % playerUrl))
        except Exception:
            printExc()
        if not self.cm.isValidUrl(playerUrl):
            playerUrl = self.cm.ph.getSearchGroups(
                data, '''"(https?:[^"]+?\.m3u8[^"]*?)"''', 1,
                ignoreCase=True)[0]
        try:
            playerUrl = byteify(json.loads('"%s"' % playerUrl))
        except Exception:
            printExc()

        if not self.cm.isValidUrl(playerUrl):
            scripts = []
            tmp = self.cm.ph.getAllItemsBeetwenNodes(data, ('<script', '>'),
                                                     ('</script', '>'), False)
            for item in tmp:
                if 'eval(' not in item and '゚ω゚ノ=' not in item:
                    continue
                scripts.append(item.strip())
            try:
                jscode = base64.b64decode(
                    '''dmFyIGRvY3VtZW50PXt9LHdpbmRvdz10aGlzLGVsZW1lbnQ9ZnVuY3Rpb24oZSl7dGhpcy5fbmFtZT1lLHRoaXMuc2V0QXR0cmlidXRlPWZ1bmN0aW9uKGUsdCl7InNyYyI9PWUmJih0aGlzLnNyYz10KX0sT2JqZWN0LmRlZmluZVByb3BlcnR5KHRoaXMsInNyYyIse2dldDpmdW5jdGlvbigpe3JldHVybiB0aGlzLl9zcmN9LHNldDpmdW5jdGlvbihlKXt0aGlzLl9zcmM9ZSxwcmludChlKX19KX0sJD1mdW5jdGlvbihlKXtyZXR1cm4gbmV3IGVsZW1lbnQoZSl9O2RvY3VtZW50LmdldEVsZW1lbnRCeUlkPWZ1bmN0aW9uKGUpe3JldHVybiBuZXcgZWxlbWVudChlKX0sZG9jdW1lbnQuZ2V0RWxlbWVudHNCeVRhZ05hbWU9ZnVuY3Rpb24oZSl7cmV0dXJuW25ldyBlbGVtZW50KGUpXX07'''
                )
                ret = js_execute(
                    jscode +
                    '\nvar videojs={Hls:{xhr:{}}};function eval(data){print(data);}\n'
                    + '\n'.join(scripts))
                decoded = self.cm.ph.getSearchGroups(
                    ret['data'],
                    '''['"]([^'^"]+?\.m3u8(?:\?[^'^"]*?)?)['"]''')[0].replace(
                        '\\/', '/')
                decoded = self.cm.getFullUrl(decoded, self.cm.meta['url'])
                if decoded.split('?', 1)[0].endswith('.m3u8'):
                    playerUrl = decoded
            except Exception:
                printExc()
        playerUrl = strwithmeta(
            playerUrl, {
                'User-Agent': self.HEADER['User-Agent'],
                'Referer': cItem['url'],
                'Origin': self.getMainUrl()
            })

        if self.cm.isValidUrl(playerUrl):
            tmp = getDirectM3U8Playlist(playerUrl, checkContent=True)
            for item in tmp:
                item['need_resolve'] = 0
                urlsTab.append(item)
        return urlsTab
Пример #26
0
 def listSeasons(self, cItem, nextCategory):
     printDBG("SerialeCO.listSeasons [%s]" % cItem)
     
     self.playerData = {}
     
     sts, data = self.getPage(cItem['url'])
     if not sts: return
     cUrl = data.meta['url']
     
     data = self.cm.ph.getDataBeetwenNodes(data, ('<script', '>', 'player.js'), ('<header', '>'))[1]
     playerUrl = self.getFullUrl(self.cm.ph.getSearchGroups(data, '''src=['"]([^'^"]+?)['"]''')[0])
     
     data = self.cm.ph.getAllItemsBeetwenMarkers(data, '<input', '>')
     self.playerData = {}
     for item in data:
         id  = self.cm.ph.getSearchGroups(item, '''id=['"]([^'^"]+?)['"]''')[0]
         val = self.cm.ph.getSearchGroups(item, '''value=['"]([^'^"]+?)['"]''')[0]
         self.playerData[id] = val
     
     sts, data = self.getPage(playerUrl)
     if not sts: return
     
     # function pobierz_info_o_odcinkach
     ajaxInfoData = self.cm.ph.getDataBeetwenMarkers(data, 'function pobierz_info_o_odcinkach', '});')[1]
     ajaxInfoVarName = self.cm.ph.getSearchGroups(ajaxInfoData, '''var\s+?([A-Za-z0-9]+?)\s*?=''')[0]
     ajaxInfoData = self.cm.ph.getDataBeetwenMarkers(ajaxInfoData, '$.ajax(', ').', False)[1]
     printDBG('ajaxInfoData: [%s]' % ajaxInfoData)
     printDBG('ajaxInfoVarName: [%s]' % ajaxInfoVarName)
     
     playerUrl = self.cm.ph.getDataBeetwenMarkers(data, 'function seriale_search', 'function')[1]
     playerUrl = self.cm.ph.getSearchGroups(playerUrl, '''['"]?url['"]?\s*:\s*['"](http[^'^"]+?)['"]''')[0]
     if not self.cm.isValidUrl(playerUrl):
         printDBG("No valid playerUrl")
         return
         
     self.playerData['player_url'] = playerUrl
         
     seasonUrl = self.cm.ph.getDataBeetwenMarkers(data, 'function pokaz_odcinki', 'function')[1]
     seasonUrl = self.cm.ph.getSearchGroups(seasonUrl, '''['"]?url['"]?\s*:\s*['"](http[^'^"]+?)['"]''')[0]
     if not self.cm.isValidUrl(seasonUrl):
         printDBG("No valid playerUrl")
         return
     
     httpParams = dict(self.defaultParams)
     httpParams['header'] = dict(httpParams['header'])
     httpParams['header']['Referer'] = cItem['url']
     httpParams['header']['Origin']  = self.getMainUrl()[:-1]
     
     sts, seasons = self.getPage(seasonUrl, httpParams, {'nazwa':self.playerData.get('fid', '')})
     if sts:
         printDBG(">>>>>>>\n%s\n>>>>>>>" % seasons)
         self.playerData['odc'] = seasons
     
     seasons = self.playerData.get('odc', '').split(',')
     for idx in range(len(seasons)):
         if seasons[idx] == '' : continue
         sNum = str(idx + 1)
         params = dict(cItem)
         params.update({'good_for_fav':False, 'category':nextCategory, 'title': _('Season %s') % sNum.zfill(2), 's_title':cItem['title'], 's_num':sNum, 'e_count':seasons[idx]})
         self.addDir(params)
     
     if 0 == len(self.currList) and ajaxInfoVarName != '' and ajaxInfoData != '':
         ret = js_execute( '{0}="{1}";\n'.format(ajaxInfoVarName, self.playerData.get(ajaxInfoVarName, '')) + 'print(JSON.stringify({0}));\n'.format(ajaxInfoData) )
         if ret['sts'] and 0 == ret['code']:
             data = ret['data'].strip()
             printDBG('DECODED DATA -> \n[%s]\n' % data)
             try:
                 data = byteify(json.loads(data))
                 searchUrl = self.getFullUrl(data['url'], cUrl)
                 post_data = data['data']
                 
                 sts, data = self.getPage(searchUrl, httpParams, post_data)
                 if not sts: return
                 
                 printDBG('DATA -> \n[%s]\n' % data)
                 
                 data = byteify(json.loads(data))
                 for sKey in data:
                     sNum = sKey.strip()
                     eItems = []
                     for eKey in data[sKey]:
                         eNum = eKey.strip()
                         title = _('%s s%se%s') % (cItem['title'], sNum.zfill(2), eNum.zfill(2))
                         if data[sKey][eKey].get('title', '') != '':
                             title += ' ' + data[sKey][eKey]['title']
                         desc = data[sKey][eKey].get('data', '')
                         params = {'good_for_fav':False,  'title': title, 'desc':desc, 's_num':sNum, 'e_num':eNum}
                         eItems.append(params)
                     if len(eItems):
                         params = dict(cItem)
                         params.update({'good_for_fav':False, 'category':nextCategory, 'title': _('Season %s') % sNum.zfill(2), 's_title':cItem['title'], 's_num':sNum, 'e_items':eItems})
                         self.addDir(params)
             except Exception:
                 printExc()
         
     if len(self.currList) == 1:
         cItem = self.currList[0]
         self.currList = []
         self.listEpisodes(cItem)
Пример #27
0
    def exploreItem(self, cItem, nextCategory):
        printDBG("Cinemaxx.exploreItem")
        self.cacheLinks = {}

        sts, data = self.getPage(cItem['url'])
        if not sts: return
        cUrl = self.cm.meta['url']
        self.setMainUrl(cUrl)

        desc = []
        descObj = self.getArticleContent(cItem, data)[0]
        icon = descObj['images'][0]['url']
        baseTitle = descObj['title']
        for item in descObj['other_info']['custom_items_list']:
            desc.append(item[1])
        desc = ' | '.join(desc) + '[/br]' + descObj['text']

        data = ph.find(data, ('<div', '>', 'dle-content'),
                       ('<div', '>', 'fstory-info'),
                       flags=0)[1]
        trailer = ph.find(data, ('<', '>', '#trailer'), '</div>', flags=0)[1]
        title = self.cleanHtmlStr(trailer)
        trailer = self.getFullUrl(ph.search(trailer, ph.IFRAME_SRC_URI_RE)[1])
        if trailer:
            self.addVideo({
                'good_for_fav': True,
                'prev_url': cUrl,
                'title': '%s %s' % (title, baseTitle),
                'url': trailer,
                'icon': icon,
                'desc': desc
            })

        data = ph.find(data, ('<div', '>', 'full-video'), '</div>', flags=0)[1]
        url = self.getFullUrl(ph.search(data, ph.IFRAME_SRC_URI_RE)[1])
        if url:
            if ('/video/' in url and '/serials/' in url) or 'playlist' in url:
                url = strwithmeta(url, {'Referer': cUrl})
                seasons = self.hdgocc.getSeasonsList(url)
                for item in seasons:
                    self.addDir(
                        MergeDicts(
                            cItem, {
                                'good_for_fav': False,
                                'prev_url': cUrl,
                                'category': nextCategory,
                                'serie_title': baseTitle,
                                'title': 'Staffel %s' % item['title'],
                                'season_id': item['id'],
                                'url': item['url'],
                                'icon': icon,
                                'desc': desc
                            }))

                if 0 != len(seasons):
                    return

                seasonUrl = url
                episodes = self.hdgocc.getEpiodesList(seasonUrl, -1)
                for item in episodes:
                    title = '{0} - {1} - s01e{2} '.format(
                        baseTitle, item['title'],
                        str(item['id']).zfill(2))
                    self.addVideo({
                        'good_for_fav': False,
                        'type': 'video',
                        'prev_url': cUrl,
                        'title': title,
                        'url': item['url'],
                        'icon': icon,
                        'desc': desc
                    })

                if 0 != len(episodes):
                    return

            self.addVideo({
                'good_for_fav': False,
                'prev_url': cUrl,
                'title': baseTitle,
                'url': url,
                'icon': icon,
                'desc': desc
            })
        else:
            data = ph.find(data, 'vk.show(', ');', flags=0)[1].split(',',
                                                                     1)[-1]
            ret = js_execute('print(JSON.stringify(%s));' % data)
            if ret['sts'] and 0 == ret['code']:
                try:
                    data = json_loads(ret['data'])
                    for sNum, season in enumerate(data, 1):
                        subItems = []
                        for eNum, episode in enumerate(season, 1):
                            title = baseTitle + ' s%se%s' % (
                                str(sNum).zfill(2), str(eNum).zfill(2))
                            subItems.append({
                                'good_for_fav': False,
                                'type': 'video',
                                'prev_url': cUrl,
                                'title': title,
                                'url': episode,
                                'icon': icon,
                                'desc': desc
                            })
                        if subItems:
                            self.addDir(
                                MergeDicts(
                                    cItem, {
                                        'good_for_fav':
                                        False,
                                        'prev_url':
                                        cUrl,
                                        'title':
                                        'Staffel %s' % (str(sNum).zfill(2)),
                                        'category':
                                        'sub_items',
                                        'sub_items':
                                        subItems
                                    }))
                except Exception:
                    printExc()
Пример #28
0
    def exploreItem(self, cItem):
        printDBG("DDLMe.exploreItem")
        self.cacheLinks = {}

        sts, data = self.getPage(cItem['url'])
        if not sts: return
        cUrl = self.getFullUrl(self.cm.meta['url'])

        #printDBG(data)

        desc = self.cleanHtmlStr(
            self.cm.ph.getDataBeetwenNodes(data, ('<p', '>', 'detailDesc'),
                                           ('</p', '>'), False)[1])

        trailer = self.cm.ph.getSearchGroups(
            data.rsplit('</ul>', 1)[0], '''<([^>]+?trailerbtn[^>]+?)>''')[0]
        url = self.getFullUrl(
            self.cm.ph.getSearchGroups(trailer, '''rel=['"]([^"^']+?)["']''',
                                       1, True)[0], cUrl)
        if url != '':
            self.cacheLinks[url] = [{
                'name': 'trailer',
                'url': strwithmeta(url, {'Referer': cUrl}),
                'need_resolve': 1
            }]
            params = dict(cItem)
            params.update({
                'good_for_fav': False,
                'title': cItem['title'] + ' - ' + _('trailer'),
                'url': url,
                'desc': desc,
                'prev_url': cUrl
            })
            self.addVideo(params)

        tmp = ''
        data = self.cm.ph.getAllItemsBeetwenNodes(data, ('<script', '>'),
                                                  ('</script', '>'), False)
        for item in data:
            if 'subcats' in item:
                tmp = item
                break
        try:
            seasons = []
            episodes = {}

            playableItems = []

            jscode = tmp + '\n' + 'print(JSON.stringify(subcats));'
            ret = js_execute(jscode)
            if ret['sts'] and 0 == ret['code']:
                data = ret['data'].strip()
                data = byteify(json.loads(data))

                for key, dat in data.iteritems():
                    for name, item in dat['links'].iteritems():
                        for linkData in item:
                            pNum = int(linkData[0])
                            url = self.getFullUrl(linkData[3], cUrl)
                            if -1 == self.up.checkHostSupport(url):
                                continue

                            if 'info' in dat:
                                parts = 0
                                sNum = int(dat['info']['staffel'])
                                eNum = int(dat['info']['nr'])
                                #eId =  int(dat['info']['sid'])
                                #urlKey = '%s_%s_%s' % (str(sNum).zfill(4), str(eNum).zfill(4), str(pNum).zfill(4))
                                title = '%s: %sx%s %s' % (
                                    cItem['title'], str(sNum).zfill(2),
                                    str(eNum).zfill(2),
                                    self.cleanHtmlStr(dat['info']['name']))
                            else:
                                parts = int(dat['1'])
                                sNum = 0
                                eNum = 0
                                #urlKey = str(pNum).zfill(4)
                                title = cItem['title']

                            urlKey = '%s_%s_%s' % (str(sNum).zfill(4),
                                                   str(eNum).zfill(4),
                                                   str(pNum).zfill(4))

                            if pNum > 1 or parts > 1:
                                title += ' (Part %s)' % pNum

                            if sNum not in seasons:
                                seasons.append(sNum)
                                episodes[sNum] = []

                            if eNum not in episodes[sNum]:
                                episodes[sNum].append(eNum)

                            if urlKey not in self.cacheLinks:
                                self.cacheLinks[urlKey] = []
                                playableItems.append({
                                    'title': title,
                                    'url': urlKey,
                                    's_num': sNum,
                                    'e_num': eNum,
                                    'prev_url': cUrl
                                })

                            self.cacheLinks[urlKey].append({
                                'name': name,
                                'url': url,
                                'need_resolve': 1
                            })

                tmpList = []
                seasons.sort()
                for sNum in seasons:
                    subItems = []
                    episodes[sNum].sort()
                    for eNum in episodes[sNum]:
                        for item in playableItems:
                            if item['s_num'] == sNum and item['e_num'] == eNum:
                                subItems.append(
                                    MergeDicts(cItem, item, {
                                        'good_for_fav': False,
                                        'type': 'video'
                                    }))
                    if len(subItems):
                        tmpList.append(
                            MergeDicts(
                                cItem, {
                                    'good_for_fav': False,
                                    'title': _('Season') + ' {0}'.format(sNum),
                                    'category': 'sub_items',
                                    'sub_items': subItems,
                                    'prev_url': cUrl
                                }))

            if len(tmpList) == 1:
                for item in tmpList[0]['sub_items']:
                    self.addVideo(item)
            else:
                self.currList.extend(tmpList)

            seasons.sort()
            printDBG('seasons: %s' % seasons)
            printDBG('episodes: %s' % episodes)
            printDBG('playableItems: %s' % playableItems)
            printDBG('cacheLinks: %s' % self.cacheLinks)
        except Exception:
            printExc()
Пример #29
0
    def getVideoLinks(self, videoUrl):
        printDBG("Altadefinizione.getVideoLinks [%s]" % videoUrl)
        videoUrl = strwithmeta(videoUrl)
        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

        urlParams = dict(self.defaultParams)
        urlParams['header'] = dict(urlParams['header'])
        urlParams['header']['Referer'] = str(
            videoUrl.meta.get('Referer', self.getMainUrl()))

        sts, data = self.getPage(videoUrl, urlParams)
        if not sts: return urlTab
        cUrl = data.meta['url']

        playerData = self.cm.ph.getDataBeetwenNodes(
            data, ('<input', '>', 'urlEmbed'), ('<iframe', '>'))[1]
        if playerData == '':
            printDBG('Missig player data')
            return urlTab
        playerData = self.cm.ph.getSearchGroups(
            playerData, '''value=['"]([^'^"]+?)['"]''')[0]
        printDBG('PLAYER_DATA: %s\n' % playerData)

        if self.cacheJSCode == '':
            jsUrl = ''
            data = re.compile('''<script[^>]+?src=['"]([^'^"]+?)['"]''',
                              re.I).findall(data)
            for item in data:
                if 'filmlive' not in item: continue
                jsUrl = self.cm.getFullUrl(item, self.cm.getBaseUrl(cUrl))
                break

            sts, data = self.getPage(jsUrl, urlParams)
            if not sts: return urlTab
            try:
                idxS = data.find('function clearify')
                num = 1
                idx = data.find('{', idxS)
                for idx in range(idx + 1, len(data), 1):
                    if data[idx] == '{': num += 1
                    if data[idx] == '}': num -= 1
                    if num == 0:
                        printDBG("JS_CODE_IDX: [%s:%s]" % (idxS, idx))
                        break

                jscode = data[idxS:idx + 1]
                printDBG('JS_CODE: %s\n' % jscode)
                self.cacheJSCode = jscode
            except Exception:
                printExc()

        jscode = [
            'var $={base64:function(not_used,e){e.length%4==3&&(e+="="),e.length%4==2&&(e+="=="),e=Duktape.dec("base64",e),decText="";for(var t=0;t<e.byteLength;t++)decText+=String.fromCharCode(e[t]);return decText},trim:function(e){return null==e?"":(e+"").replace(n,"")}};',
            self.cacheJSCode,
            'print(clearify("%s"))' % playerData
        ]
        ret = js_execute('\n'.join(jscode))
        if ret['sts'] and 0 == ret['code']:
            printDBG(ret['data'])
            urlTab = self.up.getVideoLinkExt(ret['data'])
        return urlTab
Пример #30
0
    def getVideoLinks(self, videoUrl):
        printDBG("FilmeOnlineTo.getVideoLinks [%s]" % videoUrl)
        urlTab = []
        subTracks = []

        # 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

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

        data = self.cm.ph.getDataBeetwenReMarkers(
            data, re.compile('var\s*?movie\s*?\=\s*?\{'), re.compile('}'))[1]
        ret = js_execute(data + '; print(JSON.stringify(movie));')
        try:
            movieData = byteify(json.loads(ret['data']), '', True)
            urlParams = dict(self.defaultParams)
            urlParams['header'] = dict(self.AJAX_HEADER)
            urlParams['header']['Referer'] = str(videoUrl)
            url = self.getFullUrl('/ajax/mep.php?id=%s' % movieData['id'])
            sts, data = self.getPage(url, urlParams)
            if not sts: return
            data = byteify(json.loads(data), '', True)

            params = dict(videoUrl.meta.get('params', {}))
            if params.get('tip', '') == 'embed':
                url = '/ajax/movie_embed.php?eid=%s&lid=undefined&ts=%s&up=0&mid=%s&gid=%s&epNr=%s&type=%s&server=%s&epIndex=%s&so=%s&srvr=%s' % (
                    params['id'], data.get('ts', ''), movieData['id'],
                    movieData['gid'], params['epNr'], movieData['type'],
                    params.get('server', 'NaN'), params['index'], params['so'],
                    params.get('srvr', 'NaN'))
                sts, data = self.getPage(self.getFullUrl(url), urlParams)
                if not sts: return
                data = byteify(json.loads(data), '', True)
                url = data['src'].replace('&amp;', '&')
                urlParams = {
                    'Referer': str(videoUrl),
                    'User-Agent': self.HEADER['User-Agent']
                }
                subsLinks = re.compile(
                    '''c([0-9]+?)_file=(https?://[^&^$]+?\.srt)[&$]'''
                ).findall(url)
                subsLabels = dict(
                    re.compile('''c([0-9]+?)_label=([^&^/]+?)[&/]''').findall(
                        url + '&'))
                for item in subsLinks:
                    label = subsLabels.get(item[0], 'unk')
                    subTracks.append({
                        'title': label,
                        'url': strwithmeta(item[1], urlParams),
                        'lang': label,
                        'format': 'srt'
                    })
                urlTab = self.up.getVideoLinkExt(url)
            elif params.get('tip', '') == 'vip':
                url = '/ajax/mtoken.php?eid=%s&mid=%s&so=%s&server=NaN&epNr=%s&srvr=NaN&_=%s' % (
                    params['id'], movieData['id'], params['so'],
                    params['epNr'], int(time.time() * 1000))
                sts, data = self.getPage(self.getFullUrl(url), urlParams)
                if not sts: return
                data = dict(
                    re.compile('''_([a-z]+?)\s*?=\s*['"]([^'^"]+?)['"]''').
                    findall(data))
                url = '/ajax/msources.php?eid=%s&x=%s&y=%s&z=%s&ip=%s&mid=%s&gid=%s&lang=rum&epIndex=%s&server=NaN&so=%s&epNr=%s&srvr=NaN' % (
                    params['id'], data['x'], data['y'], data['z'], data['ip'],
                    movieData['id'], movieData['gid'], params['index'],
                    params['so'], params['epNr'])
                sts, data = self.getPage(self.getFullUrl(url), urlParams)
                if not sts: return

                urlParams = {
                    'Referer': str(videoUrl),
                    'User-Agent': self.HEADER['User-Agent']
                }
                data = byteify(json.loads(data), '', True)
                url = self.getFullUrl(data['playlist'][0]['sources']['file'])
                if 'mp4' in data['playlist'][0]['sources']['type'].lower():
                    urlTab.append({
                        'name': 'mp4',
                        'url': strwithmeta(url, urlParams),
                        'need_resolve': 0
                    })
                for item in data['playlist'][0]['tracks']:
                    if item.get('kind', '').lower() != 'captions': continue
                    url = self.getFullUrl(item['file'])
                    label = self.cleanHtmlStr(item['label'])
                    subTracks.append({
                        'title': label,
                        'url': strwithmeta(url, urlParams),
                        'lang': label,
                        'format': 'srt'
                    })
                printDBG(data)
        except Exception:
            printExc()

        urlParams = {
            'Referer': str(videoUrl),
            'User-Agent': self.HEADER['User-Agent']
        }
        if len(subTracks):
            urlParams.update({'external_sub_tracks': subTracks})

        for idx in range(len(urlTab)):
            urlTab[idx]['url'] = strwithmeta(urlTab[idx]['url'], urlParams)

        return urlTab