Skip to content

Instantly share code, notes, and snippets.

@dotarr
Created May 30, 2025 09:55
Show Gist options
  • Save dotarr/ce6c3f1579a179d7a81de57dcb567854 to your computer and use it in GitHub Desktop.
Save dotarr/ce6c3f1579a179d7a81de57dcb567854 to your computer and use it in GitHub Desktop.
A quick and dirty cli tool to make a chromecast audio play an internet radio stream
import pychromecast
import sys
from uuid import UUID
# Populate these with your own CC uuid's.
# See: https://github.com/home-assistant-libs/pychromecast
CHROMECASTS = {
'lounge' : '5f209109-a83d-bcdf-b367-0c11fd97e7d0',
'kitchen' : 'c5f87312-93dc-3ef2-32f9-19ce9511e934'
}
# See below for appropriate 'content type strings'
# https://developers.google.com/cast/docs/media#mp4_audio_only
STATIONS = {
'rinse': {
'url': 'https://admin.stream.rinse.fm/proxy/rinse_uk/stream', #'https://streamer-uk.rinse.fm:8443/stream',
'content_type': 'audio/mp4; codecs="mp4a.40.2"'
},
'balamii':{
'url': 'https://balamii.out.airtime.pro/balamii_a',
'content_type': 'audio/mpeg; codecs="mp3"'
},
'nts':{
'url':'https://stream-relay-geo.ntslive.net/stream',
'content_type': 'audio/mpeg; codecs="mp3"'
}
}
def main(*args):
station = args[1]
uuid = CHROMECASTS['lounge'] if not args[2:3] else CHROMECASTS[args[2]]
cc = pychromecast.get_listed_chromecasts(uuids=[UUID(uuid)])[0][0]
cc.wait()
cc.media_controller.play_media(**STATIONS[station])
cc.media_controller.block_until_active()
if __name__=='__main__':
main(*sys.argv)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment