updates
This commit is contained in:
parent
386db9ba31
commit
2eb8a1641b
16
main.py
16
main.py
@ -4,7 +4,12 @@ import json
|
|||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
from lib.mqtt import create_client, update_disc, control_player, create_config
|
from lib.mqtt import create_client, update_disc, control_player, create_config
|
||||||
|
|
||||||
load_dotenv()
|
|
||||||
|
# Path to your .env file
|
||||||
|
dotenv_path = '/home/dietpi/floppy-ytube-player/.env'
|
||||||
|
|
||||||
|
# Load the .env file
|
||||||
|
load_dotenv(dotenv_path)
|
||||||
|
|
||||||
# Define the MQTT server details
|
# Define the MQTT server details
|
||||||
broker = os.environ.get("broker")
|
broker = os.environ.get("broker")
|
||||||
@ -13,6 +18,8 @@ port = int(os.environ.get("port"))
|
|||||||
username = os.environ.get('username')
|
username = os.environ.get('username')
|
||||||
password = os.environ.get('password')
|
password = os.environ.get('password')
|
||||||
|
|
||||||
|
print(f"Broker: {broker}, Port: {port}, Username: {username}")
|
||||||
|
|
||||||
client = create_client(broker, port, username, password)
|
client = create_client(broker, port, username, password)
|
||||||
|
|
||||||
create_config(client)
|
create_config(client)
|
||||||
@ -28,6 +35,13 @@ if len(sys.argv) > 1:
|
|||||||
# Pass the parsed data to the update_disc function
|
# Pass the parsed data to the update_disc function
|
||||||
update_disc(client, disc_data)
|
update_disc(client, disc_data)
|
||||||
except json.JSONDecodeError as e:
|
except json.JSONDecodeError as e:
|
||||||
|
try:
|
||||||
|
if json_str == "EJECT":
|
||||||
|
control_player(client, "EJECT")
|
||||||
|
update_disc(client, {"type":"album", "id":"EJECT"})
|
||||||
|
elif json_str == "PLAY":
|
||||||
|
control_player(client, "PLAY")
|
||||||
|
except Exception:
|
||||||
print(f"Invalid JSON format: {e}")
|
print(f"Invalid JSON format: {e}")
|
||||||
else:
|
else:
|
||||||
print("No JSON argument passed, running default control_player action.")
|
print("No JSON argument passed, running default control_player action.")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user