dck / app.py
13ze's picture
Create app.py
9c3ff33 verified
raw
history blame contribute delete
855 Bytes
import gradio as gr
import subprocess
# Função para baixar e reproduzir um torrent usando WebTorrent CLI
def download_and_play_torrent(magnet_link):
command = f"webtorrent download {magnet_link} --vlc"
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
if process.returncode == 0:
return "Torrent baixado e reproduzido com sucesso!"
else:
return f"Erro ao baixar ou reproduzir torrent: {stderr.decode('utf-8')}"
# Interface Gradio
iface = gr.Interface(
fn=download_and_play_torrent,
inputs="text",
outputs="text",
title="WebTorrent Gradio Interface",
description="Insira um link magnet para baixar e reproduzir usando WebTorrent.",
)
# Iniciar a interface Gradio
if __name__ == "__main__":
iface.launch()