Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

YouTube Video Downloader #664

Discussion options

I had a question regarding:

  • Add a progress bar which shows how much the download has been completed.
  • Add the option to control the quality of the video (480, 720, ...)

I have implemented this much:
YTVD

Now, I don't know how can I add those functionalities together.
For code, check my PR: #620

I got a reference from one of the mentor :
" As the yt.streams.filter(progressive=True) returns a list of all types of resolutions in a sorted manner, you can modify the script to pick the available qualities and then present the user options to pick."

[<Stream: itag="18" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.42001E" acodec="mp4a.40.2" progressive="True" type="video">,
<Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2" progressive="True" type="video">]

Not knowing where to add!
Please help me.

You must be logged in to vote

The progress bar widget explanation can be found here: https://www.geeksforgeeks.org/progressbar-widget-in-tkinter-python . For quality control, you need to research a bit about how this library (pytube) takes the filer arguments in video downloading

Replies: 2 comments 7 replies

Comment options

The progress bar widget explanation can be found here: https://www.geeksforgeeks.org/progressbar-widget-in-tkinter-python . For quality control, you need to research a bit about how this library (pytube) takes the filer arguments in video downloading

You must be logged in to vote
7 replies
Comment options

Yes, but not able to do. Kindly help me!
@kaustubhgupta Can you please tell me, which lines I have to add to 'call bar in the downloader function' ?

Comment options

just call the bar function: bar()

Comment options

Make sure to sync the time of download(ETA) with progress bar

Comment options

Now ?

from tkinter import *
from tkinter.ttk import *
from pytube import YouTube
root = Tk()
root.geometry('700x300')
root.resizable(0,0)
root.title("YouTube Video Downloader")
Label(root,text = 'Copy the link of the video you want to download from YouTube', font = 'arial 15 bold').pack()
# enter link
link = StringVar()
Label(root, text = 'Paste Link Here:', font = 'arial 15 bold').place(x = 270 , y = 60)
Entry(root, width = 80,textvariable = link).place(x = 32, y = 90)
# progress bar widget
progress = Progressbar(root, orient = HORIZONTAL, length = 100, mode = 'determinate')
# function responsible for the updation of the progress bar value
def bar():
 import time
 progress['value'] = 20
 root.update_idletasks()
 time.sleep(1)
 progress['value'] = 40
 root.update_idletasks()
 time.sleep(1)
 progress['value'] = 50
 root.update_idletasks()
 time.sleep(1)
 progress['value'] = 60
 root.update_idletasks()
 time.sleep(1)
 progress['value'] = 80
 root.update_idletasks()
 time.sleep(1)
 progress['value'] = 100
progress.pack(pady=10)
# function to download video
def Downloader():
 url = YouTube(str(link.get()))
 video = url.streams.first()
 bar()
 video.download()
 Label(root, text = 'DOWNLOADED', font = 'arial 15').place(x = 270 , y = 210)
Button(root, text = 'DOWNLOAD', font = 'arial 15 bold', bg = 'white', padx = 2, command = Downloader).place(x = 280 ,y = 150)
root.mainloop()
Comment options

I can't review here, put this code in PR only and then I can test the code locally

Answer selected by kaustubhgupta
Comment options

  • For the quality point. you can extract the quality value using Regex, then let the user choose the desired quality. After taking your input, you re-filter the search query with adding the resolution attribute. So it will be like:

yt.streams.filter(progressive=True, resolution=quality_chosen)

Need to note that the value of the quality_chosen must end with "p" character. Like "360p", "480p", etc.

  • For the progress bar point, I'm still learning tkinter so can't help you much about it, but there is a builtin progress bar commandline

from pytube.cli import on_progress

See if there is a way to actually print that progress bar on the frame instead of bothering yourself with the calculation algorithm.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /