コード例 #1
0
ファイル: vidcloud9.py プロジェクト: 17Q/modules4all
    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        headers = {
            'User-Agent': common.FF_USER_AGENT,
            'Referer': 'https://vidembed.io/'
        }

        key = '25746538592938496764662879833288'.encode('utf8')
        iv = self.f_random(16)
        encryptor = pyaes.Encrypter(
            pyaes.AESModeOfOperationCBC(key, iv.encode('utf8')))
        eid = encryptor.feed(media_id)
        eid += encryptor.feed()
        url = 'https://vidembed.io' + '/encrypt-ajax.php?id=' + base64.b64encode(eid).decode('utf8') \
            + '&refer=none&time=' + self.f_random(2) + iv + self.f_random(2)
        headers.update({'X-Requested-With': 'XMLHttpRequest'})
        js_data = json.loads(self.net.http_GET(url, headers=headers).content)
        sources = js_data.get('source', None)
        if sources:
            sources = [(source.get('label'), source.get('file'))
                       for source in sources]
            headers.pop('X-Requested-With')
            source = helpers.pick_source(helpers.sort_sources_list(sources))
            return source + helpers.append_headers(headers)

        # Try Beta Server if no sources found with earlier method
        headers.pop('X-Requested-With')
        html = self.net.http_GET(web_url, headers=headers).content
        sources = helpers.scrape_sources(html)
        if sources:
            headers.update({'Origin': 'https://vidembed.io'})
            return helpers.pick_source(sources) + helpers.append_headers(
                headers)

        raise ResolverError('Video not found')
コード例 #2
0
def encrypt_py(plain_text, key):
    if plain_text:
        try:
            scraper_key = hashlib.sha256(key).digest()
            IV = '\0' * 16
            decrypter = pyaes.Encrypter(
                pyaes.AESModeOfOperationCBC(scraper_key, IV))
            cipher_text = decrypter.feed(plain_text)
            cipher_text += decrypter.feed()
        except Exception as e:
            logger.log_warning('Exception during Py Encrypt: %s' % (e))
            cipher_text = ''
    else:
        cipher_text = ''

    return cipher_text
コード例 #3
0
def decrypt_py(cipher_text, key):
    if cipher_text:
        try:
            scraper_key = hashlib.sha256(key).digest()
            IV = '\0' * 16
            decrypter = pyaes.Decrypter(
                pyaes.AESModeOfOperationCBC(scraper_key, IV))
            plain_text = decrypter.feed(cipher_text)
            plain_text += decrypter.feed()
            if 'import' not in plain_text:
                plain_text = ''
        except Exception as e:
            logger.log_warning('Exception during Py Decrypt: %s' % (e))
            plain_text = ''
    else:
        plain_text = ''

    return plain_text