def _encryptPlayerUrl(self, data):
     printDBG("_encryptPlayerUrl data[%s]" % data)
     decrypted = ''
     try:
         data = byteify( json.loads(data) )
         salt = a2b_hex(data["v"])
         key, iv = EVP_BytesToKey(md5, "s05z9Gpd=syG^7{", salt, 32, 16, 1)
         
         if iv != a2b_hex(data.get('b', '')):
             prinDBG("_encryptPlayerUrl IV mismatched")
         
         if 0:
             from Crypto.Cipher import AES
             aes = AES.new(key, AES.MODE_CBC, iv, segment_size=128)
             decrypted = aes.decrypt(a2b_base64(data["a"]))
             decrypted = decrypted[0:-ord(decrypted[-1])]
         else:
             kSize = len(key)
             alg = AES_CBC(key, keySize=kSize)
             decrypted = alg.decrypt(a2b_base64(data["a"]), iv=iv)
             decrypted = decrypted.split('\x00')[0]
         decrypted = "%s" % json.loads( decrypted ).encode('utf-8')
     except:
         printExc()
         decrypted = ''
     return decrypted
Exemplo n.º 2
0
    def _encryptPlayerUrl(self, data):
        printDBG("_encryptPlayerUrl data[%s]" % data)
        decrypted = ''
        try:
            salt = a2b_hex(data["v"])
            key, iv = EVP_BytesToKey(md5, "s05z9Gpd=syG^7{", salt, 32, 16, 1)

            if iv != a2b_hex(data.get('b', '')):
                prinDBG("_encryptPlayerUrl IV mismatched")

            if 0:
                from Crypto.Cipher import AES
                aes = AES.new(key, AES.MODE_CBC, iv, segment_size=128)
                decrypted = aes.decrypt(a2b_base64(data["a"]))
                decrypted = decrypted[0:-ord(decrypted[-1])]
            else:
                kSize = len(key)
                alg = AES_CBC(key, keySize=kSize)
                decrypted = alg.decrypt(a2b_base64(data["a"]), iv=iv)
                decrypted = decrypted.split('\x00')[0]
            decrypted = "%s" % json.loads(decrypted).encode('utf-8')
        except Exception:
            printExc()
            decrypted = ''
        return decrypted
Exemplo n.º 3
0
 def _decUrl(data, password):
     printDBG('PASSWORD 2: ' + sha256(password).hexdigest())
     key = a2b_hex( sha256(password).hexdigest() )
     printDBG("key: [%s]" % key)
     iv = a2b_hex("a5e8d2e9c1721ae0e84ad660c472c1f3")
     encrypted = base64.b64decode(data)
     cipher = AES_CBC(key=key, keySize=32)
     return cipher.decrypt(encrypted, iv)
Exemplo n.º 4
0
 def _decUrl(data):
     password = base64.b64decode('X1dyeExsM3JuQTQ4aWFmZ0N5Xw==')[1:-1]
     salt = base64.b64decode('X0NhcnRLUyQyMTQxI18=')[1:-1]
     iv = a2b_hex(base64.b64decode('X2E1ZThkMmU5YzE3MjFhZTBlODRhZDY2MGM0NzJjMWYzXw==')[1:-1])
     encrypted = base64.b64decode(data)
     iterations = 1000
     keySize = 16
     key = pbkdf2(password, salt, iterations, keySize)
     cipher = AES_CBC(key=key, keySize=16)
     return cipher.decrypt(encrypted, iv)
Exemplo n.º 5
0
 def cryptoJS_AES_decrypt(self, encrypted, password, salt):
     def derive_key_and_iv(password, salt, key_length, iv_length):
         d = d_i = ''
         while len(d) < key_length + iv_length:
             d_i = md5(d_i + password + salt).digest()
             d += d_i
         return d[:key_length], d[key_length:key_length+iv_length]
     bs = 16
     key, iv = derive_key_and_iv(password, salt, 32, 16)
     cipher = AES_CBC(key=key, keySize=32)
     return cipher.decrypt(encrypted, iv)
Exemplo n.º 6
0
 def cryptoJS_AES_decrypt(self, encrypted, password, salt):
     def derive_key_and_iv(password, salt, key_length, iv_length):
         d = d_i = ''
         while len(d) < key_length + iv_length:
             d_i = md5(d_i + password + salt).digest()
             d += d_i
         return d[:key_length], d[key_length:key_length+iv_length]
     bs = 16
     key, iv = derive_key_and_iv(password, salt, 32, 16)
     cipher = AES_CBC(key=key, keySize=32)
     return cipher.decrypt(encrypted, iv)
