Skip to content

Commit

Permalink
parse_playlist_items: only add track_position for albums
Browse files Browse the repository at this point in the history
  • Loading branch information
jcbirdwell committed Jan 11, 2024
1 parent 3aa5227 commit 9d65913
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions ytmusicapi/parsers/playlists.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ def parse_playlist_items(results, menu_entries: Optional[List[List]] = None, is_
True,
)

track_position = None
if is_album:
track_pos_found = nav(data, ["index", "runs", 0, "text"], True)
track_position = track_pos_found if track_pos_found is None else int(track_pos_found)

song = {
"videoId": videoId,
"title": title,
Expand All @@ -96,9 +91,12 @@ def parse_playlist_items(results, menu_entries: Optional[List[List]] = None, is_
"isExplicit": isExplicit,
"videoType": videoType,
"views": views,
"track_position": track_position,
}

if is_album:
track_pos_found = nav(data, ["index", "runs", 0, "text"], True)
song["track_position"] = track_pos_found if track_pos_found is None else int(track_pos_found)

if duration:
song["duration"] = duration
song["duration_seconds"] = parse_duration(duration)
Expand Down

0 comments on commit 9d65913

Please sign in to comment.