artificialguybr commited on
Commit
e1eb4d4
·
verified ·
1 Parent(s): 7258af4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -5,26 +5,25 @@ import re
5
 
6
  # Função para baixar o clipe da Twitch
7
  def download_twitch_clip(url, auth_token):
8
- # Comando básico para download
9
  command = ["twitch-dl", "download", url, "-q", "source"]
10
 
11
- # Adiciona o token de autenticação, se fornecido
12
  if auth_token.strip():
13
  command.extend(["-a", auth_token])
14
 
15
- # Executa o comando de download e captura a saída
16
  process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
17
  stdout, stderr = process.communicate()
18
 
19
- # Usa expressão regular para encontrar o nome do arquivo na saída
20
- match = re.search(r"Target: (.+\.mp4)", stderr.decode("utf-8"))
21
  if match:
22
  file_name = match.group(1)
23
  else:
24
- raise Exception("Não foi possível encontrar o nome do arquivo de vídeo.")
 
25
 
26
  return file_name
27
 
 
28
  # Interface Gradio
29
  def gradio_interface(url, auth_token=""):
30
  file_name = download_twitch_clip(url, auth_token)
 
5
 
6
  # Função para baixar o clipe da Twitch
7
  def download_twitch_clip(url, auth_token):
 
8
  command = ["twitch-dl", "download", url, "-q", "source"]
9
 
 
10
  if auth_token.strip():
11
  command.extend(["-a", auth_token])
12
 
 
13
  process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
14
  stdout, stderr = process.communicate()
15
 
16
+ # Ajuste a expressão regular conforme necessário
17
+ match = re.search(r"Alguma expressão regular correspondente", stderr.decode("utf-8"))
18
  if match:
19
  file_name = match.group(1)
20
  else:
21
+ # Forneça uma mensagem de erro mais descritiva ou tente um método alternativo
22
+ raise Exception("Não foi possível encontrar o nome do arquivo de vídeo na saída do comando.")
23
 
24
  return file_name
25
 
26
+
27
  # Interface Gradio
28
  def gradio_interface(url, auth_token=""):
29
  file_name = download_twitch_clip(url, auth_token)