-
Notifications
You must be signed in to change notification settings - Fork 0
/
video_downloader__TKinter+yt_dlp.py
90 lines (73 loc) · 2.27 KB
/
video_downloader__TKinter+yt_dlp.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
# my ass is very big.
import subprocess
import io
import os
import time
import re
import uuid
import sys
try:
import requests
print('ok')
except Exception as e:
print(f'EXCEPTION: {e}')
print('now installing requests')
acmd = 'pip3 install requests'
res = subprocess.getoutput(acmd)
time.sleep(1)
import requests
try:
from tkinter import *
print('okkkkkkkkkkkk')
except Exception as e:
print(f'EXCEPTION: {e}')
print('now installing tkinter')
acmd = 'pip3 install tkinter'
res = subprocess.getoutput(acmd)
time.sleep(1)
from tkinter import *
# создание окна
root = Tk()
root.geometry('500x300')
root.title('youtube downloader')
Label(root, text = "downloader YT", font = 'arial 20 bold').pack()
# поле для ссылки
link = StringVar()
Label(root, text = 'please here:', font = 'arial 15 bold').place(x = 160, y = 60)
link_enter = Entry(root, width = 70,textvariable = link).place(x = 32, y = 90)
def download_url():
opendir()
try:
import yt_dlp
print('ok')
except Exception as e:
print(f'EXCEPTION: {e}')
print('now installing')
acmd = 'pip3 install yt_dlp'
res = subprocess.getoutput(acmd)
time.sleep(1)
import yt_dlp
url = str(link.get())
Label(root, text = 'Downloaded', font = 'arial 15').place(x = 180, y = 210)
ydl_opts = {
'ignoreerrors': True
}
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
error_code = ydl.download(url)
print(error_code)
filename = ''
return filename
def opendir():
filename = os.path.basename(__file__)
currdir = os.path.abspath(__file__).replace(filename, '')
if sys.platform.startswith('win'):
filename = os.path.basename(__file__)
currdir = os.path.abspath(__file__).replace(filename, '')
norm_path = os.path.normpath(currdir)
os.system('start "" "' + norm_path + '"')
else:
os.system('xdg-open "%s"' % currdir)
return
Button(root, text = 'Download', font = 'arial 15 bold', bg = 'pale violet red', padx = 2,command = download_url).place(x = 80, y = 150)
Button(root, text = 'Open dir', font = 'arial 15 bold', bg = 'pale violet red', padx = 2,command = opendir).place(x = 290, y = 150)
root.mainloop()