Open bjesus opened 4 years ago
Hmm, that's an interesting use case, I'm not sure if that's possible off the top of my head, but I will look into it and report back.
@bjesus Have you looked into something that uses the Spotify Web API instead?
Cant contribute too much to this, but I did notice that if you do the same with Spotify, it actually gives you the Spotify ID, which if you try to open in say Chrome, it deep links into the Spotify app
current_time: 209.661
content_id: spotify:track:3s4hxwmmzhCT0Z4g94cY3N
content_type: application/x-spotify.track
duration: 403.2
stream_type: BUFFERED
idle_reason: None
media_session_id: 1
playback_rate: 1
player_state: PLAYING
supported_media_commands: 514511
volume_level: 1
volume_muted: False
media_custom_data: {}
media_metadata: {'metadataType': 3, 'title': 'Warp Drive', 'songName': 'Warp Drive', 'artist': 'Tonebox', 'albumName': 'Nocturn', 'images': [{'url': 'https://i.scdn.co/image/ab67616d00001e0244d66e01a3bd0c5d478a0aaa', 'height': 300, 'width': 300}, {'url': 'https://i.scdn.co/image/ab67616d0000485144d66e01a3bd0c5d478a0aaa', 'height': 64, 'width': 64}, {'url': 'https://i.scdn.co/image/ab67616d0000b27344d66e01a3bd0c5d478a0aaa', 'height': 640, 'width': 640}]}
subtitle_tracks: []
current_subtitle_tracks: []
last_updated: 2020-08-11 17:39:06.355814
is_active_input: False
is_stand_by: True
app_id: CC32E753
display_name: Spotify
namespaces: ['urn:x-cast:com.google.cast.cac', 'urn:x-cast:com.google.cast.debugoverlay', 'urn:x-cast:com.spotify.chromecast.secure.v1', 'urn:x-cast:com.google.cast.test', 'urn:x-cast:com.google.cast.broadcast', 'urn:x-cast:com.google.cast.media']
session_id: a13ebc58-3cad-4e2d-aa17-c248cfc48cdc
transport_id: a13ebc58-3cad-4e2d-aa17-c248cfc48cdc
status_text: Casting: Warp Drive
icon_url: https://lh3.googleusercontent.com/HOX9yqNu6y87Chb1lHYqhKVTQW43oFAFFe2ojx94yCLh0yMzgygTrM0RweAexApRWqq6UahgrWYimVgK
Thanks @greghesp ! I'm not sure how to use this though... Did you manage to get Catt to start casting the Spotify playlist using this track id? or am I missing something? I'm trying to programmatically start casting a playlist.
Something tells me you can't. The way casting works for services like Spotify, is it sends the API connection to the casting device, which makes the connection to the service's server.
This is why it will continue to play when you close the browser etc
What technically prevents Catt from sending the API connection to the casting device then? I mean, how is that different from casting a youtube video with Catt?
So I've tried a couple of things - first I tried using wireshark to see what kind of requests the browser sends to my Google Home when it makes it start playing, but that failed because it seems to be encrypted and I couldn't decrypt it. Then I used https://github.com/tamland/python-tidal/ to get the media URL for a track and send it through catt cast
- and that worked, so I can basically write a script that takes a playlist, gets the first song media URL and plays it with catt cast
. Problem is, I can't make this into a playlist, because catt add
only works with youtubes for some reason?
I can easily generate a local file listing all media URLs for all tracks in the playlist, but I wonder how can I cast this whole file once with catt, and not just one song at a time. I could theoretically write a script that runs catt status
all the time to see when the track is done, and then submit the next one. It's just a little... inelegant?
I'm not entirely up to speed with how specific Chromecast apps work, but I think it would depend on the app. IIRC we only have support for the YouTube app at the moment, if support for the Spotify or Tidal apps are added, we could potentially support playing other types, but I'm not sure what that would entail.
Just to clarify, I was trying to Wireshark the chrome browser when casting from the tidal website, not some native app.
However, I'm not suggesting adding any Spotify/Tidal specific support. I can already gather a list of URLs that catt
can successfully cast
. I just currently can only feed cast
one song at a time, and then constantly check the status so I'll know when to cast
the next one. What I'm wondering is why can't I queue any other URL except YouTube when using catt add
. If I could add
the URLs, or cast
a file that is a list of URLs, my problem would be pretty much solved.
AFAIK the generic app doesn't support that, so catt would have to stay running and watch the status constantly so it can switch to the next track. It's not something I think would be a good addition currently, but you should be able to fairly easily implement it through the catt API.
Updating that I managed to decrypt the data sent using the instructions on the PyChromecast project (https://github.com/home-assistant-libs/pychromecast/issues/403) and added a pull request that allows queuing media (https://github.com/home-assistant-libs/pychromecast/pull/404). Hopefully once this is merged, and once Catt moved to PyChromecast 7 again, catt add
can use it to queue any URL.
Then, one could generate a playlist using whatever API they want (eg. python-tidal) and send it to their Chromecast using catt add
.
Ahh, that's great news, thanks! That's definitely something we could add.
Do you think we can add catt next
and catt prev
to go along media_controller.queue_next()
and media_controller.queue_prev()
? Let me know if you want me to open a new issue for this (I assume it's a pretty minor addition?).
Yes, certainly, though I'm not sure whether it should be standalone or as part of a "queue management" feature (which should include "add").
The "enqueue" support was now released with Pychromecast 7.3.0. Should I submit a pull request for "add", "next" and "prev"? It seems like the whole Pychromecast 7 support is on hold for some reason?
It seems like the whole Pychromecast 7 support is on hold for some reason?
I plan on finishing up that PR next weekend.
The "enqueue" support was now released with Pychromecast 7.3.0
Great work! Is this working with Tidal as is?
Awesome! The enqueue
isn't specific to Tidal, you can send it any media you want exactly like the play_media()
was working before. It's just play_media(URL, enqueue=True)
, which makes the Chromecast not play the song immediately but add it to the queue. However, I use it successfully with Tidal by getting the media URLs using python-tidal
and feeding them to enqueue. Great morning alarm clock ;-)
The enqueue isn't specific to Tidal
Indeed, but as I recall, queuing functionality is only part of the base receiver, from receiver API V3+. And given that Google still supports the V2 API, there's bound to be a lot of cc apps, that doesn't support V3 queuing. If you have some time to test which cc apps respond to these cmds, then that would be amazing!
I'm sorry but I'm not sure what you mean... I honestly don't know much about the spec versions. All I know is that Pychromecast's play_media()
method takes a URL as an input. The way I'm playing music from Tidal has nothing to do with the Tidal app (or any other app). I just query Tidal using python-tidal and get a URL. I can use this URL with wget, mplayer, vlc, whatever. and I can feed it to play_media
, with or without enqueue=True
.
Ah, I see.
The point about some/most cc apps not supporting this kind of queuing is still valid though. So your new functionality should be implemented as a new mixin in controllers.py
. And then as a start, DefaultCastController
could use that.
That way, we're not adding functionality that fails silently with many cc apps.
Hi! now that Pychromecast 7.5 is merged (🥳🥳🥳 @theychx), can we add support for catt next
and catt prev
? Should I send a PR?
Should I send a PR?
Please do.
Did this ever get added? @bjesus @theychx
Did this ever get added?
Nope
Hi! Thanks for catt :)
I'm trying to get my computer to auto play music on my Chromecast every morning, basically putting catt in a crontab. However, I'd like it to use my streaming service, like Spotify or Tidal. I noticed that I can go with my browser to to listen.tidal.com for example, start a playlist, press the Cast button, and then the playlist keeps playing even after I close the browser. I'm assuming then that there's some kind of a request going from my computer to the Chromecast passing the playlist to my Chromecast, and then Chromecast takes it from there. I'm trying to understand what's the URL of that playlist, and how can I replicate that request with catt.
catt info
shows some information regarding the currently playing track, but it doesn't seem to show any playlist URL like I would have hoped to pass later through catt:Is this even possible? To replicate a a playlist played by a streaming service using catt?
Thank you very much!