spotcast icon indicating copy to clipboard operation
spotcast copied to clipboard

Include timestamp option in YAML

Open itzteajay-glitch opened this issue 4 years ago • 9 comments

spotify URI allow for you to include a #mm:ss timestamp at the end of it to start a track from a specific point. Would this be something that could be imlemented? I tried putting a colon in the url but it breaks the syntax of the output but sing the url encode for a colon does not and it still works through a browser. Is there a possiblity of including a timestamp either in another YAML option or allow it to be included in the URI itself?

[140049427208032] http status: 400, code:-1 - https://api.spotify.com/v1/me/player/play?device_id=3c31e63dda8e146428f7b25084e98915: Invalid track uri: spotify:track:0mHyWYXmmCB9iQyK18m3FQ#0:38, reason: None 10:44:21 AM – Home Assistant WebSocket API (ERROR) - message first occurred at 10:36:55 AM and shows up 6 times

itzteajay-glitch avatar Feb 07 '21 18:02 itzteajay-glitch

Sure, you wanna create a PR? I have a lot to do right now so it might take time

fondberg avatar Mar 05 '21 12:03 fondberg

@itzteajay-glitch I couldn't see support for this in the official API. Can you point me to the documentation for this feature?

fondberg avatar Apr 17 '21 13:04 fondberg

I'd have to do some digging. But here's an example

You have a standard link to a song spotify:track:6dijvEXmPs4XA05dYPaK1J

You have a link to a song where it will start at a certain time spotify:track:6dijvEXmPs4XA05dYPaK1J#1:00

itzteajay-glitch avatar Apr 17 '21 14:04 itzteajay-glitch

I'm not sure if this is the call you're making? Start/Resume a User's Playback https://developer.spotify.com/documentation/web-api/reference/#category-player

I'm no python expert I'd have to dig into your code more to understand it. It does look like it has a position_ms option as a parameter.

itzteajay-glitch avatar Apr 17 '21 14:04 itzteajay-glitch

You are right. Would this be enough for your usecase? Also, is it mainly for tracks or other URi types as well?

fondberg avatar Apr 17 '21 16:04 fondberg

I think tracks and shows would be useful. I didn't check if it's available for shows but that would allow snippets of podcasts to be played by home assistant in things like audio alerts.

itzteajay-glitch avatar Apr 17 '21 17:04 itzteajay-glitch

There is actually a position_ms which can be sent in the playback request. Do you want me to add this so you can try? https://github.com/plamere/spotipy/blob/master/spotipy/client.py#L1723

fondberg avatar May 30 '21 15:05 fondberg

@itzteajay-glitch ^^

fondberg avatar Jun 19 '21 20:06 fondberg

Oh, this would be a nice addition indeed! Happy to test if needed.

TheFes avatar Apr 26 '22 08:04 TheFes