mirror of
https://github.com/metafy-social/python-scripts.git
synced 2024-11-23 20:11:10 +00:00
Merge pull request #296 from rahulkarda/master
Add youtube_playlist_downloader script
This commit is contained in:
commit
00c40b08cc
11
scripts/youtube_playlist_downloader/README.md
Normal file
11
scripts/youtube_playlist_downloader/README.md
Normal 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
|
54
scripts/youtube_playlist_downloader/script.py
Normal file
54
scripts/youtube_playlist_downloader/script.py
Normal 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()
|
Loading…
Reference in New Issue
Block a user