Exemplo n.º 7
0
 def _decUrlOld(data):
     password = base64.b64decode('X1dyeExsM3JuQTQ4aWFmZ0N5Xw==')[1:-1]
     salt = base64.b64decode('X0NhcnRLUyQyMTQxI18=')[1:-1]
     iv = a2b_hex(
         base64.b64decode(
             'X2E1ZThkMmU5YzE3MjFhZTBlODRhZDY2MGM0NzJjMWYzXw==')[1:-1])
     encrypted = base64.b64decode(data)
     iterations = 1000
     keySize = 16
     key = pbkdf2(password, salt, iterations, keySize)
     cipher = AES_CBC(key=key, keySize=16)
     return cipher.decrypt(encrypted, iv)
def CryptoJS_AES_decrypt(encrypted, password, key_length=32):
    def derive_key_and_iv(password, salt, key_length, iv_length):
        d = d_i = ''
        while len(d) < key_length + iv_length:
            d_i = md5(d_i + password + salt).digest()
            d += d_i
        return d[:key_length], d[key_length:key_length+iv_length]

    bs = 16
    salt = encrypted[len('Salted__'):bs]
    key, iv = derive_key_and_iv(password, salt, key_length, bs)
    cipher = AES_CBC(key=key, keySize=32)
    return cipher.decrypt(encrypted[bs:], iv)
Exemplo n.º 9
0
def CryptoJS_AES_decrypt(encrypted, password, key_length=32):
    def derive_key_and_iv(password, salt, key_length, iv_length):
        d = d_i = ''
        while len(d) < key_length + iv_length:
            d_i = md5(d_i + password + salt).digest()
            d += d_i
        return d[:key_length], d[key_length:key_length + iv_length]

    bs = 16
    salt = encrypted[len('Salted__'):bs]
    key, iv = derive_key_and_iv(password, salt, key_length, bs)
    cipher = AES_CBC(key=key, keySize=32)
    return cipher.decrypt(encrypted[bs:], iv)
Exemplo n.º 10
0
 def _cryptoJS_AES(self, encrypted, password, decrypt=True):
     def derive_key_and_iv(password, key_length, iv_length):
         d = d_i = ''
         while len(d) < key_length + iv_length:
             d_i = md5(d_i + password).digest()
             d += d_i
         return d[:key_length], d[key_length:key_length+iv_length]
     bs = 16
     key, iv = derive_key_and_iv(password, 32, 16)
     cipher = AES_CBC(key=key, keySize=32)
     if decrypt:
         return cipher.decrypt(encrypted, iv)
     else:
         return cipher.encrypt(encrypted, iv)
Exemplo n.º 11
0
 def cryptoJS_AES_encrypt(self, decrypted, key, iv):
     cipher = AES_CBC(key=key, keySize=32)
     return cipher.encrypt(decrypted, iv)
