diff options
| author | Arslaan Pathan <[email protected]> | 2026-10-06 12:57:00 +1300 |
|---|---|---|
| committer | Arslaan Pathan <[email protected]> | 2026-10-06 12:57:00 +1300 |
| commit | 90bde93d0462bb943cd100bfd87781e4232d1b82 (patch) | |
| tree | e4bcf3f9599fc6ae377ff4f5a535dc496db67e6d /backend.py | |
| parent | cc312e9054fd7a39a8937762247a1c72281c55e5 (diff) | |
| download | remote-automation-90bde93d0462bb943cd100bfd87781e4232d1b82.tar.xz remote-automation-90bde93d0462bb943cd100bfd87781e4232d1b82.zip | |
socket
Diffstat (limited to 'backend.py')
| -rw-r--r-- | backend.py | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -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(): |
