aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRemita Amine <[email protected]>2020-12-30 13:30:11 +0100
committerRemita Amine <[email protected]>2020-12-30 13:30:11 +0100
commitbdd044e67b5d10736aa712e9be64beff0d47f490 (patch)
tree0b38b2630038569cb581a8c2c1ac3c756cc1e90b
parentf7e95fb2a0516f90edffe72d9911222d1ed1a2bc (diff)
downloadyoutube-dl-bdd044e67b5d10736aa712e9be64beff0d47f490.tar.gz
youtube-dl-bdd044e67b5d10736aa712e9be64beff0d47f490.zip
[yandexvideo] use old api call as fallback
-rw-r--r--youtube_dl/extractor/yandexvideo.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/youtube_dl/extractor/yandexvideo.py b/youtube_dl/extractor/yandexvideo.py
index 36d01cc8e..ab8c84c93 100644
--- a/youtube_dl/extractor/yandexvideo.py
+++ b/youtube_dl/extractor/yandexvideo.py
@@ -5,6 +5,7 @@ from .common import InfoExtractor
from ..utils import (
determine_ext,
int_or_none,
+ try_get,
url_or_none,
)
@@ -64,12 +65,7 @@ class YandexVideoIE(InfoExtractor):
def _real_extract(self, url):
video_id = self._match_id(url)
- content = self._download_json(
- # 'https://frontend.vh.yandex.ru/v23/player/%s.json' % video_id,
- # video_id, query={
- # 'stream_options': 'hires',
- # 'disable_trackings': 1,
- # })['content']
+ player = try_get((self._download_json(
'https://frontend.vh.yandex.ru/graphql', video_id, data=b'''{
player(content_id: "%s") {
computed_title
@@ -90,7 +86,15 @@ class YandexVideoIE(InfoExtractor):
title
views_count
}
-}''' % video_id.encode())['player']['content']['content']
+}''' % video_id.encode(), fatal=False)), lambda x: x['player']['content'])
+ if not player or player.get('error'):
+ player = self._download_json(
+ 'https://frontend.vh.yandex.ru/v23/player/%s.json' % video_id,
+ video_id, query={
+ 'stream_options': 'hires',
+ 'disable_trackings': 1,
+ })
+ content = player['content']
title = content.get('title') or content['computed_title']