tx3bas commited on
Commit
3b6c73c
·
verified ·
1 Parent(s): 6ef99c7

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -0
app.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import time
3
+ from acestream.server import Server
4
+ from acestream.engine import Engine
5
+ from acestream.stream import Stream
6
+ import subprocess
7
+
8
+ def start_acestream_stream(acestream_id):
9
+ # Configurar el motor de AceStream
10
+ engine = Engine('acestreamengine', client_console=True)
11
+
12
+ # Intentar conectar al servidor local de AceStream
13
+ server = Server(host='127.0.0.1', port=6878)
14
+ if not server.available:
15
+ # Si no está disponible, iniciar el motor
16
+ engine.start()
17
+ while not engine.running:
18
+ time.sleep(1)
19
+
20
+ # Configurar y comenzar el flujo AceStream
21
+ stream = Stream(server, id=acestream_id)
22
+ stream.start()
23
+
24
+ # Reproducir el flujo en un reproductor como VLC o MPV
25
+ player = subprocess.Popen(['mpv', stream.playback_url])
26
+
27
+ # Retornar la URL del flujo HTTP para Gradio
28
+ return stream.playback_url
29
+
30
+ # Configurar la interfaz de Gradio
31
+ iface = gr.Interface(
32
+ fn=start_acestream_stream,
33
+ inputs="text",
34
+ outputs="text",
35
+ title="AceStream a HTTP",
36
+ description="Introduce el ID de AceStream para recibir un enlace HTTP."
37
+ )
38
+
39
+ iface.launch()