|
import gradio as gr |
|
import subprocess |
|
|
|
|
|
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')}" |
|
|
|
|
|
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.", |
|
) |
|
|
|
|
|
if __name__ == "__main__": |
|
iface.launch() |
|
|