-
Notifications
You must be signed in to change notification settings - Fork 0
/
TMVD.py
114 lines (96 loc) · 2.97 KB
/
TMVD.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import PySimpleGUI as sg
from yt_dlp import YoutubeDL
from pathlib import Path
from threading import Thread
class DownloadMusic(Thread):
def __init__(self, url):
Thread.__init__(self)
self.url = url
def run(self):
try:
print("Baixando[]\n")
out = str(
Path.home()
/ "Documents"
/ "Trash downloader"
/ "Musics (trash)"
/ "%(title)s.%(ext)s"
)
with YoutubeDL(
{
"ffmpeg_location": "ffmpeg.exe",
"outtmpl": out,
"quiet": True,
"no_warnings": True,
"format": "140",
"postprocessors": [
{"key": "FFmpegMetadata"},
{
"key": "EmbedThumbnail",
"already_have_thumbnail": True,
},
],
}
) as ydl:
ydl.download(self.url)
print("\nDonwload concluído[]")
except:
print("\nDownload mal sucedido, verifique a Url.")
class DownloadVideo(Thread):
def __init__(self, url):
Thread.__init__(self)
self.url = url
def run(self):
try:
print("Baixando[]\n")
out = str(
Path.home()
/ "Documents"
/ "Trash downloader"
/ "Videos (trash)"
/ "%(title)s.%(ext)s"
)
with YoutubeDL(
{
"ffmpeg_location": "ffmpeg.exe",
"outtmpl": out,
"quiet": True,
"no_warnings": True,
"format": "137+140/136+140/135+140/134+140/133+140/160+140/22/18",
"postprocessors": [
{"key": "FFmpegMetadata"},
{"key": "EmbedThumbnail"},
],
}
) as ydl:
ydl.download(self.url)
print("\nDonwload concluído[]")
except:
print("\nDownload mal sucedido, verifique a Url.")
layout = [
[sg.Output(key="out", size=(50, 10),)],
[
sg.Button("Download Music", key="dm"),
sg.Button("Download Video", key="dv"),
],
[sg.Input(key="IN"), sg.Button("Exit", key="Close")],
]
window = sg.Window("Trash Downloader", layout)
while True:
event, values = window.read()
v = DownloadVideo(values["IN"])
m = DownloadMusic(values["IN"])
if event == "dv":
if len(values["IN"]) > 0:
v.start()
else:
print("Por favor digite algo.")
if event == "dm":
if len(values["IN"]) > 0:
m.start()
else:
print("Por favor digite algo.")
if event in (None, "Close"):
break
window.close()
# new code looks sexy!