Hello
I created a small Python3 script to act as a brigde between an automation system and the volumio player,
Like that i can load a playlist of webradios and select 1 of the webradio stations in that playlist by sending a "stream0-stream1-stream2-stream3 comamnds toward a created port on the volumio.
I have tested it on a python windows 10 and it is working, however if i try to run it on the volumio python (updated to python3) i have the next error.
1/ print(f"Connection from {address} has been established.") -> give me an error
2/ print(“Listen…”) -> after that line the program did create the socket -
Any solutions?
import socket
import requests
http = ‘http://’
IPPlayer = ‘192.168.0.116’
cmdstring = ‘/api/v1/commands/?cmd=’
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((socket.gethostname(), 8888))
s.listen(1)
print(“Listen…”)
clientsocket, address = s.accept()
print(f"Connection from {address} has been established.")
clientsocket.send(bytes(“Hey there!!!”,“utf-8”))
while True:
msg = clientsocket.recv(7)
print(msg.decode(“utf-8”))
msg = msg.decode("utf-8")
if msg == "stream0":
res = requests.get(http+IPPlayer+cmdstring+'clearQueue')
res = requests.get(http+IPPlayer+cmdstring+'playplaylist&name=streamlist')
print(res)
if msg == "stream1":
res = requests.get(http+IPPlayer+cmdstring+'play&N=0')
print(res)
if msg == "stream2":
res = requests.get(http+IPPlayer+cmdstring+'play&N=1')
print(res)
if msg == "stream3":
res = requests.get(http+IPPlayer+cmdstring+'play&N=2')
print(res)