Skip to content
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

Add youtube download quality opts #8

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<<<<<<< HEAD
altgraph==0.17
appdirs==1.4.4
asgiref==3.2.7
autopep8==1.5.3
beautifulsoup4==4.9.1
cachetools==4.1.0
camelcase==0.2
certifi==2020.4.5.1
chardet==3.0.4
click==7.1.2
comtypes==1.1.7
Expand All @@ -23,7 +21,6 @@ google-api-core==1.17.0
google-auth==1.14.3
googleapis-common-protos==1.51.0
grpcio==1.28.1
idna==2.9
itsdangerous==1.1.0
Jinja2==2.11.2
joblib==0.15.1
Expand Down Expand Up @@ -51,17 +48,14 @@ pypiwin32==223
PyRect==0.1.4
PyScreeze==0.1.26
python-dateutil==2.8.1
pyttsx3==2.71
PyTweening==1.0.3
pytz==2020.1
pywin32==228
pywin32-ctypes==0.2.0
ratelim==0.1.6
requests==2.23.0
rsa==4.0
scikit-learn==0.23.1
scipy==1.5.0
six==1.14.0
sklearn==0.0
soupsieve==2.0.1
SpeechRecognition==3.8.1
Expand All @@ -76,7 +70,6 @@ Werkzeug==1.0.1
wikipedia==1.4.0
wit==5.1.0
youtube-search==0.1.4
=======
beautifulsoup4==4.9.1
bidict==0.19.0
certifi==2020.6.20
Expand Down Expand Up @@ -211,4 +204,3 @@ soupsieve==2.0.1
SpeechRecognition==3.8.1
urllib3==1.25.9
wikipedia==1.4.0
>>>>>>> cb24880e4000225a63a59278a3e967f3cee6ab15
25 changes: 19 additions & 6 deletions youtube_downloader.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
from pytube import *
from pytube import YouTube
from tkinter import *
from tkinter.filedialog import *
from tkinter.messagebox import *
from threading import *
file_size = 0

def create_youtube_object(url, progress):
return YouTube(url, on_progress_callback=progress).streams

def pick_resolution(streams, value):
objects_with_res = [stream for stream in streams if stream.resolution == value]
return objects_with_res[0]

def progress(stream=None, chunk=None, remaining=None):
file_downloaded = (file_size-remaining)
Expand All @@ -15,14 +21,16 @@ def progress(stream=None, chunk=None, remaining=None):
def startDownload():
global file_size
try:
print("Starting download")
URL = urlField.get()
resolution = resolutionField.get()
dBtn.config(text='Please wait...')
dBtn.config(state=DISABLED)
path_save = askdirectory()
if path_save is None:
return
ob = YouTube(URL, on_progress_callback=progress)
strm = ob.streams[0]
stream_list = create_youtube_object(URL, progress)
strm = pick_resolution(stream_list, resolution)
x = ob.description.split("|")
file_size = strm.filesize
dfile_size = file_size
Expand All @@ -40,6 +48,7 @@ def startDownload():
label.pack_forget()
desc.pack_forget()
dBtn.config(text='Start Download')
print("Finishing download")

except Exception as e:
print(e)
Expand All @@ -60,15 +69,19 @@ def startDownloadthread():

main.geometry("500x600")

file = PhotoImage(
file='images\\photo.png')
file = PhotoImage(file='images\\photo.png')

headingIcon = Label(main, image=file)
headingIcon.pack(side=TOP)

urlField = Entry(main, font=("Times New Roman", 18), justify=CENTER)

urlField.insert(0, "YouTube video URL")
urlField.pack(side=TOP, fill=X, padx=10, pady=15)

resolutionField = Entry(main, font=("Times New Roman", 18), justify=CENTER)
resolutionField.insert(0, "Desired resolution, ex: 144p or 360p")
resolutionField.pack(side=TOP, fill=X, padx=10, pady=15)


dBtn = Button(main, text="Start Download", font=(
"Times New Roman", 18), relief='ridge', activeforeground='red', command=startDownloadthread)
Expand Down