flecs icon indicating copy to clipboard operation
flecs copied to clipboard

[Bug]: /api/v1/play plays song even with dismissed queue

Open FluffyPunk opened this issue 1 year ago • 1 comments

Preflight Checklist

  • [X] I use the latest version of YouTube Music (Application).
  • [X] I have searched the issue tracker for a bug report that matches the one I want to file, without success.
  • [X] I understand that th-ch/youtube-music has NO affiliation with Google or YouTube

YouTube Music (Application) Version

3.7.1

Checklists

What operating system are you using?

Windows

Operating System Version

Windows 11 24H2

What CPU architecture are you using?

x64

Last Known Working YouTube Music (Application) version

No response

Reproduction steps

API server should be enabled

  1. Dismiss queue (or DELETE /api/v1/queue)
  2. /api/v1/play

Expected Behavior

I think it should be unavailable to launch song since there's no songs in queue.

Actual Behavior

Sending request launches last played song after dismissing queue. It is showed by sending /api/v1/song

{
  "title": "cheatreal",
  "artist": "t+pazolite",
  "views": 438926,
  "uploadDate": "2022-11-30T02:07:10-08:00",
  "imageSrc": "https://lh3.googleusercontent.com/fngVaWP1iFl8OpmQyerxW17bJjzfrUH4w45ZHVEf3tKpwqhnVEXdcx3zp49OX3pftKoaCw2qJURxYxFWsA=w544-h544-l90-rj",
  "isPaused": true,
  "songDuration": 295,
  "elapsedSeconds": 0,
  "url": "https://music.youtube.com/watch?v=MzDpeX3eJRQ",
  "album": "Answer from X Girlz",
  "videoId": "MzDpeX3eJRQ",
  "playlistId": "RDAMPLOLAK5uy_kdLCctiPE2quAcjleq3tpLmqpgwiyAGDI",
  "mediaType": "AUDIO"
}

But at same moment queue is empty

{
  "items": [],
  "autoPlaying": false
}

Enabled plugins

  1. API Server
  2. Audio Compressor
  3. Exponential Volume
  4. Discord RPC
  5. Disable Autoplay
  6. In-App Menu
  7. Lyrics Genius
  8. Navigation
  9. Precise Volume

Additional Information

I see 2 ways of fixing this - simple and kinda complicated.

Simple is one is just checking queue for items - if there is no items[] in queue, so return error on /api/v1/play that there is no songs

Other way is checking if videoId in current song info (/api/v1/song) is presented in queue, but I'm not sure about queue structure since it looks kinda spaghetti raw JSON

FluffyPunk avatar Jan 04 '25 14:01 FluffyPunk

When you dismiss the queue, YouTube Music (web) retains the current playing song and just resets the playback at 0s, which is kinda weird personally.

If we make a workaround just for the API server, the data from the API would differ from the source of truth (YouTube Music itself).

franz-dc avatar Jan 05 '25 17:01 franz-dc