Rigellute / spotify-tui

Spotify for the terminal written in Rust 🚀
MIT License
17.34k stars 518 forks source link

Wrong title in command line when changing tracks #791

Open nacht-falter opened 3 years ago

nacht-falter commented 3 years ago

When I change songs via the command line without UI, e.g. like this spt p --name monolake --artist the new track is played correctly, but sometimes the title of the track that has been playing before is printed to the terminal. It's not consistent though as this terminal output shows:

$ spt p --name monolake --artist
▶ Reminiscence - Monolake                   # correct
$ spt p --name muse --artist
▶ Reminiscence - Monolake                   # wrong
$ spt pb -t
⏸ Uprising - Muse                          # correct
$ spt p --name infinite\ snow --track 
☆ ▶ Infinite Snow - Monolake                # correct
$ spt p --name uprising --track
▶ Uprising - Muse                           # correct
$ spt p --name infinite\ snow --track
☆ ▶ Infinite Snow - Monolake                # correct 
$ spt p --name uprising --track
☆ ▶ Infinite Snow - Monolake                # wrong

(I am running spotify-tui 0.23.0 on macOS)

OrangeFran commented 3 years ago

This also caught my attention but I never bothered to fix it, sorry :/ I think spotify just needs some time to process and update the playback when we send a change song request. I tried waiting half a second with std::thread::sleep before querying the status and it seems that it displays the playback status consistently now, though it's probably not a good solution. Let me know if you find something better, else I'll open a pr.

Edit: https://github.com/Rigellute/spotify-tui/compare/master...OrangeFran:fix_song_status

nacht-falter commented 3 years ago

Looks good. Thx!