Skip to content

Added YouTube video downloader #620

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 25, 2021

Conversation

mehabhalodiya
Copy link
Contributor

Description

To implement this, I have used basic concept of python, tkinter and pytube library.

  • Tkinter is a standard GUI library and it is one of the easiest ways to build a GUI application.
  • pytube used for downloading videos from youtube

Fixes #602 YouTube Video Downloader with GUI

Have you read the Contributing Guidelines on Pull Requests?

  • Yes
  • No

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code follows the style guidelines(Clean Code) of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have created a helpful and easy to understand README.md
  • My documentation follows Template for README.md
  • My changes generate no new warnings
  • I have added tests/screenshots that prove my feature is effective or that my feature works.

link = StringVar()

Label(root, text = 'Paste Link Here:', font = 'arial 15 bold').place(x = 270 , y = 60)
link_enter = Entry(root, width = 80,textvariable = link).place(x = 32, y = 90)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Entry function doesn't have any return value , why are you assigning it to a variable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated!
Thank you :)

Copy link
Contributor

@kaustubhgupta kaustubhgupta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 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, ...)

@kaustubhgupta kaustubhgupta added the enhancement New feature or request label Mar 17, 2021
@mehabhalodiya
Copy link
Contributor Author

  • 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 will implement the feature of progress bar.
I am not getting about quality control download!

I need your help! Please help me out, I am ready to work.

@kaustubhgupta
Copy link
Contributor

@mehabhalodiya Refer to this: https://python-pytube.readthedocs.io/en/latest/user/streams.html#filtering-streams

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">]

@kaustubhgupta
Copy link
Contributor

@mehabhalodiya updates?

@kaustubhgupta
Copy link
Contributor

@mehabhalodiya Final updates: did you found the workaround or should I assign it to someone else?

@kaustubhgupta kaustubhgupta added hold Needs a second thought and removed enhancement New feature or request labels Mar 21, 2021
@kaustubhgupta
Copy link
Contributor

@mehabhalodiya If you are unable to add quality options, you can add the progress bar and we will accept that submission

@kaustubhgupta
Copy link
Contributor

@mehabhalodiya Updates?

@mehabhalodiya
Copy link
Contributor Author

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()

@kaustubhgupta
Copy link
Contributor

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()

Did you run the script locally?
image

@mehabhalodiya
Copy link
Contributor Author

Yes, me too got stuck in this!
Tell me which lines to be added and improved.

@kaustubhgupta
Copy link
Contributor

Yes, me too got stuck in this!
Tell me which lines to be added and improved.

as the error suggests, try removing font attributes

@mehabhalodiya
Copy link
Contributor Author

Yes, me too got stuck in this!
Tell me which lines to be added and improved.

as the error suggests, try removing font attributes

Yes, but still not working :/

@kaustubhgupta
Copy link
Contributor

Yes, me too got stuck in this!
Tell me which lines to be added and improved.

as the error suggests, try removing font attributes

Yes, but still not working :/

what's the error now?

@mehabhalodiya
Copy link
Contributor Author

output

@mehabhalodiya
Copy link
Contributor Author

mehabhalodiya commented Mar 22, 2021

I have removed font, bg and padx attributes.
I think, there is some issue with progress bar! I am not sure.
Tell me if you want anything now!

@kaustubhgupta
Copy link
Contributor

I have removed font, bg and padx attributes.

okay, so now you are getting bar progress with download without any errors? If yes then update the code in PR, I will review and approve asap

@mehabhalodiya
Copy link
Contributor Author

@kaustubhgupta Let me know if I am done with the code so that I can modify!
Give me a sign to move ahead.

@kaustubhgupta
Copy link
Contributor

kaustubhgupta commented Mar 22, 2021

@kaustubhgupta Let me know if I am done with the code so that I can modify!
Give me a sign to move ahead.

Um, then copy your code, paste it as a gist and share the link here, I will run it locally and will let you know the status

@mehabhalodiya
Copy link
Contributor Author

@kaustubhgupta
Copy link
Contributor

Umm it didn't ran
image

@mehabhalodiya
Copy link
Contributor Author

So now?
I think progress bar messed up all!

@kaustubhgupta
Copy link
Contributor

So now?
I think progress bar messed up all!

I will re-review all the changes in the morning and will let you know about any changes/

@kaustubhgupta
Copy link
Contributor

@mehabhalodiya dropping the idea for the progress bar. It would require creating separate thread for this other than the main GUI thread.

@kaustubhgupta kaustubhgupta added next review needed Approved by some mentors, more approvals needed and removed hold Needs a second thought labels Mar 23, 2021
Copy link
Contributor

@santushtisharma10 santushtisharma10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice @mehabhalodiya 💯 💯

@kaustubhgupta
Copy link
Contributor

@antrikshmisri

@kaustubhgupta kaustubhgupta added Approved PR Approved and Ready to Merge gssoc23 Issues created for/by the GirlScript Summer of Code'23 Participants level2 Bug fixing, Adding small features and removed next review needed Approved by some mentors, more approvals needed labels Mar 24, 2021
@avinashkranjan avinashkranjan merged commit b2ac815 into avinashkranjan:master Mar 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approved PR Approved and Ready to Merge gssoc23 Issues created for/by the GirlScript Summer of Code'23 Participants level2 Bug fixing, Adding small features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

YouTube Video Downloader with GUI
5 participants