Merge pull request #296 from rahulkarda/master

Add youtube_playlist_downloader script
This commit is contained in:
Agnish Ghosh 2022-10-10 11:19:18 +05:30 committed by GitHub
commit 00c40b08cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 65 additions and 0 deletions

View File

@ -0,0 +1,11 @@
# Youtube Playlist Downloader
This is a simple script that lets you download each video in a youtbue playlist.
## Installations
pip install python-youtube
pip install pytube
## Usage
1. Clone the repo
2. Download the requirements
3. Run python script.py

View File

@ -0,0 +1,54 @@
from tkinter import *
from pyyoutube import Api
from pytube import YouTube
from threading import Thread
from tkinter import messagebox
def threading():
t1 = Thread(target=download_videos)
t1.start()
def download_videos():
api = Api(api_key='Enter API Key')
if "youtube" in playlistId.get():
playlist_id = playlistId.get()[len(
"https://www.youtube.com/playlist?list="):]
else:
playlist_id = playlistId.get()
playlist_item_by_id = api.get_playlist_items(
playlist_id=playlist_id, count=None, return_json=True)
for index, videoid in enumerate(playlist_item_by_id['items']):
link = f"https://www.youtube.com/watch?v={videoid['contentDetails']['videoId']}"
yt_obj = YouTube(link)
filters = yt_obj.streams.filter(progressive=True, file_extension='mp4')
filters.get_highest_resolution().download()
print(f"Downloaded:- {link}")
messagebox.showinfo("Success", "Video Successfully downloaded")
root = Tk()
root.geometry('400x200')
Label(root, text="Youtube Playlist Downloader",
font="italic 15 bold").pack(pady=10)
Label(root, text="Enter Playlist URL:-", font="italic 10").pack()
playlistId = Entry(root, width=60)
playlistId.pack(pady=5)
download_start = Button(root, text="Download Start", command=threading)
download_start.pack(pady=10)
root.mainloop()