jishi / node-sonos-http-api

An HTTP API bridge for Sonos easing automation. Hostable on any node.js capable device, like a raspberry pi or similar.
http://jishi.github.io/node-sonos-http-api/
MIT License
1.84k stars 462 forks source link

How to play clip from path #817

Open mediendiver opened 2 years ago

mediendiver commented 2 years ago

I would like to play a file in path like this: /test/1.mp3, but it doesn't work. If I copy the file in /1.mp3 it works fine. But when I copy the file in the folder test, it doesn't work.

This work for me: http://127.0.0.1:5005/Bad/clip/1.mp3 So, the file ist playing, but I get an error, that the file is not found.

This works not: http://127.0.0.1:5005/Bad/clip/test/1.mp3 or http://127.0.0.1:5005/Bad/clip%2f1.mp3

How can I fixed it?

jishi commented 2 years ago

You can't right now. Because the API is actually using / as a delimiter for multiple parameters, it gets confused by this.

https://github.com/jishi/node-sonos-http-api/blob/master/lib/actions/clip.js#L14

values[0] will become test in your example, and 1.mp3 will be interpreted as volume. It is also not decoding parameters (only the room name) so your url escaping doesn't work.

That could easily be fixed though, by adding a decodeURIComponent on line 14. Then you would be able to do

http://127.0.0.1:5005/Bad/clip/test%2f1.mp3

I think.