Exemplo n.º 12
0
    def getVideoLinks(self, baseUrl):
        printDBG("YifyTV.getVideoLinks [%s]" % baseUrl)

        # 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 baseUrl 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

        urlTab = []

        baseUrl = strwithmeta(baseUrl)
        imdbid = baseUrl.meta.get('imdbid', '')
        sub_tracks = baseUrl.meta.get('external_sub_tracks', [])

        header = dict(self.AJAX_HEADER)
        #header['Referer'] = baseUrl.meta['Referer']

        if 'sou' in baseUrl.meta:
            souTab = [baseUrl.meta['sou']]
            if souTab[0] == 'pic':
                souTab.append('adr')
            if souTab[0] == 'adr':
                souTab.append('pic')

            for sou in souTab:
                post_data = {'fv': '27', 'url': baseUrl, 'sou': sou}
                url = 'https://ymovies.tv/playerlite/pk/pk/plugins/player_p2.php'
                sts, data = self.getPage(url, {'header': header}, post_data)
                if not sts: return []

                printDBG(
                    "+++++++++++++++++++++++  data  ++++++++++++++++++++++++")
                printDBG(data)
                printDBG(
                    "+++++++++++++++++++++++++++++++++++++++++++++++++++++++")

                try:
                    attempt = 0
                    while attempt < 3:
                        attempt += 1
                        printDBG(data)
                        if 'jscode' in data:
                            try:
                                data = byteify(json.loads(data))[0]['jscode'][
                                    1:-1]  #.replace('eval(', 'print(')
                                jsTab = ['']
                                jsTab.append(
                                    '''var iptv_href="%s"; var iptv_domain="%s"; var iptv_video_id="%s"; var iptv_jwpath="%s";\n'''
                                    % (self.getMainUrl(),
                                       self.up.getDomain(
                                           self.getMainUrl()), imdbid, url))
                                jsTab.append(
                                    base64.b64decode(
                                        '''ZnVuY3Rpb24gU2hvd0Rpdigpe31mdW5jdGlvbiBzaG93aUZyYW1lKCl7cHJpbnQoYXJndW1lbnRzWzBdKX1mdW5jdGlvbiBnZXRKd1BhdGgoKXtyZXR1cm4gaXB0dl9qd3BhdGh9ZnVuY3Rpb24gZ2V0X3BhcmFtc19ub19zb3JjZXMoKXtyZXR1cm4gaXB0dl92aWRlb19pZH1mdW5jdGlvbiBzZXRUaW1lb3V0KHQsbil7aWYoaXB0dl9kaXJlY3QpdHJ5e3QoKX1jYXRjaChlKXtwcmludCgiXG4iKX1lbHNlIHRoaXMudHJ5dXAoKX12YXIgZG9jdW1lbnQ9e30sd2luZG93PXRoaXMsbG9jYXRpb249e307bG9jYXRpb24uaHJlZj1pcHR2X2hyZWYsbG9jYXRpb24uaG9zdG5hbWU9aXB0dl9kb21haW4sbG9jYXRpb24udG9TdHJpbmc9ZnVuY3Rpb24oKXtyZXR1cm4gaXB0dl9ocmVmfSxkb2N1bWVudC5sb2NhdGlvbj1sb2NhdGlvbjt2YXIgZWxlbWVudD1mdW5jdGlvbih0KXt0aGlzLnRleHQ9ZnVuY3Rpb24oKXtyZXR1cm4ibm9uZSJ9LHRoaXMuZmlyc3Q9ZnVuY3Rpb24oKXtyZXR1cm4gbmV3IGVsZW1lbnR9fSwkPWZ1bmN0aW9uKHQpe3JldHVybiBuZXcgZWxlbWVudCh0KX0scGxheWVybW9kZT0iIixzb3VyY2VTZWxlY3RlZD0wLHNvdXJjZXM9W3tzdWJfZGVsYXk6MCxzdWJfZmFjdG9yOjF9XTskLmdldD1mdW5jdGlvbigpe3JldHVybiBwcmludChhcmd1bWVudHNbMF0pLHtkb25lOlNob3dEaXYsZXJyb3I6U2hvd0Rpdn19LCQucG9zdD1mdW5jdGlvbigpe3ByaW50KCJcbklQVFZfUE9TVF9TVEFSVFxuIikscHJpbnQoSlNPTi5zdHJpbmdpZnkoe3VybDphcmd1bWVudHNbMF0scGFyYW1zOmFyZ3VtZW50c1sxXX0pKSxwcmludCgiXG5JUFRWX1BPU1RfRU5EXG4iKX07'''
                                    ))
                                jsTab.append('var iptv_fun = %s; iptv_fun();' %
                                             data)

                                for iptv_direct in ["false", "true"]:
                                    jsTab[
                                        0] = 'var iptv_direct = %s;' % iptv_direct
                                    jscode = '\n'.join(jsTab)
                                    printDBG(
                                        "+++++++++++++++++++++++  CODE  ++++++++++++++++++++++++"
                                    )
                                    printDBG(jscode)
                                    printDBG(
                                        "+++++++++++++++++++++++++++++++++++++++++++++++++++++++"
                                    )
                                    ret = js_execute(jscode)
                                    if not ret['sts'] or 0 != ret['code']:
                                        ret = js_execute(
                                            jscode.replace('eval(', 'print('))
                                    if ret['sts'] and 0 == ret['code']:
                                        decoded = ret['data'].strip()
                                        printDBG('DECODED DATA -> [%s]' %
                                                 decoded)
                                        data = decoded
                                        break
                                if 'jscode' in data:
                                    data = data[data.
                                                find("["):data.rfind("]") + 1]
                                    data = byteify(json.loads('"%s"' % data))
                                    continue
                            except Exception:
                                printExc()

                            if 'IPTV_POST_START' in data:
                                data = self.cm.ph.getDataBeetwenMarkers(
                                    data, 'IPTV_POST_START', 'IPTV_POST_END',
                                    0)[1]
                                try:
                                    tmp = byteify(json.loads(data.strip()))
                                    sts, data = self.getPage(
                                        tmp['url'], {
                                            'header': header,
                                            'raw_post_data': True
                                        }, tmp['params'])
                                    if not sts: return []
                                    tmp = byteify(json.loads(data))
                                    for hostDomain in tmp['hosts']:
                                        urlTab.append({
                                            'name':
                                            hostDomain,
                                            'url':
                                            'http://%s%s' %
                                            (hostDomain, tmp['path'])
                                        })
                                    if len(urlTab): break
                                except Exception:
                                    printExc()

                            g3 = self.cm.ph.getSearchGroups(
                                data + '&', '''[&\?]g3=([^&]+?)&''')[0]
                            emb = self.cm.ph.getSearchGroups(
                                data + '&', '''[&\?]emb=([^&^\*]+?)[&\*]''')[0]
                            if emb != '': data = urllib.unquote(emb)
                            if g3 != '':
                                post_data = {
                                    'fv': '0',
                                    'g3': urllib.unquote(g3)
                                }
                                url = 'https://ymovies.tv/playerlite/pk/pk/plugins/player_g3.php'
                                sts, data = self.getPage(
                                    url, {'header': header}, post_data)
                                if not sts: return []
                                printDBG(data)
                            elif self.cm.isValidUrl(
                                    data) and 1 == self.up.checkHostSupport(
                                        data):
                                urlTab = self.up.getVideoLinkExt(data)
                                break
                            else:
                                if 'showiFrame(' in data:
                                    url = urllib.unquote(
                                        self.cm.ph.getDataBeetwenMarkers(
                                            data, "emb='+'", "'", False)[1])
                                    tmp = url.split('sub.file')
                                    url = tmp[0]
                                    subTrack = urllib.unquote(tmp[1])
                                    if url.startswith('//'):
                                        url = 'http:' + url
                                    if subTrack.startswith('//'):
                                        subTrack = 'http:' + subTrack
                                    tmpUrlTab = self.up.getVideoLinkExt(url)
                                    if self.cm.isValidUrl(subTrack):
                                        format = subTrack[-3:]
                                        for idx in range(len(tmpUrlTab)):
                                            tmpUrlTab[idx][
                                                'url'] = strwithmeta(
                                                    tmpUrlTab[idx]['url'], {
                                                        'external_sub_tracks':
                                                        [{
                                                            'title': '',
                                                            'url': subTrack,
                                                            'lang': 'en',
                                                            'format': format
                                                        }]
                                                    })
                                    urlTab.extend(tmpUrlTab)
                                    printDBG(urlTab)
                                    break

                                if 'sources[sourceSelected]["paramId"]' in data:
                                    data = data.replace('"+"',
                                                        '').replace(' ', '')
                                    paramSite = self.cm.ph.getSearchGroups(
                                        data,
                                        'sources\[sourceSelected\]\["paramSite"\]="([^"]+?)"'
                                    )[0]
                                    data = self.cm.ph.getSearchGroups(
                                        data,
                                        'sources\[sourceSelected\]\["paramId"\]="([^"]+?)"'
                                    )[0]
                                    printDBG(
                                        'data ------------------------- [%s]' %
                                        data)
                                    if data.startswith('enc'):
                                        encrypted = base64.b64decode(data[3:])
                                        key = unhexlify(
                                            base64.b64decode(
                                                'MzAzOTM4NzMzOTM3MzU0MTMxMzIzMzczMzEzMzM1NjQ2NDY2Njc3NzQ4MzczODM0MzczNTMzMzQzNjcyNjQ3Nw=='
                                            ))
                                        iv = unhexlify(
                                            base64.b64decode(
                                                'NWE0MTRlMzEzNjMzNjk2NDZhNGM1MzUxMzU0YzY0MzU='
                                            ))
                                        cipher = AES_CBC(key=key,
                                                         padding=noPadding(),
                                                         keySize=32)
                                        data = cipher.decrypt(
                                            encrypted, iv).split('\x00')[0]
                                        if 'ucl' == paramSite:
                                            urlTab.extend(
                                                self.up.getVideoLinkExt(
                                                    "https://userscloud.com/embed-"
                                                    + data + "-1280x534.html"))
                                        elif 'tus' == paramSite:
                                            urlTab.extend(
                                                self.up.getVideoLinkExt(
                                                    "https://tusfiles.net/embed-"
                                                    + data +
                                                    "-1280x534.html?v=34"))
                                        elif 'up' == paramSite:
                                            urlTab.extend(
                                                self.up.getVideoLinkExt(
                                                    "http://uptobox.com/" +
                                                    data))
                                        break

                        if '("' in data:
                            data = self.cm.ph.getDataBeetwenMarkers(
                                data, '(', ')', False)[1]
                            data = byteify(json.loads(data))
                        if isinstance(data, basestring):
                            data = byteify(json.loads(data))
                        printDBG(data)
                        for item in data:
                            #printDBG('++++++++++++++++++++++\n%s\n++++++++++++++++++++++' % item)
                            if (item.get('type', '').startswith('video/')
                                    or item.get('type', '').startswith(
                                        'application/x-shockwave-flash')
                                ) and self.cm.isValidUrl(item.get('url', '')):
                                urlTab.append({
                                    'name':
                                    '{0}x{1}'.format(item.get('height', ''),
                                                     item.get('width', '')),
                                    'url':
                                    item['url'],
                                    'need_resolve':
                                    0
                                })
                    break
                except Exception:
                    SetIPTVPlayerLastHostError(
                        'The Mirror is broken.\nIf available you can choose other source.'
                    )
                    printExc()
                    return []

                if len(urlTab): break

        elif self.cm.isValidUrl(baseUrl):
            urlTab = self.up.getVideoLinkExt(baseUrl)

        printDBG(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
        printDBG(urlTab)

        for idx in range(len(urlTab)):
            subs = list(
                strwithmeta(urlTab[idx]['url']).meta.get(
                    'external_sub_tracks', []))
            subs.extend(sub_tracks)
            urlTab[idx]['url'] = strwithmeta(urlTab[idx]['url'],
                                             {'external_sub_tracks': subs})

        printDBG(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
        printDBG(urlTab)
        return urlTab
Exemplo n.º 13
0
    def getVideoLinks(self, baseUrl):
        printDBG("YifyTV.getVideoLinks [%s]" % baseUrl)

        # 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 baseUrl 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

        urlTab = []

        baseUrl = strwithmeta(baseUrl)
        imdbid = baseUrl.meta.get('imdbid', '')
        sub_tracks = baseUrl.meta.get('external_sub_tracks', [])

        header = dict(self.AJAX_HEADER)
        #header['Referer'] = baseUrl.meta['Referer']

        if 'sou' in baseUrl.meta:
            souTab = [baseUrl.meta['sou']]
            if souTab[0] == 'pic':
                souTab.append('adr')
            if souTab[0] == 'adr':
                souTab.append('pic')

            for sou in souTab:
                post_data = {'fv': '27', 'url': baseUrl, 'sou': sou}
                url = 'https://ymovies.to/playerlite/pk/pk/plugins/player_p2.php'
                sts, data = self.getPage(url, {'header': header}, post_data)
                if not sts:
                    return []

                printDBG(
                    "+++++++++++    player_p2.php javascript code  +++++++++")
                printDBG(data)
                printDBG(
                    "+++++++++++++++++++++++++++++++++++++++++++++++++++++++")

                if 'jscode' in data:
                    data = byteify(json_loads(data))[0]['jscode'][1:-1]
                    if 'eval(' in data:
                        evalCode = self.cm.ph.getSearchGroups(
                            data, "(eval\(.*?\));")[0]
                        evalCode2 = evalCode[5:-1]
                        evalCodeSub = "print(" + evalCode2 + ");\n" + evalCode
                        printDBG("eval code: %s, %s ----> %s" %
                                 (evalCode, evalCode2, evalCodeSub))
                        data = data.replace(evalCode, evalCodeSub)

                    jsTab = ['']
                    jsTab.append(
                        '''var iptv_href="%s"; var iptv_domain="%s"; var iptv_video_id="%s"; var iptv_jwpath="%s";\n'''
                        % (self.getMainUrl(),
                           self.up.getDomain(self.getMainUrl()), imdbid, url))
                    jsTab.append(
                        base64.b64decode(
                            '''ZnVuY3Rpb24gU2hvd0Rpdigpe31mdW5jdGlvbiBzaG93aUZyYW1lKCl7cHJpbnQoYXJndW1lbnRzWzBdKX1mdW5jdGlvbiBnZXRKd1BhdGgoKXtyZXR1cm4gaXB0dl9qd3BhdGh9ZnVuY3Rpb24gZ2V0X3BhcmFtc19ub19zb3JjZXMoKXtyZXR1cm4gaXB0dl92aWRlb19pZH1mdW5jdGlvbiBzZXRUaW1lb3V0KHQsbil7aWYoaXB0dl9kaXJlY3QpdHJ5e3QoKX1jYXRjaChlKXtwcmludCgiXG4iKX1lbHNlIHRoaXMudHJ5dXAoKX12YXIgZG9jdW1lbnQ9e30sd2luZG93PXRoaXMsbG9jYXRpb249e307bG9jYXRpb24uaHJlZj1pcHR2X2hyZWYsbG9jYXRpb24uaG9zdG5hbWU9aXB0dl9kb21haW4sbG9jYXRpb24udG9TdHJpbmc9ZnVuY3Rpb24oKXtyZXR1cm4gaXB0dl9ocmVmfSxkb2N1bWVudC5sb2NhdGlvbj1sb2NhdGlvbjt2YXIgZWxlbWVudD1mdW5jdGlvbih0KXt0aGlzLnRleHQ9ZnVuY3Rpb24oKXtyZXR1cm4ibm9uZSJ9LHRoaXMuZmlyc3Q9ZnVuY3Rpb24oKXtyZXR1cm4gbmV3IGVsZW1lbnR9fSwkPWZ1bmN0aW9uKHQpe3JldHVybiBuZXcgZWxlbWVudCh0KX0scGxheWVybW9kZT0iIixzb3VyY2VTZWxlY3RlZD0wLHNvdXJjZXM9W3tzdWJfZGVsYXk6MCxzdWJfZmFjdG9yOjF9XTskLmdldD1mdW5jdGlvbigpe3JldHVybiBwcmludChhcmd1bWVudHNbMF0pLHtkb25lOlNob3dEaXYsZXJyb3I6U2hvd0Rpdn19LCQucG9zdD1mdW5jdGlvbigpe3ByaW50KCJcbklQVFZfUE9TVF9TVEFSVFxuIikscHJpbnQoSlNPTi5zdHJpbmdpZnkoe3VybDphcmd1bWVudHNbMF0scGFyYW1zOmFyZ3VtZW50c1sxXX0pKSxwcmludCgiXG5JUFRWX1BPU1RfRU5EXG4iKX07'''
                        ))

                    jsTab.append('var iptv_fun = %s; iptv_fun();' % data)

                    for iptv_direct in ["false", "true"]:
                        jsTab[0] = 'var iptv_direct = %s;' % iptv_direct
                        jscode = '\n'.join(jsTab)
                        printDBG(
                            "+++++++++++++ code after replaces ++++++++++++++++++++++++"
                        )
                        printDBG(jscode)
                        printDBG(
                            "+++++++++++++++++++++++++++++++++++++++++++++++++++++++"
                        )
                        ret = js_execute(jscode)

                        if ret['sts']:  #and 0 == ret['code']:
                            decoded = ret['data'].strip()
                            printDBG('DECODED DATA -> [%s]' % decoded)

                            # various forms of data answer

                            try_url = decoded.split('\n')[-1]
                            if self.cm.isValidUrl(try_url):
                                urlTab.extend(self.up.getVideoLinkExt(try_url))

                                break

                            elif 'parseRes2' in decoded:
                                printDBG("Search for ParseRes2 argument")
                                prData = self.cm.ph.getSearchGroups(
                                    decoded, "parseRes2\(\"(.*?)\"\)")[0]
                                printDBG("ParseRes2 function argument : %s" %
                                         prData)

                                #decoded2 = json_loads(prData.replace('\"','"'))

                                decoded2 = json_loads(eval('"' + prData + '"'))
                                printDBG("------------decoded2-------------")
                                printDBG(str(decoded2))

                                for l in decoded2:
                                    if 'url' in l:
                                        if l['url'].endswith('.m3u8'):
                                            params = getDirectM3U8Playlist(
                                                self.getFullUrl(l['url']),
                                                checkExt=False,
                                                variantCheck=True,
                                                checkContent=True,
                                                sortWithMaxBitrate=99999999)
                                            printDBG(str(params))
                                            urlTab.extend(params)
                                        else:
                                            if not 'image' in l.get(
                                                    'type', ''):
                                                params = {
                                                    'name':
                                                    l.get('type', 'link'),
                                                    'url':
                                                    self.getFullUrl(l['url'])
                                                }
                                                printDBG(str(params))
                                                urlTab.append(params)
                                break

                            elif 'showiFrame' in decoded:
                                arg = self.cm.ph.getSearchGroups(
                                    decoded,
                                    "showiFrame\(['\"](.*?)['\"]\)")[0]
                                printDBG(
                                    "Search for showiFrame argument: %s " %
                                    arg)

                                if 'emb=' in decoded:
                                    url = urllib.unquote(
                                        self.cm.ph.getDataBeetwenMarkers(
                                            decoded, "emb='+'", "*", False)[1])
                                    if not url:
                                        url = urllib.unquote(
                                            self.cm.ph.getDataBeetwenMarkers(
                                                decoded, "emb='+'", "'",
                                                False)[1])

                                    printDBG("---> found url: %s " % url)
                                    if 'sub.file' in url:
                                        tmp = url.split('sub.file')
                                        url = tmp[0]
                                        subTrack = urllib.unquote(tmp[1])
                                        if url.startswith('//'):
                                            url = 'http:' + url
                                        if subTrack.startswith('//'):
                                            subTrack = 'http:' + subTrack
                                        tmpUrlTab = self.up.getVideoLinkExt(
                                            url)
                                        if self.cm.isValidUrl(subTrack):
                                            format = subTrack[-3:]
                                            for idx in range(len(tmpUrlTab)):
                                                tmpUrlTab[idx][
                                                    'url'] = strwithmeta(
                                                        tmpUrlTab[idx]['url'],
                                                        {
                                                            'external_sub_tracks':
                                                            [{
                                                                'title': '',
                                                                'url':
                                                                subTrack,
                                                                'lang': 'en',
                                                                'format':
                                                                format
                                                            }]
                                                        })
                                        urlTab.extend(tmpUrlTab)
                                        printDBG(urlTab)
                                    else:
                                        urlTab.extend(
                                            self.up.getVideoLinkExt(url))

                                else:
                                    if self.cm.isValidUrl(arg):
                                        urlTab = self.up.getVideoLinkExt(arg)

                                break

                            elif 'sources[sourceSelected]["paramId"]' in decoded:
                                data = data.replace('"+"', '').replace(' ', '')
                                paramSite = self.cm.ph.getSearchGroups(
                                    data,
                                    'sources\[sourceSelected\]\["paramSite"\]="([^"]+?)"'
                                )[0]
                                data = self.cm.ph.getSearchGroups(
                                    data,
                                    'sources\[sourceSelected\]\["paramId"\]="([^"]+?)"'
                                )[0]
                                printDBG(
                                    'data ------------------------- [%s]' %
                                    data)
                                if data.startswith('enc'):
                                    encrypted = base64.b64decode(data[3:])
                                    key = unhexlify(
                                        base64.b64decode(
                                            'MzAzOTM4NzMzOTM3MzU0MTMxMzIzMzczMzEzMzM1NjQ2NDY2Njc3NzQ4MzczODM0MzczNTMzMzQzNjcyNjQ3Nw=='
                                        ))
                                    iv = unhexlify(
                                        base64.b64decode(
                                            'NWE0MTRlMzEzNjMzNjk2NDZhNGM1MzUxMzU0YzY0MzU='
                                        ))
                                    cipher = AES_CBC(key=key,
                                                     padding=noPadding(),
                                                     keySize=32)
                                    data = cipher.decrypt(encrypted,
                                                          iv).split('\x00')[0]
                                    if 'ucl' == paramSite:
                                        params = self.up.getVideoLinkExt(
                                            "https://userscloud.com/embed-" +
                                            data + "-1280x534.html")
                                        printDBG(str(params))
                                        urlTab.extend(params)
                                    elif 'tus' == paramSite:
                                        params = self.up.getVideoLinkExt(
                                            "https://tusfiles.net/embed-" +
                                            data + "-1280x534.html?v=34")
                                        printDBG(str(params))
                                        urlTab.extend(params)
                                    elif 'up' == paramSite:
                                        params = self.up.getVideoLinkExt(
                                            "http://uptobox.com/" + data)
                                        printDBG(str(params))
                                        urlTab.extend(params)
                                    break

                            elif 'IPTV_POST_START' in decoded:
                                data = self.cm.ph.getDataBeetwenMarkers(
                                    data, 'IPTV_POST_START', 'IPTV_POST_END',
                                    0)[1]
                                try:
                                    tmp = byteify(json_loads(data.strip()))
                                    sts, data = self.getPage(
                                        tmp['url'], {
                                            'header': header,
                                            'raw_post_data': True
                                        }, tmp['params'])
                                    if not sts: return []
                                    tmp = byteify(json_loads(data))
                                    for hostDomain in tmp['hosts']:
                                        params = {
                                            'name':
                                            hostDomain,
                                            'url':
                                            'http://%s%s' %
                                            (hostDomain, tmp['path'])
                                        }
                                        printDBG(str(params))
                                        urlTab.append(params)
                                    if len(urlTab): break
                                except Exception:
                                    printExc()

                            else:
                                data = json_loads(decoded)

        elif self.cm.isValidUrl(baseUrl):
            urlTab = self.up.getVideoLinkExt(baseUrl)

        printDBG(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
        printDBG(urlTab)

        for idx in range(len(urlTab)):
            subs = list(
                strwithmeta(urlTab[idx]['url']).meta.get(
                    'external_sub_tracks', []))
            subs.extend(sub_tracks)
            urlTab[idx]['url'] = strwithmeta(urlTab[idx]['url'],
                                             {'external_sub_tracks': subs})

        printDBG(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
        printDBG(urlTab)
        return urlTab
Exemplo n.º 14
0
    def getVideoLinks(self, baseUrl):
        printDBG("YifyTV.getVideoLinks [%s]" % baseUrl)

        urlTab = []
        sub_tracks = strwithmeta(baseUrl).meta.get('external_sub_tracks', [])

        header = dict(self.AJAX_HEADER)
        header['Referer'] = baseUrl.meta['Referer']

        souTab = [baseUrl.meta.get('sou', '')]
        if souTab[0] == 'pic':
            souTab.append('adr')
        if souTab[0] == 'adr':
            souTab.append('pic')
        for sou in souTab:
            post_data = {'fv': '18', 'url': baseUrl, 'sou': sou}
            url = 'http://yify.tv/playerlite/pk/pk/plugins/player_p2.php'
            sts, data = self.cm.getPage(url, {'header': header}, post_data)
            if not sts: return []
            #printDBG('>>>>>>>>>>>>>>>>>>>>>>>\n%s\n<<<<<<<<<<<<<<<' % data)
            try:
                printDBG(data)
                if 'jscode' in data:
                    data = self._evalJscode(data)
                    if 'sources[sourceSelected]["paramId"]' in data:
                        data = data.replace('"+"', '').replace(' ', '')
                        data = self.cm.ph.getSearchGroups(
                            data,
                            'sources\[sourceSelected\]\["paramId"\]="([^"]+?)"'
                        )[0]
                        printDBG('data ------------------------- [%s]' % data)
                        if data.startswith('enc'):
                            encrypted = base64.b64decode(data[3:])
                            key = unhexlify(
                                base64.b64decode(
                                    'MzAzOTM4NzMzOTM3MzU0MTMxMzIzMzczMzEzMzM1NjQ2NDY2Njc3NzQ4MzczODM0MzczNTMzMzQzNjcyNjQ3Nw=='
                                ))
                            iv = unhexlify(
                                base64.b64decode(
                                    'NWE0MTRlMzEzNjMzNjk2NDZhNGM1MzUxMzU0YzY0MzU='
                                ))
                            cipher = AES_CBC(key=key,
                                             padding=noPadding(),
                                             keySize=32)
                            data = cipher.decrypt(encrypted,
                                                  iv).split('\x00')[0]
                            urlTab.extend(
                                self.up.getVideoLinkExt(
                                    "https://userscloud.com/embed-" + data +
                                    "-1280x534.html"))
                            break

                data = byteify(json.loads(data))
                for item in data:
                    #printDBG('++++++++++++++++++++++\n%s\n++++++++++++++++++++++' % item)
                    if item.get('type', '').startswith('video/') and item.get(
                            'url', '').startswith('http'):
                        urlTab.append({
                            'name':
                            '{0}x{1}'.format(item.get('height', ''),
                                             item.get('width', '')),
                            'url':
                            item['url'],
                            'need_resolve':
                            0
                        })
            except Exception:
                SetIPTVPlayerLastHostError(
                    'The Mirror is broken.\nIf available you can choose other source.'
                )
                printExc()
            if len(urlTab): break

        if False:
            videoUrl = url
            if url.startswith('//'):
                videoUrl = 'http:' + videoUrl
            urlTab = self.up.getVideoLinkExt(videoUrl)
        for idx in range(len(urlTab)):
            urlTab[idx]['url'] = strwithmeta(
                urlTab[idx]['url'], {'external_sub_tracks': sub_tracks})

        return urlTab
Exemplo n.º 15
0
 def _decUrl(data, password):
     key = a2b_hex(sha256(password).hexdigest())
     iv = a2b_hex("a5e8d2e9c1721ae0e84ad660c472c1f3")
     encrypted = base64.b64decode(data)
     cipher = AES_CBC(key=key, keySize=32)
     return cipher.decrypt(encrypted, iv)