michaelherger / lms-plugin-tidal

A TIDAL plugin to integrate with the Lyrion Music Server (fka. Logitech Media Server)
40 stars 7 forks source link

missing "now playing" values on screensaver #70

Open chaseadam opened 3 months ago

chaseadam commented 3 months ago

I am calling the plugin using the very handy tidal: and https://listen.tidal.com protocol handlers like so:

curl 'http://127.0.0.1:9002/jsonrpc.js' -X POST --data-raw '{"id":1,"method":"slim.request","params":["00:04:20:06:XX:XX",["playlist","play","tidal://album:55163258"]]}'

All of the track information is present when inspecting details when browsing with the remote and in in LMS, but the "now playing: " only on the "now playing" screensaver is blank if I have not started the song from the Tidal app in LMS before. If I start the song, then it will always display the screensaver now playing value correctly.

I can replicate this down to individual tracks within an album.

I believe this has something to do with how the plugin syncs/stores the values of the tracks. Maybe there is a specific value used by the screensaver which is not populating via the protocol handler pathway?

I noted that current title from status command is empty when playing the tracks with missing values

Using my freshly fixed SB3 with this fantastic plugin. Very impressed with completeness and polish!

michaelherger commented 3 months ago

Are you saying this was a problem with the SB3's Now Playing screensaver only? The web UI would show the track information? Can you share a "screenshot"?

chaseadam commented 3 months ago

