rework input to string
This commit is contained in:
parent
67ef8209f4
commit
6eb668510b
62
main.py
62
main.py
@ -25,37 +25,31 @@ if len(sys.argv) > 1:
|
|||||||
# Get the JSON argument from the command line
|
# Get the JSON argument from the command line
|
||||||
input_str = sys.argv[1]
|
input_str = sys.argv[1]
|
||||||
|
|
||||||
try:
|
# Convert the JSON string into a dictionary
|
||||||
# Convert the JSON string into a dictionary
|
disc_data = input_str.split(":")
|
||||||
disc_data = input_str.split(":")
|
if disc_data[0] == "ytmusic":
|
||||||
if disc_data[0] == "ytmusic":
|
disc_object = {
|
||||||
disc_object = {
|
"Name":disc_data[1],
|
||||||
"Name":disc_data[1],
|
"type":disc_data[2],
|
||||||
"type":disc_data[2],
|
"id":disc_data[3]
|
||||||
"id":disc_data[3]
|
}
|
||||||
}
|
# Check if disc is the same as last inserted
|
||||||
# Check if disc is the same as last inserted
|
if (disc_object == json.loads(check_current_disc(client))):
|
||||||
if (disc_object == json.loads(check_current_disc(client))):
|
# If disc is the same, PLAY
|
||||||
# If disc is the same, PLAY
|
control_player(client, "PLAY")
|
||||||
control_player(client, "PLAY")
|
else:
|
||||||
else:
|
# Pass the parsed data to the update_disc function
|
||||||
# Pass the parsed data to the update_disc function
|
control_player(client, "PLAY")
|
||||||
control_player(client, "PLAY")
|
update_disc(client, disc_data)
|
||||||
update_disc(client, disc_data)
|
else:
|
||||||
except json.JSONDecodeError as e:
|
if input_str == "EJECT":
|
||||||
try:
|
# PAUSE the current playing item
|
||||||
if input_str == "EJECT":
|
control_player(client, "PAUSE")
|
||||||
# PAUSE the current playing item
|
elif input_str == "PLAY":
|
||||||
control_player(client, "PAUSE")
|
# PLAY the current playing item
|
||||||
elif input_str == "PLAY":
|
control_player(client, "PLAY")
|
||||||
# PLAY the current playing item
|
elif input_str == "PAUSE":
|
||||||
control_player(client, "PLAY")
|
# PAUSE the current playing item
|
||||||
elif input_str == "PAUSE":
|
control_player(client, "PAUSE")
|
||||||
# PAUSE the current playing item
|
else:
|
||||||
control_player(client, "PAUSE")
|
print(f"Can't process {input_str}")
|
||||||
else:
|
|
||||||
print(f"Can't process {input_str}")
|
|
||||||
except Exception:
|
|
||||||
print(f"Invalid JSON format: {e}")
|
|
||||||
else:
|
|
||||||
print("No Command or Track Info Passed")
|
|
Loading…
x
Reference in New Issue
Block a user