|
import gradio as gr |
|
import subprocess |
|
import os |
|
import re |
|
import datetime |
|
import uuid |
|
|
|
|
|
def download_twitch_clip(url, auth_token): |
|
|
|
unique_id = uuid.uuid4() |
|
|
|
|
|
output_filename = f"{unique_id}.mkv" |
|
|
|
command = ["twitch-dl", "download", url, "-q", "source", "-o", output_filename] |
|
|
|
if auth_token.strip(): |
|
command.extend(["-a", auth_token]) |
|
|
|
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
|
stdout, stderr = process.communicate() |
|
|
|
|
|
return output_filename |
|
|
|
|
|
def gradio_interface(url, auth_token=""): |
|
file_name = download_twitch_clip(url, auth_token) |
|
return file_name |
|
|
|
iface = gr.Interface( |
|
fn=gradio_interface, |
|
inputs=[ |
|
gr.Textbox(label="URL do Clipe da Twitch"), |
|
gr.Textbox(label="Token de Autenticação (opcional)") |
|
], |
|
outputs=gr.Video() |
|
) |
|
|
|
|
|
iface.launch() |
|
|