aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArslaan Pathan <[email protected]>2026-10-06 12:57:00 +1300
committerArslaan Pathan <[email protected]>2026-10-06 12:57:00 +1300
commit90bde93d0462bb943cd100bfd87781e4232d1b82 (patch)
treee4bcf3f9599fc6ae377ff4f5a535dc496db67e6d
parentcc312e9054fd7a39a8937762247a1c72281c55e5 (diff)
downloadremote-automation-90bde93d0462bb943cd100bfd87781e4232d1b82.tar.xz
remote-automation-90bde93d0462bb943cd100bfd87781e4232d1b82.zip
socket
-rw-r--r--backend.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/backend.py b/backend.py
index f8a0b24..35cc6b1 100644
--- a/backend.py
+++ b/backend.py
@@ -2,6 +2,7 @@ from flask import Flask
from pathlib import Path
from dotenv import load_dotenv
import json
+import socket
import requests
import random
import subprocess
@@ -51,9 +52,9 @@ def print_queue():
print_lock.release()
def mpv_command(command):
- with open(MPV_SOCKET, "w") as sock:
- sock.write(json.dumps({"command": command}) + "\n")
- sock.flush()
+ with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as sock:
+ sock.connect(MPV_SOCKET)
+ sock.sendall((json.dumps({"command": command}) + "\n").encode())
@app.get("/automate/music")
def music():