Skip to content

Commit

Permalink
get_playlist: fix artists for unnoficial videos (#627)
Browse files Browse the repository at this point in the history
  • Loading branch information
czifumasa authored and sigma67 committed Jul 23, 2024
1 parent 14417db commit 40ff2b4
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions ytmusicapi/parsers/playlists.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,13 @@ def parse_playlist_item(
if "musicItemRendererDisplayPolicy" in data:
isAvailable = data["musicItemRendererDisplayPolicy"] != "MUSIC_ITEM_RENDERER_DISPLAY_POLICY_GREY_OUT"

# For unavailable items indexes are preset,
# because meaning of the flex column cannot be found using navigationEndpoint
title_index = 0 if isAvailable is False else None
artist_index = 1 if isAvailable is False else None
album_index = 2 if isAvailable is False else None
# For unavailable items and for album track lists indexes are preset,
# because meaning of the flex column cannot be reliably found using navigationEndpoint
use_preset_columns = True if isAvailable is False or is_album is True else None

title_index = 0 if use_preset_columns else None
artist_index = 1 if use_preset_columns else None
album_index = 2 if use_preset_columns else None
user_channel_indexes = []
unrecognized_index = None

Expand All @@ -114,7 +116,8 @@ def parse_playlist_item(
navigation_endpoint = nav(flex_column_item, [*TEXT_RUN, "navigationEndpoint"], True)

if not navigation_endpoint:
unrecognized_index = index if unrecognized_index is None else unrecognized_index
if nav(flex_column_item, TEXT_RUN_TEXT, True) is not None:
unrecognized_index = index if unrecognized_index is None else unrecognized_index
continue

if "watchEndpoint" in navigation_endpoint:
Expand Down

0 comments on commit 40ff2b4

Please sign in to comment.