From 62cb64cbb3df03c669c47ee3255fd96453435103 Mon Sep 17 00:00:00 2001 From: kclauhk <78251477+kclauhk@users.noreply.github.com> Date: Mon, 2 Jun 2025 23:24:36 +0800 Subject: [PATCH 1/3] [ie/youtube] extract translated info --- yt_dlp/extractor/youtube/_video.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/yt_dlp/extractor/youtube/_video.py b/yt_dlp/extractor/youtube/_video.py index d82225718..d79952969 100644 --- a/yt_dlp/extractor/youtube/_video.py +++ b/yt_dlp/extractor/youtube/_video.py @@ -4204,8 +4204,16 @@ def process_language(container, base_url, lang_code, sub_name, client_name, quer elif info.get('view_count') is None: info['view_count'] = vc + if self._preferred_lang: + info['title'] = traverse_obj( + vpir, ('title', 'runs', 0, 'text', {str}), default=info['title']) + vsir = get_first(contents, 'videoSecondaryInfoRenderer') if vsir: + if self._preferred_lang: + info['description'] = traverse_obj( + vsir, ('attributedDescription', 'content', {str}), default=info['description']) + vor = traverse_obj(vsir, ('owner', 'videoOwnerRenderer')) info.update({ 'channel': self._get_text(vor, 'title'), From 5ab5a6dd041d1ccf1cfa058c2b781e00c1e69463 Mon Sep 17 00:00:00 2001 From: kclauhk <78251477+kclauhk@users.noreply.github.com> Date: Fri, 6 Jun 2025 22:12:35 +0800 Subject: [PATCH 2/3] use _get_text and add test --- yt_dlp/extractor/youtube/_video.py | 38 ++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/yt_dlp/extractor/youtube/_video.py b/yt_dlp/extractor/youtube/_video.py index d79952969..6958933d6 100644 --- a/yt_dlp/extractor/youtube/_video.py +++ b/yt_dlp/extractor/youtube/_video.py @@ -1751,6 +1751,41 @@ class YoutubeIE(YoutubeBaseInfoExtractor): 'media_type': 'short', }, }, + { + 'url': 'https://www.youtube.com/watch?v=8047tcn3o5U', + 'info_dict': { + 'id': '8047tcn3o5U', + 'ext': 'mp4', + 'title': 'Rooting: Layering and Cuttings in Pots', + 'description': r're:^➤When making new plants,', + 'uploader': 'MiradasBiologicas in English', + 'uploader_id': '@Miradasbiologicas', + 'uploader_url': 'https://www.youtube.com/@Miradasbiologicas', + 'channel': 'MiradasBiologicas in English', + 'channel_id': 'UCNUwfzPMUFZYXOOCHaYnp7g', + 'channel_url': 'https://www.youtube.com/channel/UCNUwfzPMUFZYXOOCHaYnp7g', + 'channel_is_verified': True, + 'thumbnail': r're:https?://.+/.+\.(?:jpg|webp)', + 'playable_in_embed': False, + 'age_limit': 0, + 'duration': 601, + 'timestamp': 1699623740, + 'upload_date': '20231110', + 'availability': 'public', + 'live_status': 'not_live', + 'view_count': int, + 'like_count': int, + 'comment_count': int, + 'channel_follower_count': int, + 'categories': ['Howto & Style'], + 'tags': 'count:27', + 'media_type': 'video', + }, + 'params': { + 'extractor_args': {'youtube': {'lang': ['en']}}, + 'skip_download': True, + }, + }, ] _WEBPAGE_TESTS = [ @@ -4205,8 +4240,7 @@ def process_language(container, base_url, lang_code, sub_name, client_name, quer info['view_count'] = vc if self._preferred_lang: - info['title'] = traverse_obj( - vpir, ('title', 'runs', 0, 'text', {str}), default=info['title']) + info['title'] = self._get_text(vpir, 'title') or info['title'] vsir = get_first(contents, 'videoSecondaryInfoRenderer') if vsir: From 6a4f22ee75754b2ad3bea292aa9f015f19fc1c29 Mon Sep 17 00:00:00 2001 From: kclauhk <78251477+kclauhk@users.noreply.github.com> Date: Wed, 18 Jun 2025 16:13:36 +0800 Subject: [PATCH 3/3] Update yt_dlp/extractor/youtube/_video.py Co-authored-by: N/Ame <173015200+grqz@users.noreply.github.com> --- yt_dlp/extractor/youtube/_video.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yt_dlp/extractor/youtube/_video.py b/yt_dlp/extractor/youtube/_video.py index 6958933d6..230ae1732 100644 --- a/yt_dlp/extractor/youtube/_video.py +++ b/yt_dlp/extractor/youtube/_video.py @@ -1757,7 +1757,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor): 'id': '8047tcn3o5U', 'ext': 'mp4', 'title': 'Rooting: Layering and Cuttings in Pots', - 'description': r're:^➤When making new plants,', + 'description': r're:➤When making new plants,', 'uploader': 'MiradasBiologicas in English', 'uploader_id': '@Miradasbiologicas', 'uploader_url': 'https://www.youtube.com/@Miradasbiologicas',