Skip to content

Apple Music: date_added never populated for library playlists (and albums) — "recently added" sort is wrong #6349

Description

@chrisbeams-ops

Before you begin

What happened?

What happened?

Sorting the library by "recently added" does not work for Apple Music. Every playlist gets its Music Assistant import time as timestamp_added instead of the date it was actually added to the Apple Music library, so the order is meaningless (it degrades to alphabetical / import-batch order).

Apple does expose the data. Calling the same endpoint MA uses, with the documented extend parameter, returns dateAdded on library playlists:

GET https://amp-api.music.apple.com/v1/me/library/playlists?extend=dateAdded
→ "Billie Eilish Essentials": { "dateAdded": "2024-02-25T15:01:08Z", ... }

dateAdded is a documented LibraryPlaylists attribute, marked not-required, so it is only returned when requested via extend. (Playlists added before ~2016 legitimately have no dateAdded — those are unavoidable.) The same gap affects library albums (me/library/albums also supports extend=dateAdded).

What I already tried (to save you the dead ends)

On 2.10.2 I patched the provider locally:

  1. Added extend="dateAdded" to the me/library/playlists and me/library/albums requests in providers/apple_music/library.py.
  2. Added a _set_date_added() helper (mirroring the Tidal provider) reading item["attributes"]["dateAdded"] into media_item.date_added, for each yielded playlist/album.

get_library_playlists() then yields playlists with date_added set correctly — but the value is still lost by the time the row is written: a removed + re-synced playlist comes back with today's timestamp, not its real dateAdded.

Tracing it: MusicController.add_item_to_library() re-fetches the item via get_item()provider.get_playlist()_get_regular_playlist(), which never sets date_added (and for hasCatalog/editorial playlists reads the catalog endpoint, which has no dateAdded at all). So the date_added the sync generator set is discarded on the re-fetch.

  1. I then patched add_item_to_library() to carry the caller's date_added onto the re-fetched item. It still comes back insert-time — so the value is dropped at a further point I could not pin from outside the running process.

Also: for existing rows, _library_item_needs_update() doesn't treat a date_added change as update-worthy, so a normal re-sync never backfills dates onto playlists already in the library.

How to reproduce

Music Assistant version

2.10.2 (Home Assistant add-on, Python 3.14)

How to reproduce

  1. Add the Apple Music provider, let the library sync.
  2. Sort the playlist library by "recently added".
  3. Order reflects sync/import time, not Apple's dateAdded. Confirm via the API call above that Apple returns real, differing dateAdded values for the same playlists.

Music Assistant version

2.10.2 (Home Assistant add-on, Python 3.14)

How do you run Music Assistant?

Home Assistant add-on

Diagnostics report or log file

music-assistant-diagnostics-2026-09-06-130515.json

Anything else?

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions