Okay, so tweaking the renderer.php works as expected and the log file always shows track ID when a new track is loaded:
And Al's script works as expected:
Theoretically, that's all the "data" that we need, just need to figure out how to tie it all together and display it in the overlay.
There is the problem of the log file to deal with, of course. Even though verbose logging is not necessary, eventually the log file will become a problem. That's a lot of wasted cycles and space when all we need, literally, is the most recent occurence of "Spotify URI <spotify:track:xxxxxxxxxxxxxxxxxxx>" in the log. Maybe there is a way to "watch" the log file for "Spotify URI <spotify:track:", parse the track ID, dump it to a state file, and route the rest of the log file to /dev/null ?? Then, Al's script could be written to watch the state file and grab new metadata any time the trackID in the state file changes.
I bet there is a way better approach to this. I have been looking at "spotifyd", which appears to be a daemonized branch of librespot written in rust, with more "extras". From discussion I read, metadata was on the radar (and playback controls). I haven't had time to install it and play with it yet.
Code:
2024-01-24 20:44:48.414941 INFO [src/bin.rs:420] Capture finished
2024-01-24 20:44:48.420066 INFO [src/bin.rs:410] Playback finished
[2024-01-24T20:44:48Z INFO librespot_playback::player] Loading <夜にダンス> with Spotify URI <spotify:track:0RffFIV29Yb7vjGokb0e6q>
[2024-01-24T20:44:48Z INFO librespot_playback::player] <夜にダンス> (256875 ms) loaded
[2024-01-24T20:44:48Z INFO librespot::player_event_handler] Running ["/var/local/www/commandw/spotevent.sh"] with environment variables {"TRACK_ID": "0RffFIV29Yb7vjGokb0e6q", "PLAYER_EVENT": "playing", "POSITION_MS": "0", "DURATION_MS": "256875"}
2024-01-24 20:44:48.931375 INFO [src/bin.rs:711] CamillaDSP version 1.0.3
2024-01-24 20:44:48.931499 INFO [src/bin.rs:712] Running on linux, aarch64
2024-01-24 20:44:48.975094 INFO [src/alsadevice.rs:161] Starting playback from Prepared state
[2024-01-24T20:45:07Z INFO librespot::player_event_handler] Running ["/var/local/www/commandw/spotevent.sh"] with environment variables {"OLD_TRACK_ID": "0RffFIV29Yb7vjGokb0e6q", "TRACK_ID": "14f6jZAEm43fqsrrZpYVeT", "PLAYER_EVENT": "changed"}
no pid file present!
ALSA lib libasound_module_pcm_cdsp.c:869:(cdsp_hw_free) Error executing camilla_exit_cmd /usr/local/bin/cdspstorevolume
2024-01-24 20:45:08.554882 INFO [src/bin.rs:420] Capture finished
2024-01-24 20:45:10.642460 INFO [src/bin.rs:410] Playback finished
[2024-01-24T20:45:10Z INFO librespot_playback::player] Loading <Ones And Zeros> with Spotify URI <spotify:track:14f6jZAEm43fqsrrZpYVeT>
[2024-01-24T20:45:11Z INFO librespot_playback::player] <Ones And Zeros> (267360 ms) loaded
[2024-01-24T20:45:11Z INFO librespot::player_event_handler] Running ["/var/local/www/commandw/spotevent.sh"] with environment variables {"DURATION_MS": "267360", "PLAYER_EVENT": "playing", "TRACK_ID": "14f6jZAEm43fqsrrZpYVeT", "POSITION_MS": "0"}
2024-01-24 20:45:11.091851 INFO [src/bin.rs:711] CamillaDSP version 1.0.3
2024-01-24 20:45:11.092328 INFO [src/bin.rs:712] Running on linux, aarch64
2024-01-24 20:45:11.175354 INFO [src/alsadevice.rs:161] Starting playback from Prepared state
And Al's script works as expected:
Code:
moode@moode:~ $ ./metaspot.sh 5qhGBRamxnwW6peITFjCPo
Artist: Barney Bentall
Album : Gift Horse
Track : 4 - Too Good To Be True (3:33)
Cover : https://i.scdn.co/image/ab67616d0000b273033f8bf880436443b7cc3074
Theoretically, that's all the "data" that we need, just need to figure out how to tie it all together and display it in the overlay.
There is the problem of the log file to deal with, of course. Even though verbose logging is not necessary, eventually the log file will become a problem. That's a lot of wasted cycles and space when all we need, literally, is the most recent occurence of "Spotify URI <spotify:track:xxxxxxxxxxxxxxxxxxx>" in the log. Maybe there is a way to "watch" the log file for "Spotify URI <spotify:track:", parse the track ID, dump it to a state file, and route the rest of the log file to /dev/null ?? Then, Al's script could be written to watch the state file and grab new metadata any time the trackID in the state file changes.
I bet there is a way better approach to this. I have been looking at "spotifyd", which appears to be a daemonized branch of librespot written in rust, with more "extras". From discussion I read, metadata was on the radar (and playback controls). I haven't had time to install it and play with it yet.