A feature-rich command-line audio/video downloader
[ie/youtube] Fix auto-generated metadata extraction (#13896)
TheQWERTYCodra56217f9f6c5
diff --git a/yt_dlp/extractor/youtube/_video.py b/yt_dlp/extractor/youtube/_video.pyindex 01398cb65f..e7b8e2d5a2 100644--- a/yt_dlp/extractor/youtube/_video.py+++ b/yt_dlp/extractor/youtube/_video.py@@ -1556,6 +1556,46 @@ class YoutubeIE(YoutubeBaseInfoExtractor):'view_count': int,},'params': {'skip_download': True},+ }, {+ # Youtube Music Auto-generated description with dot in artist name+ 'url': 'https://music.youtube.com/watch?v=DbCvuSGfR3Y',+ 'info_dict': {+ 'id': 'DbCvuSGfR3Y',+ 'ext': 'mp4',+ 'title': 'Back Around',+ 'artists': ['half·alive'],+ 'track': 'Back Around',+ 'album': 'Conditions Of A Punk',+ 'release_date': '20221202',+ 'release_year': 2021,+ 'alt_title': 'Back Around',+ 'description': 'md5:bfc0e2b3cc903a608d8a85a13cb50f95',+ 'media_type': 'video',+ 'uploader': 'half•alive',+ 'channel': 'half•alive',+ 'channel_id': 'UCYQrYophdVI3nVDPOnXyIng',+ 'channel_url': 'https://www.youtube.com/channel/UCYQrYophdVI3nVDPOnXyIng',+ 'channel_is_verified': True,+ 'channel_follower_count': int,+ 'comment_count': int,+ 'view_count': int,+ 'like_count': int,+ 'age_limit': 0,+ 'duration': 223,+ 'thumbnail': 'https://i.ytimg.com/vi_webp/DbCvuSGfR3Y/maxresdefault.webp',+ 'heatmap': 'count:100',+ 'categories': ['Music'],+ 'tags': ['half·alive', 'Conditions Of A Punk', 'Back Around'],+ 'creators': ['half·alive'],+ 'timestamp': 1669889281,+ 'upload_date': '20221201',+ 'playable_in_embed': True,+ 'availability': 'public',+ 'live_status': 'not_live',+ },+ 'params': {+ 'skip_download': True,+ },}]_WEBPAGE_TESTS = [{# <object>@@ -4008,20 +4048,14 @@ class YoutubeIE(YoutubeBaseInfoExtractor):# Youtube Music Auto-generated descriptionif (video_description or '').strip().endswith('\nAuto-generated by YouTube.'):- # XXX: Causes catastrophic backtracking if description has "·"- # E.g. https://www.youtube.com/watch?v=DoPaAxMQoiI- # Simulating atomic groups: (?P<a>[^xy]+)x => (?=(?P<a>[^xy]+))(?P=a)x- # reduces it, but does not fully fix it. https://regex101.com/r/8Ssf2h/2mobj = re.search(r'''(?xs)- (?=(?P<track>[^\n·]+))(?P=track)·- (?=(?P<artist>[^\n]+))(?P=artist)\n+- (?=(?P<album>[^\n]+))(?P=album)\n- (?:.+?℗\s*(?P<release_year>\d{4})(?!\d))?- (?:.+?Released\ on\s*:\s*(?P<release_date>\d{4}-\d{2}-\d{2}))?- (.+?\nArtist\s*:\s*- (?=(?P<clean_artist>[^\n]+))(?P=clean_artist)\n- )?.+\nAuto-generated\ by\ YouTube\.\s*$+ (?:\n|^)(?P<track>[^\n·]+)\ ·\ (?P<artist>[^\n]+)\n++ (?P<album>[^\n]+)\n++ (?:℗\s*(?P<release_year>\d{4}))?+ (?:.+?\nReleased\ on\s*:\s*(?P<release_date>\d{4}-\d{2}-\d{2}))?+ (?:.+?\nArtist\s*:\s*(?P<clean_artist>[^\n]+)\n)?+ .+\nAuto-generated\ by\ YouTube\.\s*$''', video_description)if mobj:release_year = mobj.group('release_year')@@ -4033,7 +4067,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):info.update({'album': mobj.group('album'.strip()),'artists': ([a] if (a := mobj.group('clean_artist'))- else [a.strip() for a in mobj.group('artist').split('·')]),+ else [a.strip() for a in mobj.group('artist').split(' · ')]),'track': mobj.group('track').strip(),'release_date': release_date,'release_year': int_or_none(release_year),