Try to match the exact title and artist/album first (case-insensitive via StringQuery),
only then fall back to the previous substring matching.
This helps in cases where multiple variants of a song with distinct listen counts exist, like "Song" and "Song (inst.)" or "Song (Japanese ver.)".
This commit stops "Song" from also updating those separate variants if an exact match of "Song" exists.
Nonetheless, if the library only has an item named "Song (feat. Artist)", "Song" will still update its play count through the substring match.
The query was previously written as `(title && artist) || (title && album)`, which is distributively the same as `title && (artist || album)`.
Rewriting it clarifies the intent, where the title must match and the artist or album confirms the match.
Previously, all matchers were simply OR'd together, so the preference for MBID matches stated in the comments wasn't really applied.
Instead, listens with an MBID match could also update tracks with a different MBID, just because they had a substring match on their title.
For example, a listen for "Song" would also update play counts for "Song (inst.)", even though the library already contained "Song" with the listen's exact MBID and the instrumental has a different one.
Rewrite the plugin around Plex' PIN authentication flow: running
`beet plexupdate --auth` opens a browser window and stores the
obtained token together with a generated client identifier in a
token file (`plex_token.json`) next to the beets configuration.
- add a PlexSession (based on TimeoutAndRetrySession) that handles
token persistence, plex.tv PIN polling, and attaching the token to
local server requests
- look up the music library section through the JSON API instead of
parsing XML
- refresh the Plex library once, at the end of commands that changed
the library; report missing sections and 401 responses clearly
instead of failing silently
- deprecate the manual `token` configuration option in favor of the
interactive login
TrackInfo expects the converted ISO 8601 duration in its length
field. The plugin passed it as duration instead, which TrackInfo
silently stores as a flexible attribute while length stays None, so
Tidal candidates were matched without any track-length distance.
Pass the duration as length and update the parsing tests to assert
info.length instead of the incorrect info.duration flex field.
When `beet import -W` (--nowrite) is run with the scrub plugin
enabled (auto=True), the plugin was scrubbing (removing) tags even
though --nowrite means "don't write to files". This caused tags
to be lost.
The fix adds a guard at the start of import_task_files to skip
the entire scrub operation when should_write() returns False,
making the scrub plugin respect the --nowrite flag like other
plugins do.
Fixes#6958