13ze commited on
Commit
9c3ff33
1 Parent(s): ee6b285

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import subprocess
3
+
4
+ # Função para baixar e reproduzir um torrent usando WebTorrent CLI
5
+ def download_and_play_torrent(magnet_link):
6
+ command = f"webtorrent download {magnet_link} --vlc"
7
+ process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
8
+ stdout, stderr = process.communicate()
9
+
10
+ if process.returncode == 0:
11
+ return "Torrent baixado e reproduzido com sucesso!"
12
+ else:
13
+ return f"Erro ao baixar ou reproduzir torrent: {stderr.decode('utf-8')}"
14
+
15
+ # Interface Gradio
16
+ iface = gr.Interface(
17
+ fn=download_and_play_torrent,
18
+ inputs="text",
19
+ outputs="text",
20
+ title="WebTorrent Gradio Interface",
21
+ description="Insira um link magnet para baixar e reproduzir usando WebTorrent.",
22
+ )
23
+
24
+ # Iniciar a interface Gradio
25
+ if __name__ == "__main__":
26
+ iface.launch()