mirror of
https://github.com/ytdl-org/youtube-dl
synced 2025-03-31 20:27:27 +09:00
Compare commits
No commits in common. "f9f9699f2fa87ec54d59b1834cc56adb6147fec6" and "99de2f38d375f794ffdc4f5a110a5227310f3ab0" have entirely different histories.
f9f9699f2f
...
99de2f38d3
@ -1,25 +1,16 @@
|
|||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import random
|
|
||||||
import re
|
import re
|
||||||
import string
|
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
ExtractorError,
|
|
||||||
int_or_none,
|
int_or_none,
|
||||||
mimetype2ext,
|
mimetype2ext,
|
||||||
parse_codecs,
|
parse_codecs,
|
||||||
update_url_query,
|
|
||||||
xpath_element,
|
xpath_element,
|
||||||
xpath_text,
|
xpath_text,
|
||||||
)
|
)
|
||||||
from ..compat import (
|
|
||||||
compat_b64decode,
|
|
||||||
compat_ord,
|
|
||||||
compat_struct_pack,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class VideaIE(InfoExtractor):
|
class VideaIE(InfoExtractor):
|
||||||
@ -28,7 +19,7 @@ class VideaIE(InfoExtractor):
|
|||||||
videa(?:kid)?\.hu/
|
videa(?:kid)?\.hu/
|
||||||
(?:
|
(?:
|
||||||
videok/(?:[^/]+/)*[^?#&]+-|
|
videok/(?:[^/]+/)*[^?#&]+-|
|
||||||
(?:videojs_)?player\?.*?\bv=|
|
player\?.*?\bv=|
|
||||||
player/v/
|
player/v/
|
||||||
)
|
)
|
||||||
(?P<id>[^?#&]+)
|
(?P<id>[^?#&]+)
|
||||||
@ -62,7 +53,6 @@ class VideaIE(InfoExtractor):
|
|||||||
'url': 'https://videakid.hu/player/v/8YfIAjxwWGwT8HVQ?autoplay=1',
|
'url': 'https://videakid.hu/player/v/8YfIAjxwWGwT8HVQ?autoplay=1',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}]
|
}]
|
||||||
_STATIC_SECRET = 'xHb0ZvME5q8CBcoQi6AngerDu3FGO9fkUlwPmLVY_RTzj2hJIS4NasXWKy1td7p'
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _extract_urls(webpage):
|
def _extract_urls(webpage):
|
||||||
@ -70,84 +60,26 @@ class VideaIE(InfoExtractor):
|
|||||||
r'<iframe[^>]+src=(["\'])(?P<url>(?:https?:)?//videa\.hu/player\?.*?\bv=.+?)\1',
|
r'<iframe[^>]+src=(["\'])(?P<url>(?:https?:)?//videa\.hu/player\?.*?\bv=.+?)\1',
|
||||||
webpage)]
|
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()
|
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
query = {'v': video_id}
|
|
||||||
player_page = self._download_webpage(
|
|
||||||
'https://videa.hu/player', video_id, query=query)
|
|
||||||
|
|
||||||
nonce = self._search_regex(
|
info = self._download_xml(
|
||||||
r'_xt\s*=\s*"([^"]+)"', player_page, 'nonce')
|
'http://videa.hu/videaplayer_get_xml.php', video_id,
|
||||||
l = nonce[:32]
|
query={'v': video_id})
|
||||||
s = nonce[32:]
|
|
||||||
result = ''
|
|
||||||
for i in range(0, 32):
|
|
||||||
result += s[i - (self._STATIC_SECRET.index(l[i]) - 31)]
|
|
||||||
|
|
||||||
random_seed = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(8))
|
video = xpath_element(info, './/video', 'video', fatal=True)
|
||||||
query['_s'] = random_seed
|
sources = xpath_element(info, './/video_sources', 'sources', fatal=True)
|
||||||
query['_t'] = result[:16]
|
|
||||||
|
|
||||||
b64_info, handle = self._download_webpage_handle(
|
|
||||||
'http://videa.hu/videaplayer_get_xml.php', video_id, query=query)
|
|
||||||
if b64_info.startswith('<?xml'):
|
|
||||||
info = self._parse_xml(b64_info, video_id)
|
|
||||||
else:
|
|
||||||
key = result[16:] + random_seed + handle.headers['x-videa-xs']
|
|
||||||
info = self._parse_xml(self.rc4(
|
|
||||||
compat_b64decode(b64_info), key), video_id)
|
|
||||||
|
|
||||||
video = xpath_element(info, './video', 'video')
|
|
||||||
if not video:
|
|
||||||
raise ExtractorError(xpath_element(
|
|
||||||
info, './error', fatal=True), expected=True)
|
|
||||||
sources = xpath_element(
|
|
||||||
info, './video_sources', 'sources', fatal=True)
|
|
||||||
hash_values = xpath_element(
|
|
||||||
info, './hash_values', 'hash values', fatal=True)
|
|
||||||
|
|
||||||
title = xpath_text(video, './title', fatal=True)
|
title = xpath_text(video, './title', fatal=True)
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
for source in sources.findall('./video_source'):
|
for source in sources.findall('./video_source'):
|
||||||
source_url = source.text
|
source_url = source.text
|
||||||
source_name = source.get('name')
|
if not source_url:
|
||||||
source_exp = source.get('exp')
|
|
||||||
if not (source_url and source_name and source_exp):
|
|
||||||
continue
|
continue
|
||||||
hash_value = xpath_text(hash_values, 'hash_value_' + source_name)
|
|
||||||
if not hash_value:
|
|
||||||
continue
|
|
||||||
source_url = update_url_query(source_url, {
|
|
||||||
'md5': hash_value,
|
|
||||||
'expires': source_exp,
|
|
||||||
})
|
|
||||||
f = parse_codecs(source.get('codecs'))
|
f = parse_codecs(source.get('codecs'))
|
||||||
f.update({
|
f.update({
|
||||||
'url': self._proto_relative_url(source_url),
|
'url': source_url,
|
||||||
'ext': mimetype2ext(source.get('mimetype')) or 'mp4',
|
'ext': mimetype2ext(source.get('mimetype')) or 'mp4',
|
||||||
'format_id': source.get('name'),
|
'format_id': source.get('name'),
|
||||||
'width': int_or_none(source.get('width')),
|
'width': int_or_none(source.get('width')),
|
||||||
@ -156,7 +88,8 @@ class VideaIE(InfoExtractor):
|
|||||||
formats.append(f)
|
formats.append(f)
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
thumbnail = self._proto_relative_url(xpath_text(video, './poster_src'))
|
thumbnail = xpath_text(video, './poster_src')
|
||||||
|
duration = int_or_none(xpath_text(video, './duration'))
|
||||||
|
|
||||||
age_limit = None
|
age_limit = None
|
||||||
is_adult = xpath_text(video, './is_adult_content', default=None)
|
is_adult = xpath_text(video, './is_adult_content', default=None)
|
||||||
@ -167,7 +100,7 @@ class VideaIE(InfoExtractor):
|
|||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': title,
|
'title': title,
|
||||||
'thumbnail': thumbnail,
|
'thumbnail': thumbnail,
|
||||||
'duration': int_or_none(xpath_text(video, './duration')),
|
'duration': duration,
|
||||||
'age_limit': age_limit,
|
'age_limit': age_limit,
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user