-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
67 lines (50 loc) · 1.84 KB
/
Copy pathmain.py
File metadata and controls
67 lines (50 loc) · 1.84 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import tkinter as tk
from tkinter import *
from config import *
from widgets import *
from util.yt_utils import sortStreamsByQuality
class YTDL_Window:
# Don't edit the spaces, it's for padding
VIDEO_INFO_KEYS = [
"Title ",
"Length",
"Author",
"Date "
]
def __init__(self):
master = tk.Tk()
self.master = master
master.title(TITLE)
master.geometry(WINDOW_SIZE)
master.resizable(RESIZE_W, RESIZE_H)
# Widgets
self.inputFrame = InputFrame(self, "Video URL: ")
self.infoFrame = InfoFrame(self, self.VIDEO_INFO_KEYS)
# Listbox(es) for streams
self.videoWithAudioListbox = StreamList(self, [], "Video with audio")
self.onlyVideoListbox = StreamList(self, [], "Video only")
self.onlyAudioListbox = StreamList(self, [], "Audio only", isAudio=True)
def exec(self, video, streams):
# Returns string, which means the video cannot be downloaded now
if (type(video) == str):
print(video)
return
# Update the video's info
self.infoFrame.update(video)
# Update stream lists
onlyAudio = streams.filter(only_audio=True)
onlyVideo = streams.filter(only_video=True)
videoWithAudio = (set(streams) - set(onlyVideo)) - set(onlyAudio)
videoWithAudio = sortStreamsByQuality(list(videoWithAudio))
onlyAudio = sortStreamsByQuality(list(onlyAudio))
onlyVideo = list(onlyVideo) # This doesn't need to sort somehow
self.videoWithAudioListbox.update(videoWithAudio)
self.onlyVideoListbox.update(onlyVideo)
self.onlyAudioListbox.update(onlyAudio)
def start(self):
self.master.mainloop()
def main():
window = YTDL_Window()
window.start()
if (__name__ == "__main__"):
main()