Browse Source

[yandexvideo] use old api call as fallback

Remita Amine 4 years ago
parent
commit
bdd044e67b
1 changed files with 11 additions and 7 deletions
  1. 11 7
      youtube_dl/extractor/yandexvideo.py

+ 11 - 7
youtube_dl/extractor/yandexvideo.py

@@ -5,6 +5,7 @@ from .common import InfoExtractor
 from ..utils import (
 from ..utils import (
     determine_ext,
     determine_ext,
     int_or_none,
     int_or_none,
+    try_get,
     url_or_none,
     url_or_none,
 )
 )
 
 
@@ -64,12 +65,7 @@ class YandexVideoIE(InfoExtractor):
     def _real_extract(self, url):
     def _real_extract(self, url):
         video_id = self._match_id(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'''{
             'https://frontend.vh.yandex.ru/graphql', video_id, data=b'''{
   player(content_id: "%s") {
   player(content_id: "%s") {
     computed_title
     computed_title
@@ -90,7 +86,15 @@ class YandexVideoIE(InfoExtractor):
     title
     title
     views_count
     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']
         title = content.get('title') or content['computed_title']