update to read in content
This commit is contained in:
parent
2f90562b9c
commit
5bdfdb0881
24
main.py
24
main.py
@ -1,4 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
import json
|
||||||
from lib.mqtt import create_client, update_disc, control_player, create_config
|
from lib.mqtt import create_client, update_disc, control_player, create_config
|
||||||
|
|
||||||
# Define the MQTT server details
|
# Define the MQTT server details
|
||||||
@ -12,10 +14,20 @@ client = create_client(broker, port, username, password)
|
|||||||
|
|
||||||
create_config(client)
|
create_config(client)
|
||||||
|
|
||||||
# update_disc(client, {"type":"album", "id":"MPREb_2UBRpewr9ad"})
|
# Check if any arguments are passed
|
||||||
# update_disc(client, {"type":"playlist", "id":"LM"})
|
if len(sys.argv) > 1:
|
||||||
|
# Get the JSON argument from the command line
|
||||||
#
|
json_str = sys.argv[1]
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Convert the JSON string into a dictionary
|
||||||
|
disc_data = json.loads(json_str)
|
||||||
|
# Pass the parsed data to the update_disc function
|
||||||
|
update_disc(client, disc_data)
|
||||||
|
except json.JSONDecodeError as e:
|
||||||
|
print(f"Invalid JSON format: {e}")
|
||||||
|
else:
|
||||||
|
print("No JSON argument passed, running default control_player action.")
|
||||||
|
|
||||||
|
# You can still have the default behavior if no JSON is passed
|
||||||
control_player(client, "EJECT")
|
control_player(client, "EJECT")
|
||||||
|
|
||||||
#
|
|
Loading…
x
Reference in New Issue
Block a user