fix #650: playlists without track count in metadata now return trackCount=None

This commit is contained in:
sigma67 2024-10-05 10:44:11 +02:00
commit e433b22231
No known key found for this signature in database
2 changed files with 4 additions and 4 deletions

View file

@ -54,7 +54,7 @@ class TestPlaylists:
assert playlist["owned"] is False
playlist = yt_oauth.get_playlist("RDATgXd-")
assert playlist["trackCount"] >= 100
assert playlist["trackCount"] is None # playlist has no trackCount
assert len(playlist["tracks"]) >= 100
playlist = yt_oauth.get_playlist("PLj4BSJLnVpNyIjbCWXWNAmybc97FXLlTk", limit=None, related=True)

View file

@ -151,9 +151,9 @@ class PlaylistsMixin(MixinProtocol):
song_count_text = second_subtitle_runs[has_views + 0]["text"]
song_count_search = re.findall(r"\d+", song_count_text)
# extract the digits from the text, return 0 if no match
song_count = to_int("".join(song_count_search)) if song_count_search is not None else 0
song_count = to_int("".join(song_count_search)) if song_count_search is not None else None
else:
song_count = len(section_list["contents"])
song_count = None
playlist["trackCount"] = song_count
@ -278,7 +278,7 @@ class PlaylistsMixin(MixinProtocol):
:param title: Optional. New title for the playlist
:param description: Optional. New description for the playlist
:param privacyStatus: Optional. New privacy status for the playlist
:param moveItem: Optional. Move one item before another. Items are specified by setVideoId, which is the
:param moveItem: Optional. Move one item before another. Items are specified by setVideoId, which is the
unique id of this playlist item. See :py:func:`get_playlist`
:param addPlaylistId: Optional. Id of another playlist to add to this playlist
:param addToTop: Optional. Change the state of this playlist to add items to the top of the playlist (if True)