Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gwpl/92ab540016bf43359654d5b0f013b1ec to your computer and use it in GitHub Desktop.
Save gwpl/92ab540016bf43359654d5b0f013b1ec to your computer and use it in GitHub Desktop.
Play FLAC m3u playlist from NAS on Sonos via http URIs
#!/bin/bash
#find speaker IP with `socos` :
# socos list
#(1) 192.168.1.101 Moon
#(2) 192.168.1.102 Mars
# (...)
#(6) 192.168.1.106 Playroom stereo
python3 soco_play_m3u_by_uri_http_flac_Sonos_NAS.py 192.168.1.106 meshuggah*.m3u 4dots*.m3u phobh*.m3u the_number_twelve_looks_like_you*.m3u the_dillinger_escape_plan*.m3u
#!/usr/bin/env python3
import sys
import soco
ip=sys.argv[1]
print('Playing on Speaker with ip='+ip)
s=soco.SoCo(ip)
print(' get_speaker_info()='+str(s.get_speaker_info()))
s.clear_queue()
for m3u_filename in sys.argv[2:]:
print('Adding m3u...'+m3u_filename)
with open(m3u_filename, 'r') as m3u_filehandler:
for line in m3u_filehandler:
filename = line.rstrip('\n')
print('..."'+filename+'"')
s.add_uri_to_queue('http://192.168.1.99:8080/MusicShared/'+filename)
s.play_from_queue(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment