# coding: utf-8 from __future__ import unicode_literals import random import re import string from .common import InfoExtractor from ..utils import ( ExtractorError, int_or_none, mimetype2ext, parse_codecs, update_url_query, urljoin, xpath_element, xpath_text, ) from ..compat import ( compat_b64decode, compat_ord, compat_struct_pack, compat_urlparse, ) class VideaIE(InfoExtractor): _VALID_URL = r'''(?x) https?:// videa(?:kid)?\.hu/ (?: videok/(?:[^/]+/)*[^?#&]+-| (?:videojs_)?player\?.*?\bv=| player/v/ ) (?P[^?#&]+) ''' _TESTS = [{ 'url': 'http://videa.hu/videok/allatok/az-orult-kigyasz-285-kigyot-kigyo-8YfIAjxwWGwT8HVQ', 'md5': '97a7af41faeaffd9f1fc864a7c7e7603', 'info_dict': { 'id': '8YfIAjxwWGwT8HVQ', 'ext': 'mp4', 'title': 'Az őrült kígyász 285 kígyót enged szabadon', 'thumbnail': r're:^https?://.*', 'duration': 21, }, }, { 'url': 'http://videa.hu/videok/origo/jarmuvek/supercars-elozes-jAHDWfWSJH5XuFhH', 'md5': 'd57ccd8812c7fd491d33b1eab8c99975', 'info_dict': { 'id': 'jAHDWfWSJH5XuFhH', 'ext': 'mp4', 'title': 'Supercars előzés', 'thumbnail': r're:^https?://.*', 'duration': 64, }, }, { 'url': 'http://videa.hu/player?v=8YfIAjxwWGwT8HVQ', 'md5': '97a7af41faeaffd9f1fc864a7c7e7603', 'info_dict': { 'id': '8YfIAjxwWGwT8HVQ', 'ext': 'mp4', 'title': 'Az őrült kígyász 285 kígyót enged szabadon', 'thumbnail': r're:^https?://.*', 'duration': 21, }, }, { 'url': 'http://videa.hu/player/v/8YfIAjxwWGwT8HVQ?autoplay=1', 'only_matching': True, }, { 'url': 'https://videakid.hu/videok/origo/jarmuvek/supercars-elozes-jAHDWfWSJH5XuFhH', 'only_matching': True, }, { 'url': 'https://videakid.hu/player?v=8YfIAjxwWGwT8HVQ', 'only_matching': True, }, { 'url': 'https://videakid.hu/player/v/8YfIAjxwWGwT8HVQ?autoplay=1', 'only_matching': True, }] _STATIC_SECRET = 'xHb0ZvME5q8CBcoQi6AngerDu3FGO9fkUlwPmLVY_RTzj2hJIS4NasXWKy1td7p' @staticmethod def _extract_urls(webpage): return [url for _, url in re.findall( r']+src=(["\'])(?P(?:https?:)?//videa\.hu/player\?.*?\bv=.+?)\1', webpage)] @staticmethod def rc4(cipher_text, key): res = b'' key_len = len(key) S = list(range(256)) j = 0 for i in range(256): j = (j + S[i] + ord(key[i % key_len])) % 256 S[i], S[j] = S[j], S[i] i = 0 j = 0 for m in range(len(cipher_text)): i = (i + 1) % 256 j = (j + S[i]) % 256 S[i], S[j] = S[j], S[i] k = S[(S[i] + S[j]) % 256] res += compat_struct_pack('B', k ^ compat_ord(cipher_text[m])) return res.decode('utf-8') def _real_extract(self, url): video_id = self._match_id(url) video_page = self._download_webpage(url, video_id) if 'videa.hu/player' in url: player_url = url player_page = video_page else: player_url = self._search_regex( r'