File size: 1,060 Bytes
89df459
 
 
8eefd04
c98b0b5
234649d
89df459
 
1badb48
234649d
 
c98b0b5
234649d
 
 
 
89df459
1badb48
89df459
 
8eefd04
 
89df459
234649d
 
89df459
 
1badb48
89df459
 
 
 
 
 
80798c8
1badb48
89df459
4765650
89df459
 
 
 
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
41
42
43
import gradio as gr
import subprocess
import os
import re
import datetime
import uuid

# Função para baixar o clipe da Twitch
def download_twitch_clip(url, auth_token):
    # Gerar um UUID
    unique_id = uuid.uuid4()

    # Criar um nome de arquivo único com o UUID
    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()

    # O nome do arquivo é determinado pelo UUID
    return output_filename

# Interface Gradio
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()
)

# Executar a interface
iface.launch()