]> jfr.im git - yt-dlp.git/commitdiff
[niconico] Fix title and thumbnail extraction (#273)
authorCXwudi <redacted>
Mon, 26 Apr 2021 02:53:57 +0000 (19:53 -0700)
committerGitHub <redacted>
Mon, 26 Apr 2021 02:53:57 +0000 (08:23 +0530)
Authored by: CXwudi

yt_dlp/extractor/niconico.py

index 84437e450f5302c74eeb202339118c372987c19d..91924b318e08d1c4c53f8dd1d4d0a023445eeade 100644 (file)
@@ -493,7 +493,8 @@ def get_video_info_xml(items):
 
         # Start extracting information
         title = (
-            get_video_info_web(['originalTitle', 'title'])
+            get_video_info_xml('title')  # prefer to get the untranslated original title
+            or get_video_info_web(['originalTitle', 'title'])
             or self._og_search_title(webpage, default=None)
             or self._html_search_regex(
                 r'<span[^>]+class="videoHeaderTitle"[^>]*>([^<]+)</span>',
@@ -507,7 +508,9 @@ def get_video_info_xml(items):
 
         thumbnail = (
             self._html_search_regex(r'<meta property="og:image" content="([^"]+)">', webpage, 'thumbnail data', default=None)
-            or get_video_info_web(['thumbnail_url', 'largeThumbnailURL', 'thumbnailURL'])
+            or try_get(  # choose highest from 720p to 240p
+                get_video_info_web('thumbnail'),
+                ['ogp', 'player', 'largeUrl', 'middleUrl', 'url'])
             or self._html_search_meta('image', webpage, 'thumbnail', default=None)
             or video_detail.get('thumbnail'))