Skip to content

Commit

Permalink
Fix the test for GoPro extractor.
Browse files Browse the repository at this point in the history
gopro.com returns empty string as author/track for some videos; consider
such attributes to be missing.

Signed-off-by: Alexey Neyman <stilor@att.net>
  • Loading branch information
stilor committed Jan 18, 2024
1 parent fb3f9f7 commit 5687be1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions yt_dlp/extractor/gopro.py
Expand Up @@ -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<id>[A-Za-z0-9]+)'

Expand Down Expand Up @@ -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')),
}

0 comments on commit 5687be1

Please sign in to comment.