Yep only the screensaver while playing (not sure if that is the same as "now playing screensaver"

this is the experience going through tidal://album:55163258

I have previously "played" the first two tracks individually using the process below so they are populated, but track 3 and beyond are not

https://github.com/michaelherger/lms-plugin-tidal/assets/333031/ada62be8-7d8e-44da-bdbe-68543fd83624

Then I go through this process to "populate" the "screensaver now playing" value: Screenshot 2024-04-02 at 10-34-51 Logitech Media Server Screenshot 2024-04-02 at 10-34-58 Logitech Media Server Screenshot 2024-04-02 at 10-35-11 Logitech Media Server

press "play" icon (which replaces the playlist)

retrigger the album play with URI via API:

curl 'http://127.0.0.1:9002/jsonrpc.js' -X POST --data-raw '{"id":1,"method":"slim.request","params":["00:04:20:06:XX:XX",["playlist","play","tidal://album:55163258"]]}'

The value is populated:

https://github.com/michaelherger/lms-plugin-tidal/assets/333031/7d2a906d-86e0-4736-ac3b-9b0e0e5170d3

Could be red herring, but I believe this value may be tied to the current_title value I get with status request. When value is empty vs populated:

➜  curl --silent 'http://127.0.0.1:9002/jsonrpc.js' -X POST --data-raw '{"id":1,"method":"slim.request","params":["00:04:20:06:ac:22",["status","-","-1","tags:uB"]]}' | jq .result.current_title
""
➜  curl --silent 'http://127.0.0.1:9002/jsonrpc.js' -X POST --data-raw '{"id":1,"method":"slim.request","params":["00:04:20:06:ac:22",["status","-","-1","tags:uB"]]}' | jq .result.current_title
"I'm Only Sleeping (Remastered 2009)"
michaelherger commented 3 months ago

Your SB isn't synced with another player, is it?

Please enable debug logging for plugin.tidal, reproduce the issue, then send me a copy of the resulting server.log.zip to https://www.dropbox.com/request/T3RctyzGgNg0oFDubq6a (Settings/Advanced/Logging)

chaseadam commented 3 months ago

not synced

uploaded logs. I ran through the procedure in the last few minutes after 16:50 in the logs:

michaelherger commented 3 months ago

Trying to reproduce this... what screensaver are you using? I'm seeing SaverSwitcher is involved. Could you please go back to just the default Now Playing screensaver. Is the behaviour the same?

From the log I'm not seeing what I hoped I'd see. How technical are you? Would you be able to modify one of the source files to try something out?

chaseadam commented 3 months ago

I am technical, but I do not have much perl experience. I definitely do some guided modifications.

This is the "now playing" value which pops up for a brief period when "screensaver while playing" is active. Note that this triggers when the track changes (either due to track end and next track on playlist or track change via API).

The video is of the "spectrum analyzer" value of "screensaver while playing": image

When using the "now playing" value of "screensaver while playing" the value is correct.

Even with the "spectrum analyzer" screensaver active and showing an "empty" value, you can also see in the video a very brief view of the "now playing" screen which appears to be correct. See second 6-10 of the video:

https://github.com/michaelherger/lms-plugin-tidal/assets/333031/7d2a906d-86e0-4736-ac3b-9b0e0e5170d3

More red herring research: Have noted previously that the network payload to the device is different for the "empty" values and I included the network.jsonrpc debug. The "status" response values are different (specifically the "current_title" is empty). Why it is empty appears to be the cache is loading differently if played via an "album" playlist vs direct track play causing the missing "current_title" the status payload.

Here is a reference which only adds the current_title to a Jive request (I see other references to Jive in issues which makes me think it is related, but I am using a SB3...) if certain values are present: https://github.com/LMS-Community/slimserver/blob/5630727fbeb277f6fa2fa0cf042c9adc2662cecc/Slim/Control/Queries.pm#L4680 A few other references to current_title in that file as well: https://github.com/LMS-Community/slimserver/blob/5630727fbeb277f6fa2fa0cf042c9adc2662cecc/Slim/Control/Queries.pm#L4697 https://github.com/LMS-Community/slimserver/blob/5630727fbeb277f6fa2fa0cf042c9adc2662cecc/Slim/Control/Queries.pm#L1235

michaelherger commented 3 months ago

Can you please confirm the default Now Playing screen saver would behave the same?

chaseadam commented 3 months ago

When using the "now playing" setting for "screensaver while playing" the value is correct.

michaelherger commented 3 months ago

I'm sorry, this has to wait. This seems to be a rather exotic issue (legacy players only, specific screensaver only, TIDAL only(?), when adding tracks over JSON/RPC only). I'm not even sure whether this is a TIDAL or an LMS issue.

I have to prioritise other work. Please ping me again once the Lyrion transition has settled. Thanks for your understanding!

chaseadam commented 3 months ago

No worries, I understand the priority. Some additional research I did via the logs (this is the first I saw of the logs).

I note that the Slim::Schema::RemoteTrack::setAttributes value for track when playing for the first time via passing album URI to API is different and there is a schema error for tracks which don't show the title:

 [24-04-03 12:00:08.0108] Slim::Schema::RemoteTrack::get (453) tidal://55163264.mp4, title->* undefined value *
<play track as part of album triggered with album URI passed via API>
[24-04-03 12:00:08.0100] Slim::Web::JSONRPC::requestMethod (398) requestMethod([
  "00:04:20:06:ac:22",
  ["status", "-", 1, "tags:cgAABbehldiqtyrSSuoKLNJ"],
])
[24-04-03 12:00:08.0101] Slim::Web::JSONRPC::requestMethod (424) Parsing command: Found client [00:04:20:06:ac:22]
[24-04-03 12:00:08.0103] Slim::Web::JSONRPC::requestMethod (473) Dispatching...
[24-04-03 12:00:08.0108] Slim::Schema::RemoteTrack::get (453) tidal://55163264.mp4, title->* undefined value *
[24-04-03 12:00:08.0119] Slim::Web::JSONRPC::requestWrite (525) requestWrite()
[24-04-03 12:00:08.0120] Slim::Web::JSONRPC::generateJSONResponse (368) generateJSONResponse()
[24-04-03 12:00:08.0131] Slim::Web::JSONRPC::writeResponse (299) JSON response: {
  id => 1,
  method => "slim.request",
  params => [
        "00:04:20:06:ac:22",
        ["status", "-", 1, "tags:cgAABbehldiqtyrSSuoKLNJ"],
      ],
  result => {
        can_seek                 => 1,
        current_title            => "",
...
[24-04-03 12:00:13.8131] Slim::Web::JSONRPC::writeResponse (314) JSON raw response: [{"result":{"rate":1,"current_title":"","playlist shuffle":0,"digital_volume_control":1,"power":1,"playlist_loop":[{"url":"tidal://55163264.mp4","year":"0","disc":"1","artist":"The Beatles","type":"mp4","coverid":"-93948385375840","duration":"158","title":"Yellow Submarine (Remastered 2009)","album":"Revolver (Remastered)","tracknum":"6","artwork_url":"/imageproxy/http%3A%2F%2Fresources.tidal.com%2Fimages%2F2f02e7b1%2F626c%2F4637%2F8bed%2Fffe0f46be122%2F1280x1280.jpg/image.jpg","playlist index":0,"bitrate":"320kbps","id":"-93948385375840"}],"showBriefly":["Now Playing","Yellow Submarine (Remastered 2009)"],"remoteMeta":{"id":"-93948385375840","title":"Yellow Submarine (Remastered 2009)","coverid":"-93948385375840","artist":"The Beatles","album":"Revolver (Remastered)","duration":"158","disc":"1","tracknum":"6","year":"0","bitrate":"320kbps","url":"tidal://55163264.mp4","type":"mp4","artwork_url":"/imageproxy/http%3A%2F%2Fresources.tidal.com%2Fimages%2F2f02e7b1%2F626c%2F4637%2F8bed%2Fffe0f46be122%2F1280x1280.jpg/image.jpg"},"player_name":"scratch","duration":158.94,"time":1.47442499923706,"playlist_tracks":1,"playlist_cur_index":"0","mode":"play","mixer volume":100,"player_connected":1,"signalstrength":0,"playlist mode":"off","remote":1,"can_seek":1,"playlist repeat":0,"playlist_timestamp":1712160012.19593,"player_ip":"10.0.2.100:60102","seq_no":0},"params":["00:04:20:06:ac:22",["status","-","1","tags:cgAABbehldiqtyrSSuoKLNJ"]],"method":"slim.request","id":"1"}]
[24-04-03 12:00:13.8133] Slim::Web::JSONRPC::writeResponse (351) Response headers: [
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 1483
Content-Type: application/json

]
[24-04-03 12:00:14.0809] Slim::Display::Display::curLines (503) lines Slim::Plugin::Visualizer::Plugin::screensaverLines [Slim::Display::Display::update, (eval)(265)]
[24-04-03 12:00:14.0812] Slim::Display::Display::curLines (504) {
  screen1 => {
        fonts => { "graphic-160x32" => "high", "graphic-320x32" => "high" },
        line  => ["", "Now Playing: "],
      },
}
...
<perform search>
...
[24-04-03 12:00:28.5505] Plugins::TIDAL::API::Async::__ANON__ (440) Using cache key 'tidal_resp:/search/tracks:countryCodeUS:limit100:queryyellow 2009'
[24-04-03 12:00:28.5508] Plugins::TIDAL::API::Async::__ANON__ (458) Getting /search/tracks?countryCode=US&limit=100&query=yellow+2009
[24-04-03 12:00:28.6647] Plugins::TIDAL::API::Async::__ANON__ (467) do {
  my $a = {
    items => [          
...
<play on track>
...
[24-04-03 12:00:42.3431] Slim::Music::Info::setTitle (293) Adding title Yellow Submarine (Remastered 2009) for tidal://55163264.mp4
[24-04-03 12:00:42.3434] Slim::Schema::_preCheckAttributes (2753) Report for tidal://55163264.mp4:
[24-04-03 12:00:42.3435] Slim::Schema::_preCheckAttributes (2754) * Attributes *
[24-04-03 12:00:42.3435] Slim::Schema::_preCheckAttributes (2760) .. TITLESEARCH : YELLOW SUBMARINE REMASTERED 2009
[24-04-03 12:00:42.3436] Slim::Schema::_preCheckAttributes (2760) .. YEAR : 0
[24-04-03 12:00:42.3437] Slim::Schema::_preCheckAttributes (2760) .. TITLESORT : YELLOW SUBMARINE REMASTERED 2009
[24-04-03 12:00:42.3438] Slim::Schema::_preCheckAttributes (2760) .. urlmd5 : 8d936125ed1763927b4f7120193d3321
[24-04-03 12:00:42.3438] Slim::Schema::_preCheckAttributes (2760) .. RATING : 0
[24-04-03 12:00:42.3439] Slim::Schema::_preCheckAttributes (2760) .. REMOTE : 1
[24-04-03 12:00:42.3440] Slim::Schema::_preCheckAttributes (2760) .. TITLE : Yellow Submarine (Remastered 2009)
[24-04-03 12:00:42.3441] Slim::Schema::_preCheckAttributes (2763) * Deferred Attributes *
[24-04-03 12:00:42.3441] Slim::Schema::_preCheckAttributes (2769) .. COMMENT : ARRAY(0x557215431f38)
[24-04-03 12:00:42.3443] Slim::Schema::RemoteTrack::updateOrCreate (386) tidal://55163264.mp4
[24-04-03 12:00:42.3445] Slim::Schema::RemoteTrack::setAttributes (344) tidal://55163264.mp4 => {
  RATING      => 0,
  REMOTE      => 1,
  TITLE       => "Yellow Submarine (Remastered 2009)",
  TITLESEARCH => "YELLOW SUBMARINE REMASTERED 2009",
  TITLESORT   => "YELLOW SUBMARINE REMASTERED 2009",
  YEAR        => 0,
  urlmd5      => "8d936125ed1763927b4f7120193d3321",
}
[24-04-03 12:00:42.3449] Slim::Music::Info::setCurrentTitle (548) Setting title for tidal://55163264.mp4 to Yellow Submarine (Remastered 2009)
[24-04-03 12:00:42.3481] Slim::Display::Display::showBriefly (238) caller Slim::Player::StreamingController::_playersMessage (727)
[24-04-03 12:00:42.3488] Slim::Display::Display::showBriefly (251) {
  jive => {
        duration => 30_000,
        icon => "/imageproxy/http%3A%2F%2Fresources.tidal.com%2Fimages%2F2f02e7b1%2F626c%2F4637%2F8bed%2Fffe0f46be122%2F1280x1280.jpg/image.jpg",
        text => [
              "Getting stream info...",
              "Yellow Submarine (Remastered 2009)",
            ],
        type => "song",
      },
  screen1 => {
        line => [
              "Getting stream info...",
              "Yellow Submarine (Remastered 2009)",
            ],
        overlay => undef,
      },
}
[24-04-03 12:00:42.3498] Plugins::TIDAL::API::Async::__ANON__ (458) Getting /tracks/55163264/playbackinfopostpaywall?assetpresentation=FULL&audioquality=HIGH&countryCode=US&limit=100&playbackmode=STREAM
[24-04-03 12:00:42.3508] Plugins::TIDAL::ProtocolHandler::getNextTrack (218) Getting next track playback info for tidal://55163264.mp4
...
[24-04-03 12:00:44.1790] Slim::Web::JSONRPC::writeResponse (314) JSON raw response: [{"params":["00:04:20:06:ac:22",["status","-","1","tags:cgAABbehldiqtyrSSuoKLNJ"]],"method":"slim.request","id":"1","result":{"seq_no":0,"player_ip":"10.0.2.100:58946","playlist_timestamp":1712160042.50057,"playlist repeat":0,"can_seek":1,"remote":1,"playlist mode":"off","signalstrength":0,"player_connected":1,"mode":"play","playlist_cur_index":"0","mixer volume":100,"playlist_tracks":1,"duration":158.94,"time":1.54112612533569,"player_name":"scratch","remoteMeta":{"id":"-93948385375840","title":"Yellow Submarine (Remastered 2009)","coverid":"-93948385375840","artist":"The Beatles","album":"Revolver (Remastered)","duration":"158","disc":"1","tracknum":"6","year":"0","bitrate":"320kbps","url":"tidal://55163264.mp4","type":"mp4","artwork_url":"/imageproxy/http%3A%2F%2Fresources.tidal.com%2Fimages%2F2f02e7b1%2F626c%2F4637%2F8bed%2Fffe0f46be122%2F1280x1280.jpg/image.jpg"},"showBriefly":["Now Playing","Yellow Submarine (Remastered 2009)"],"playlist_loop":[{"year":"0","disc":"1","url":"tidal://55163264.mp4","coverid":"-93948385375840","type":"mp4","artist":"The Beatles","title":"Yellow Submarine (Remastered 2009)","duration":"158","id":"-93948385375840","bitrate":"320kbps","album":"Revolver (Remastered)","tracknum":"6","artwork_url":"/imageproxy/http%3A%2F%2Fresources.tidal.com%2Fimages%2F2f02e7b1%2F626c%2F4637%2F8bed%2Fffe0f46be122%2F1280x1280.jpg/image.jpg","playlist index":0}],"power":1,"digital_volume_control":1,"playlist shuffle":0,"current_title":"Yellow Submarine (Remastered 2009)","rate":1}}]
[24-04-03 12:00:44.1791] Slim::Web::JSONRPC::writeResponse (351) Response headers: [
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 1517
Content-Type: application/json

]
[24-04-03 12:00:44.3801] Slim::Display::Display::curLines (503) lines Slim::Plugin::Visualizer::Plugin::screensaverLines [Slim::Display::Display::update, (eval)(265)]
[24-04-03 12:00:44.3804] Slim::Display::Display::curLines (504) {
  screen1 => {
        fonts => { "graphic-160x32" => "high", "graphic-320x32" => "high" },
        line  => ["", "Now Playing: Yellow Submarine (Remastered 2009)"],
      },
}

The following is an example of a never before played track from another never before played album

[24-04-03 12:12:29.5706] Slim::Schema::RemoteTrack::updateOrCreate (386) tidal://103353844.mp4
[24-04-03 12:12:29.5707] Slim::Schema::RemoteTrack::new (304) Slim::Schema::RemoteTrack, tidal://103353844.mp4
[24-04-03 12:12:29.5710] Slim::Schema::RemoteTrack::setAttributes (344) tidal://103353844.mp4 => {
  RATING => 0,
  REMOTE => 1,
  YEAR   => 0,
  url    => "tidal://103353844.mp4",
  urlmd5 => "d662db60375bc98cae948c4c3891289f",
}

I think the current_title is used by the screensaver and that value comes from a lookup of the URI in the DB and the "now playing" value comes from the playlist (which Tidal plugin is managing properly always).

The following example log shows after "search for track and play" procedure. Notably this includes a "setTitle" action (presumably triggered from Tidal plugin):

[24-04-03 12:00:42.3431] Slim::Music::Info::setTitle (293) Adding title Yellow Submarine (Remastered 2009) for tidal://55163264.mp4
[24-04-03 12:00:42.3434] Slim::Schema::_preCheckAttributes (2753) Report for tidal://55163264.mp4:
[24-04-03 12:00:42.3435] Slim::Schema::_preCheckAttributes (2754) * Attributes *
[24-04-03 12:00:42.3435] Slim::Schema::_preCheckAttributes (2760) .. TITLESEARCH : YELLOW SUBMARINE REMASTERED 2009
[24-04-03 12:00:42.3436] Slim::Schema::_preCheckAttributes (2760) .. YEAR : 0
[24-04-03 12:00:42.3437] Slim::Schema::_preCheckAttributes (2760) .. TITLESORT : YELLOW SUBMARINE REMASTERED 2009
[24-04-03 12:00:42.3438] Slim::Schema::_preCheckAttributes (2760) .. urlmd5 : 8d936125ed1763927b4f7120193d3321
[24-04-03 12:00:42.3438] Slim::Schema::_preCheckAttributes (2760) .. RATING : 0
[24-04-03 12:00:42.3439] Slim::Schema::_preCheckAttributes (2760) .. REMOTE : 1
[24-04-03 12:00:42.3440] Slim::Schema::_preCheckAttributes (2760) .. TITLE : Yellow Submarine (Remastered 2009)
[24-04-03 12:00:42.3441] Slim::Schema::_preCheckAttributes (2763) * Deferred Attributes *
[24-04-03 12:00:42.3441] Slim::Schema::_preCheckAttributes (2769) .. COMMENT : ARRAY(0x557215431f38)
[24-04-03 12:00:42.3443] Slim::Schema::RemoteTrack::updateOrCreate (386) tidal://55163264.mp4
[24-04-03 12:00:42.3445] Slim::Schema::RemoteTrack::setAttributes (344) tidal://55163264.mp4 => {
  RATING      => 0,
  REMOTE      => 1,
  TITLE       => "Yellow Submarine (Remastered 2009)",
  TITLESEARCH => "YELLOW SUBMARINE REMASTERED 2009",
  TITLESORT   => "YELLOW SUBMARINE REMASTERED 2009",
  YEAR        => 0,
  urlmd5      => "8d936125ed1763927b4f7120193d3321",
}
[24-04-03 12:00:42.3449] Slim::Music::Info::setCurrentTitle (548) Setting title for tidal://55163264.mp4 to Yellow Submarine (Remastered 2009)