-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
43 lines (35 loc) · 1.44 KB
/
app.py
File metadata and controls
43 lines (35 loc) · 1.44 KB
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 webview
from pytube import YouTube
video = {
'url': '',
'title': '',
'thumbnail': '',
'status': '',
}
# Função para capturar a URL e baixar o vídeo
def YtDownload():
video['url'] = webview.evaluate_js('document.getElementById("floatingInput").value')
if video['url']:
try:
youtube = YouTube(video['url'])
video['title'] = youtube.title
video['thumbnail'] = youtube.thumbnail_url
# Atualiza a interface com o título do vídeo
webview.evaluate_js(f'document.getElementById("title").innerText = "Título: {video["title"]}";')
# Baixa o vídeo
stream = youtube.streams.get_highest_resolution()
stream.download()
video['status'] = 'Download concluído!'
webview.evaluate_js(f'document.getElementById("status").innerText = "{video["status"]}";')
except Exception as e:
video['status'] = f"Erro: {str(e)}"
webview.evaluate_js(f'document.getElementById("status").innerText = "{video["status"]}";')
else:
video['status'] = "URL inválida. Insira um link do YouTube."
webview.evaluate_js(f'document.getElementById("status").innerText = "{video["status"]}";')
# Inicia a aplicação
def main():
webview.create_window('YouTube Downloader', './UI/index.html')
webview.start()
if __name__ == '__main__':
main()