forked from martinbjeldbak/acestream-http-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
91 lines (73 loc) · 2.63 KB
/
app.py
File metadata and controls
91 lines (73 loc) · 2.63 KB
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
import tkinter as tk
from tkinter import ttk
import subprocess
import re
import time
import threading
HIGHLIGHT_SEC = 1.5 # kaç saniye boyunca yeşil kalacak
def clean_id(raw: str) -> str:
raw = raw.strip()
if raw.lower().startswith("acestream://"):
raw = raw[12:]
return re.sub(r"[^0-9a-fA-F]", "", raw)
def play_stream(stream_id: str, port: str, entry_widget, status_widget):
sid = clean_id(stream_id)
if not sid:
status_widget.config(text="Geçersiz ID!")
return
try:
port_num = int(port)
except ValueError:
port_num = 6880
url = f"http://localhost:{port_num}/ace/getstream?id={sid}"
# 1) GUI uyarısı
def blink():
entry_widget.config(style="Green.TEntry")
status_widget.config(text=f"Oynatılıyor: {sid}")
time.sleep(HIGHLIGHT_SEC)
entry_widget.config(style="TEntry")
threading.Thread(target=blink, daemon=True).start()
# 2) mpv başlat
subprocess.Popen(["mpv", url])
def build_ui():
root = tk.Tk()
root.title("AceStream MPV GUI (port + uyarı)")
root.geometry("540x300")
root.resizable(False, False)
style = ttk.Style()
style.map("Green.TEntry",
fieldbackground=[("active", "#aaffaa"), ("!active", "#aaffaa")])
entries_id = []
entries_port = []
for i in range(6):
ttk.Label(root, text=f"Link {i+1}:").grid(row=i, column=0, padx=6, pady=5, sticky="e")
e_id = ttk.Entry(root, width=40)
e_id.grid(row=i, column=1, padx=6, pady=5)
entries_id.append(e_id)
e_port = ttk.Entry(root, width=6)
e_port.insert(0, "6880")
e_port.grid(row=i, column=2, padx=6, pady=5)
entries_port.append(e_port)
btn = ttk.Button(
root,
text="Oynat",
command=lambda idx=i: play_stream(
entries_id[idx].get(),
entries_port[idx].get(),
entries_id[idx],
status_label
)
)
btn.grid(row=i, column=3, padx=6, pady=5)
# Status bar
status_label = ttk.Label(root, text="Hazır", anchor="w")
status_label.grid(row=6, column=0, columnspan=4, sticky="we", padx=6, pady=6)
# Tümünü oynat
def play_all():
for e_id, e_port in zip(entries_id, entries_port):
play_stream(e_id.get(), e_port.get(), e_id, status_label)
all_btn = ttk.Button(root, text="Tümünü Oynat", command=play_all)
all_btn.grid(row=7, column=1, columnspan=2, pady=8)
root.mainloop()
if __name__ == "__main__":
build_ui()