1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
from flask import Flask
from pathlib import Path
from dotenv import load_dotenv
import requests
import subprocess
import threading
import os
app = Flask(__name__)
print_lock = threading.Lock()
load_dotenv("/srv/automation/remote-automation/.env")
@app.get("/automate/hack_this_club")
def hack_this_club():
print("i’M gOnNa HaCk\nThIs ClUb!!!1!1!1!!11!111!1!11!1")
print("this club. ia m going to hack ,is hack club.")
print("yes, i am going To hack, this club Is called hack club. i see no problem with This,")
print("i will hack this club on October 21st, 2043 at 5:36 am")
print("i will hack into, The hcb and it has money .also i have idv database downloaded and ,i will use it to hack this club ")
os.system('lp -d Canon_G3060 /opsec.txt')
return "ok"
@app.get("/automate/print_queue")
def print_queue():
if not print_lock.acquire(blocking=False):
print("print queue is already running")
return "print queue busy", 400
try:
print("printing file(s) in /srv/shares/public/printing")
path = Path("/srv/shares/public/printing")
files = [f for f in path.iterdir() if f.is_file()]
for file in files:
subprocess.run(["lp", "-d", "Canon_G3060", str(file)], check=True)
subprocess.run(["mv", str(file), "/srv/shares/public/printed"], check=True)
print(f"printed {len(files)} file(s)")
return f"printed {len(files)} file(s)"
except Exception as e:
return f"exception: {(str(e))}", 500
finally:
print_lock.release()
@app.get("/automate/music")
def music():
NAVIDROME_URL = os.environ.get("NAVIDROME_URL", "127.0.0.1")
USERNAME = os.environ.get("NAVIDROME_USER", "user")
PASSWORD = os.environ.get("NAVIDROME_PASSWORD", "password123")
PLAYLIST_ID = os.environ.get("NAVIDROME_PLAYLIST_ID", "6767baldniko67")
params = {
"u": USERNAME,
"p": PASSWORD,
"s": "remote-automation",
"v": "1.16.1",
"c": "remote-automation",
"f": "json",
"id": PLAYLIST_ID,
}
print(f"Params: {params}")
response = requests.get(f"{NAVIDROME_URL}/rest/getPlaylist.view")
response.raise_for_status()
print("Navidrome status:", response.status_code)
print("Navidrome content-type:", response.headers.get("content-type"))
print("Navidrome response:", response.text[:500])
songs = response.json()["subsonic-response"]["playlist"]["entry"]
song = random.choice(songs)
stream_params = {
"u": USERNAME,
"p": PASSWORD,
"s": "remote-automation",
"v": "1.16.1",
"c": "remote-automation",
"id": song["id"],
}
subprocess.Popen([
"mpv",
"--no-video",
"--audio-device=pipewire",
"--",
requests.Request("GET", stream_url, params=stream_params).prepare().url,
])
print(f"Playing: {song['title']} - {song.get('artist', 'Unknown Artist')}")
if __name__ == "__main__":
app.run(host="0.0.0.0", port=6732)
|