It looks like the expected behavior of Sonic Sage is that when it gets a list of songs, it first searches personal libraries for a matching track, and if not found, goes to Tidal. However, there seems to be a small bug when the track title matches the album title, causing the Tidal version of the track being added to the playlist instead. Not a huge deal, but it does result in things like the play count of the personal track not increasing, and the track not being added to the library’s play history.
A couple examples:
Green Day’s American Idiot:
Entire album exists in my music library:
“Create a playlist starting with Green Day’s American Idiot” results in the Tidal track being added:
“Create a playlist starting with Green Day’s Holiday” results in the local track being added:
Yellocard’s Ocean Avenue:
“Create a playlist starting with Yellowcard’s Ocean Avenue” adds from Tidal:
“Create a playlist starting with Yellocard’s Only One” adds the personal track:
I tried this with a couple other title tracks that I knew off the top of my head, and saw the same behavior with all of them.
Is there something specific about title tracks that would make the results from the server take longer? Because from everything I’ve seen so far (admittedly only a dozen or so attempts), it always returns Tidal tracks for title tracks that I own, and never returns Tidal tracks for non-title tracks on my server. I would have expected a more even race.
It’s even more obvious with prompts like “Create a playlist with all the songs from Yellowcard’s Ocean Avenue”, which results in all but the title track being pulled from my server (not a very good use of AI resources, but good for showcasing this ~consistent behavior):
Since it sounds like this isn’t actually a bug, is changing the race behavior something that would ever be considered? I personally wouldn’t mind waiting a few more seconds during playlist creation to guarantee that my own tracks always trump Tidal results, but maybe I’m in the minority there.
Not that I know of. You can enter “Green Day American Idiot” e.g. in the search bar in web or Plexamp and see if your library results take longer. Optimizing your database can help. Not having a massive library can help.
Circling back here since I had some more time to dig into things, and I think it’s more than just a race. What seems to actually be the problem is that when searching my local server for title tracks, the track results don’t prioritize the track title match, instead showing all tracks from that album in a seemingly arbitrary (but consistent) order. E.g., in the following log snippet:
18:08:25.222 [Javascript] INFO - GPT: Issuing request for 'Create a playlist starting with Green Day's American Idiot' in language English with model gpt-3.5-turbo.
18:08:25.223 [0x00021ef8] DEBUG - Networking: Create request 269: (POST https://api.openai.com/v1/chat/completions).
18:08:29.342 [0x00021ef8] DEBUG - Networking: Create request 270: (GET https://music.provider.plex.tv/hubs/search?query=Green%20Day%20American%20Idiot&excludeFields=summary&limit=11).
18:08:29.347 [0x00021ef8] DEBUG - Networking: Create request 271: (GET https://192-168-1-2.XXX.plex.direct:32400/hubs/search?query=Green%20Day%20American%20Idiot&excludeFields=summary&limit=11&includeCollections=1&contentDirectoryID=11&includeFields=thumbBlurHash&X-Plex-Device-Name=XXX).
18:08:29.405 [0x000225bc] DEBUG - Networking: Completed request 271: (GET https://192-168-1-2.XXX.plex.direct:32400/hubs/search?query=Green%20Day%20American%20Idiot&excludeFields=summary&limit=11&includeCollections=1&contentDirectoryID=11&includeFields=thumbBlurHash&X-Plex-Device-Name=XXX) with code 200 (have 18924 bytes) in 53 ms.
18:08:29.407 [Javascript] INFO - GPT: Matched [green day - american idiot] with catalog result [green day - boulevard of broken dreams] with with distance 0.42105263157894735.
18:08:29.657 [0x000225bc] DEBUG - Networking: Completed request 270: (GET https://music.provider.plex.tv/hubs/search?query=Green%20Day%20American%20Idiot&excludeFields=summary&limit=11) with code 200 (have 38367 bytes) in 310 ms.
18:08:29.659 [Javascript] INFO - GPT: Matched [green day - american idiot] with catalog result [green day - boulevard of broken dreams] with with distance 0.42105263157894735.
18:08:29.659 [Javascript] INFO - GPT: Matched [green day - american idiot] with catalog result [green day - american idiot] with with distance 1.
18:08:29.666 [Javascript] INFO - GPT: Search complete for 'Green Day - American Idiot' with result true.
The server request comes back in 53 ms, and in 2ms Plexamp looks at the first track result (“boulevard of broken dreams”) and assigns it a match score (0.42). ~250ms later, the music.provider.plex.tv results comes in, and it correctly returns the title track as the first result, so it’s given a perfect score and is chosen over the local result.
May 12, 2023 22:12:20.194 [0x0e71b000] DEBUG - Networking: Completed request 118851: (GET https://10-0-0-xxx:32400/hubs/search?query=Green%20Day%20American%20Idiot&excludeFields=summary&limit=11&includeCollections=1&contentDirectoryID=1224&includeFields=thumbBlurHash&X-Plex-Device-Name=Mac%20Pro) with code 200 (have 16294 bytes) in 34 ms.
May 12, 2023 22:12:20.196 [Javascript] INFO - GPT: Matched [green day - american idiot] with catalog result [green day - american idiot] with with distance 1.
May 12, 2023 22:12:20.547 [0x0e71b000] DEBUG - Networking: Completed request 118850: (GET https://music.provider.plex.tv/hubs/search?query=Green%20Day%20American%20Idiot&excludeFields=summary&limit=11) with code 200 (have 38367 bytes) in 387 ms.
May 12, 2023 22:12:20.549 [Javascript] INFO - GPT: Search complete for 'Green Day - American Idiot' with result true.
The order the hubs are returned doesn’t matter, it looks for track hubs:
Visual representation from the Plexamp search results:
Edit: And as another data point, swapping the order from ‘Green Day American Idiot’ to ‘American Idiot Green Day’ results in the track title moving up to the first position again:
Possibly something up with the metadata on that track? Or server database issue. I would check the metadata in the web app as well as optimizing the database.
I optimized the database beforehand (and ran through ChuckPa’s DB repair tool) on the hunch that maybe some search indexing was going wrong, but the behavior was the same before and after. I rechecked and refreshed metadata for a few albums (and everything had already been run through MusicBrainz) and nothing seemed off, and I got the same results.
I dug deeper, and at least figured out why the returned tracks were seemingly random, but consistent. It looks like exact title matches are first, and after that, the following query is run to find close matches, which outputs items based on their view count:
select distinct metadata_items.id
from metadata_items
join metadata_items as parents on parents.id=metadata_items.parent_id
join metadata_items as grandparents on grandparents.id=parents.parent_id
join fts4_metadata_titles_icu on metadata_items.id=fts4_metadata_titles_icu.rowid
join media_items on media_items.metadata_item_id=metadata_items.id
join media_parts on media_parts.media_item_id=media_items.id
left join metadata_item_settings on metadata_item_settings.guid=metadata_items.guid and metadata_item_settings.account_id= 1
where
fts4_metadata_titles_icu.title_sort match 'Yellowcard* Ocean* Avenue*'
and metadata_items.library_section_id in (11)
and metadata_items.metadata_type=10
order by
metadata_item_settings.view_count desc,
grandparents.title_sort collate icu_root asc,
parents.title_sort collate icu_root asc,
parents.year asc,
metadata_items.absolute_index asc,
metadata_items.`index` asc,
metadata_items.title_sort collate icu_root asc,
metadata_items.id asc
limit 30;
The metadata ids that the query above outputs is the same order that the tracks appear in Plex/Plexamp search. If I briefly bump up the play count of the title track, then it appears first in the list.
That doesn’t necessarily explain why ‘Ocean Avenue Yellowcard’ results in the ‘Ocean Avenue’ track getting a higher score (0.71) than ‘Yellowcard Ocean Avenue’ (0.31, the same as all the other album tracks). My only wild speculation is that there’s some logic that says “the search query starts with the track title, so I’ll bump it up the list,” but not “the track title is a substring of the search query, so I’ll bump it up the list.”