5 from .common
import InfoExtractor
6 from ..compat
import compat_b64decode
, compat_ord
20 class VideaIE(InfoExtractor
):
25 videok/(?:[^/]+/)*[^?#&]+-|
26 (?:videojs_)?player\?.*?\bv=|
31 _EMBED_REGEX
= [r
'<iframe[^>]+src=(["\'])(?P
<url
>(?
:https?
:)?
//videa\
.hu
/player
\?.*?
\bv
=.+?
)\
1']
33 'url
': 'http
://videa
.hu
/videok
/allatok
/az
-orult
-kigyasz
-285-kigyot
-kigyo
-8YfIAjxwWGwT8HVQ
',
34 'md5
': '97a7af41faeaffd9f1fc864a7c7e7603
',
36 'id': '8YfIAjxwWGwT8HVQ
',
38 'title
': 'Az őrült kígyász
285 kígyót enged szabadon
',
39 'thumbnail
': r're
:^https?
://.*',
43 'url
': 'http
://videa
.hu
/videok
/origo
/jarmuvek
/supercars
-elozes
-jAHDWfWSJH5XuFhH
',
44 'md5
': 'd57ccd8812c7fd491d33b1eab8c99975
',
46 'id': 'jAHDWfWSJH5XuFhH
',
48 'title
': 'Supercars előzés
',
49 'thumbnail
': r're
:^https?
://.*',
53 'url
': 'http
://videa
.hu
/player?v
=8YfIAjxwWGwT8HVQ
',
54 'md5
': '97a7af41faeaffd9f1fc864a7c7e7603
',
56 'id': '8YfIAjxwWGwT8HVQ
',
58 'title
': 'Az őrült kígyász
285 kígyót enged szabadon
',
59 'thumbnail
': r're
:^https?
://.*',
63 'url
': 'http
://videa
.hu
/player
/v
/8YfIAjxwWGwT8HVQ?autoplay
=1',
64 'only_matching
': True,
66 'url
': 'https
://videakid
.hu
/videok
/origo
/jarmuvek
/supercars
-elozes
-jAHDWfWSJH5XuFhH
',
67 'only_matching
': True,
69 'url
': 'https
://videakid
.hu
/player?v
=8YfIAjxwWGwT8HVQ
',
70 'only_matching
': True,
72 'url
': 'https
://videakid
.hu
/player
/v
/8YfIAjxwWGwT8HVQ?autoplay
=1',
73 'only_matching
': True,
75 _STATIC_SECRET = 'xHb0ZvME5q8CBcoQi6AngerDu3FGO9fkUlwPmLVY_RTzj2hJIS4NasXWKy1td7p
'
78 def rc4(cipher_text, key):
86 j = (j + S[i] + ord(key[i % key_len])) % 256
87 S[i], S[j] = S[j], S[i]
91 for m in range(len(cipher_text)):
94 S[i], S[j] = S[j], S[i]
95 k = S[(S[i] + S[j]) % 256]
96 res += struct.pack('B
', k ^ compat_ord(cipher_text[m]))
100 def _real_extract(self, url):
101 video_id = self._match_id(url)
102 video_page = self._download_webpage(url, video_id)
104 if 'videa
.hu
/player
' in url:
106 player_page = video_page
108 player_url = self._search_regex(
109 r'<iframe
.*?src
="(/player\?[^"]+)"', video_page, 'player url')
110 player_url = urljoin(url, player_url)
111 player_page = self._download_webpage(player_url, video_id)
113 nonce = self._search_regex(
114 r'_xt\s*=\s*"([^
"]+)"', player_page, 'nonce
')
118 for i in range(0, 32):
119 result += s[i - (self._STATIC_SECRET.index(l[i]) - 31)]
121 query = parse_qs(player_url)
122 random_seed = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(8))
123 query['_s
'] = random_seed
124 query['_t
'] = result[:16]
126 b64_info, handle = self._download_webpage_handle(
127 'http
://videa
.hu
/videaplayer_get_xml
.php
', video_id, query=query)
128 if b64_info.startswith('<?xml
'):
129 info = self._parse_xml(b64_info, video_id)
131 key = result[16:] + random_seed + handle.headers['x
-videa
-xs
']
132 info = self._parse_xml(self.rc4(
133 compat_b64decode(b64_info), key), video_id)
135 video = xpath_element(info, './video
', 'video
')
137 raise ExtractorError(xpath_element(
138 info, './error
', fatal=True), expected=True)
139 sources = xpath_element(
140 info, './video_sources
', 'sources
', fatal=True)
141 hash_values = xpath_element(
142 info, './hash_values
', 'hash values
', fatal=False)
144 title = xpath_text(video, './title
', fatal=True)
147 for source in sources.findall('./video_source
'):
148 source_url = source.text
149 source_name = source.get('name
')
150 source_exp = source.get('exp
')
151 if not (source_url and source_name):
154 xpath_text(hash_values, 'hash_value_
' + source_name)
155 if hash_values is not None else None)
156 if hash_value and source_exp:
157 source_url = update_url_query(source_url, {
159 'expires
': source_exp,
161 f = parse_codecs(source.get('codecs
'))
163 'url
': self._proto_relative_url(source_url),
164 'ext
': mimetype2ext(source.get('mimetype
')) or 'mp4
',
165 'format_id
': source.get('name
'),
166 'width
': int_or_none(source.get('width
')),
167 'height
': int_or_none(source.get('height
')),
170 self._sort_formats(formats)
172 thumbnail = self._proto_relative_url(xpath_text(video, './poster_src
'))
175 is_adult = xpath_text(video, './is_adult_content
', default=None)
177 age_limit = 18 if is_adult == '1' else 0
182 'thumbnail
': thumbnail,
183 'duration
': int_or_none(xpath_text(video, './duration
')),
184 'age_limit
': age_limit,