From 378a5335213122318fa4c35b8a50d07b6dd7970c Mon Sep 17 00:00:00 2001 From: Marco Sirabella Date: Thu, 25 Mar 2021 00:36:39 -0700 Subject: [PATCH 1/2] [youtube] Use localized title & description - Fixes #28421 - Fixes #27738 - Fixes #27499 - Fixes #10758 - Fixes mpv-player/mpv#8676 --- youtube_dl/extractor/youtube.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py index badca3977..f4589a85f 100644 --- a/youtube_dl/extractor/youtube.py +++ b/youtube_dl/extractor/youtube.py @@ -1067,6 +1067,24 @@ class YoutubeIE(YoutubeBaseInfoExtractor): 'url': 'https://www.youtube.com/watch?v=nGC3D_FkCmg', 'only_matching': True, }, + { + # Translated title + 'url': 'UnIhRpIT7nc', + 'info_dict': { + 'id': 'UnIhRpIT7nc', + 'ext': 'mp4', + 'title': 'inabakumori - Lagtrain (Vo. Kaai Yuki) / 稲葉曇『ラグトレイン』Vo. 歌愛ユキ', + # Translated description + 'description': 'md5:d0865e57701acd99b4d89679a66e9632', + 'upload_date': '20200716', + 'uploader': '稲葉曇', + 'uploader_id': 'UCNElM45JypxqAR73RoUQ10g', + 'uploader_url': r're:https?://(?:www\.)?youtube\.com/channel/UCNElM45JypxqAR73RoUQ10g', + }, + 'params': { + 'skip_download': True, + }, + }, ] _formats = { '5': {'ext': 'flv', 'width': 400, 'height': 240, 'acodec': 'mp3', 'abr': 64, 'vcodec': 'h263'}, @@ -1479,10 +1497,11 @@ class YoutubeIE(YoutubeBaseInfoExtractor): player_response, lambda x: x['microformat']['playerMicroformatRenderer'], dict) or {} - video_title = video_details.get('title') \ - or get_text(microformat.get('title')) \ + video_title = get_text(microformat.get('title')) \ + or video_details.get('title') \ or search_meta(['og:title', 'twitter:title', 'title']) - video_description = video_details.get('shortDescription') + video_description = get_text(microformat.get('description')) \ + or video_details.get('shortDescription') if not smuggled_data.get('force_singlefeed', False): if not self._downloader.params.get('noplaylist'): From 7ad130c4b603cea70cb049d25fefe60c0a2ca6cd Mon Sep 17 00:00:00 2001 From: Marco Sirabella Date: Thu, 25 Mar 2021 01:02:20 -0700 Subject: [PATCH 2/2] [youtube] Fix channel value never being set Previously was never getting set because was expecting a string but getting a dict, as evidenced by get_text Surprisingly, can't find an issue to close with this one --- youtube_dl/extractor/youtube.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py index f4589a85f..32e9327bb 100644 --- a/youtube_dl/extractor/youtube.py +++ b/youtube_dl/extractor/youtube.py @@ -426,6 +426,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor): 'ext': 'mp4', 'title': 'youtube-dl test video "\'/\\ä↭𝕐', 'uploader': 'Philipp Hagemeister', + 'channel': 'Philipp Hagemeister', 'uploader_id': 'phihag', 'uploader_url': r're:https?://(?:www\.)?youtube\.com/user/phihag', 'channel_id': 'UCLqxVugv74EIW3VWh2NOa3Q', @@ -1078,6 +1079,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor): 'description': 'md5:d0865e57701acd99b4d89679a66e9632', 'upload_date': '20200716', 'uploader': '稲葉曇', + 'channel': 'inabakumori', 'uploader_id': 'UCNElM45JypxqAR73RoUQ10g', 'uploader_url': r're:https?://(?:www\.)?youtube\.com/channel/UCNElM45JypxqAR73RoUQ10g', }, @@ -1914,7 +1916,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor): info['channel'] = get_text(try_get( vsir, lambda x: x['owner']['videoOwnerRenderer']['title'], - compat_str)) + dict)) rows = try_get( vsir, lambda x: x['metadataRowContainer']['metadataRowContainerRenderer']['rows'],