File size: 1,149 Bytes
3b6c73c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
import time
from acestream.server import Server
from acestream.engine import Engine
from acestream.stream import Stream
import subprocess

def start_acestream_stream(acestream_id):
    # Configurar el motor de AceStream
    engine = Engine('acestreamengine', client_console=True)
    
    # Intentar conectar al servidor local de AceStream
    server = Server(host='127.0.0.1', port=6878)
    if not server.available:
        # Si no está disponible, iniciar el motor
        engine.start()
        while not engine.running:
            time.sleep(1)
    
    # Configurar y comenzar el flujo AceStream
    stream = Stream(server, id=acestream_id)
    stream.start()
    
    # Reproducir el flujo en un reproductor como VLC o MPV
    player = subprocess.Popen(['mpv', stream.playback_url])
    
    # Retornar la URL del flujo HTTP para Gradio
    return stream.playback_url

# Configurar la interfaz de Gradio
iface = gr.Interface(
    fn=start_acestream_stream,
    inputs="text",
    outputs="text",
    title="AceStream a HTTP",
    description="Introduce el ID de AceStream para recibir un enlace HTTP."
)

iface.launch()