tkinter yt downloader with resolution

Solutions on MaxInterview for tkinter yt downloader with resolution by the best coders in the world

showing results for - "tkinter yt downloader with resolution"
Domenico
18 Sep 2019
1from tkinter import *
2import pafy
3
4class YouTubeDownloader:
5    def __init__(self,master):
6        self.master = master
7        master.title("Youtube Downloader")
8        self.media_option = StringVar()
9        self.audio_quality_lsit = []
10        self.audio_quality_drop_menu = StringVar()
11        self.video_quality_lsit = []
12        self.video_quality_drop_menu = StringVar()
13        Label(master, text="YouTube URL:").grid(row=0)
14        self.url_field = Entry(master)
15        self.url_field.grid(row=0, column=1)
16        Button(master, text='Paste URL', command=self.url).grid(row=0, column=4, sticky=W, pady=10)
17        Button(master, text='Download', command=self.download).grid(row=12, column=4, sticky=W, pady=10)
18        Label(master, text="Media Type: ").grid(row=3)
19        media_drop_menu = OptionMenu(master, self.media_option, "Audio", "Video", command=self.media_select)
20        media_drop_menu.grid(row=5, column=0)
21
22
23    def url(self):
24        global data
25        url = self.url_field.get()
26        data = pafy.new(url)
27
28
29    def media_select(self):
30        global  A_V
31        A_V = self.media_option.get()
32        if A_V == "Audio":
33            audio()
34        elif A_V == "Video":
35            video()
36
37
38    def audio():
39        global selected_audio
40        audio_streams = self.data.audiostreams
41        for audio_quality in audio_streams:
42            audio_quality_lsit.append(audio_quality.bitrate)
43        selected_audio = audio_quality_drop_menu.get()
44        print("selected_audio") #Debug Statement
45        Label(master, text="Audio Bitrate: ").grid(row=7, column=1)
46        show_drop_menu = OptionMenu(master, audio_quality_drop_menu, *audio_quality_lsit)
47        show_drop_menu.grid(row=9, column=1)
48
49
50    def video(self):
51        global selected_video
52        video_streams = self.data.streams
53        for video_quality in video_streams:
54            video_quality_lsit.append(video_quality.resolution)
55        selected_video = video_quality_drop_menu.get()
56        print("selected_video")  #Debug Statement
57        Label(master, text="Video Quality: ").grid(row=7, column=1)
58        show_drop_menu = OptionMenu(master, video_quality_drop_menu, *video_quality_lsit)
59        show_drop_menu.grid(row=9, column=1)
60
61
62    def download(self):
63        if selected_audio:
64            print("Audio")  #Debug Statement
65            self.selected_audio.download(quiet=False)
66        elif selected_video:
67            print("Video")  #Debug Statement
68            self.selected_video.download(quiet=False)
69
70
71
72root = Tk()
73my_youtube = YouTubeDownloader(root)
74root.mainloop()
75
similar questions
queries leading to this page
tkinter yt downloader with resolution