From 5687be1987e5e93448a59c9716135fb8f36f1946 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Wed, 17 Jan 2024 22:11:26 -0800 Subject: [PATCH] Fix the test for GoPro extractor. gopro.com returns empty string as author/track for some videos; consider such attributes to be missing. Signed-off-by: Alexey Neyman --- yt_dlp/extractor/gopro.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/yt_dlp/extractor/gopro.py b/yt_dlp/extractor/gopro.py index e091091979f..8a635593eb7 100644 --- a/yt_dlp/extractor/gopro.py +++ b/yt_dlp/extractor/gopro.py @@ -3,12 +3,20 @@ int_or_none, remove_end, str_or_none, + strip_or_none, try_get, unified_timestamp, url_or_none, ) +# gopro.com returns empty string as author/track for some video. Treat it as +# if it were null. +def nonempty_or_none(s): + v = strip_or_none(s) + return None if v == '' else v + + class GoProIE(InfoExtractor): _VALID_URL = r'https?://(www\.)?gopro\.com/v/(?P[A-Za-z0-9]+)' @@ -98,8 +106,8 @@ def _real_extract(self, url): try_get(metadata, lambda x: x['account']['nickname'])), 'duration': int_or_none( video_info.get('source_duration')), - 'artist': str_or_none( + 'artist': nonempty_or_none( video_info.get('music_track_artist')), - 'track': str_or_none( + 'track': nonempty_or_none( video_info.get('music_track_name')), }