Skip to content

get_playlist() crashes on OLAK chart playlists without album info #853

@guillevc

Description

@guillevc

Description

get_playlist() crashes with TypeError: 'NoneType' object is not subscriptable when fetching OLAK playlists that don't have album info on all tracks (e.g., chart/trending playlists).

Reproduction

Library version: 1.11.5

Steps:

from ytmusicapi import YTMusic
ytm = YTMusic()
playlist = ytm.get_playlist("OLAK5uy_mzYnlaHgFOvLaxqIPnnouEr-idiUn4NIM")  # Trending 20 Spain

Error:

TypeError: 'NoneType' object is not subscriptable
  File "ytmusicapi/parsers/playlists.py", line 122, in parse_audio_playlist
    playlist["title"] = playlist["tracks"][0]["album"]["name"]

Root Cause

parse_audio_playlist() assumes all OLAK playlists are album playlists where every track has album info. However, chart playlists like "Trending 20 Spain" use the OLAK prefix but contain music videos (OMVs) without album info.

Proposed Fix

Make parse_audio_playlist() return None when not all tracks have album info, allowing the caller to fall back to regular playlist parsing.

I have a fix ready and will submit a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions