Last active
March 21, 2023 19:15
-
-
Save Tknott95/78b150bfab24af7aa0f50717fa7eeea6 to your computer and use it in GitHub Desktop.
pychive - the quick and dirty python yotuube playlist archiver (willk add flags for diff types of archiving). This is faster than yt_dlp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import pytube | |
from multiprocessing import Process | |
playlist_url = input("Enter the playlist url: ") | |
folder_name = input("Enter the folder name where the videos will be downloaded: ") | |
procs_running = [] | |
if not os.path.exists(folder_name): | |
os.mkdir(folder_name) | |
i = 0 | |
playlist = pytube.Playlist(playlist_url) | |
for vid in playlist.videos: | |
i += 1 | |
list_length = len(playlist.videos) | |
print(f'\n{i}/{list_length} | {(i*100) / list_length}% COMPLETE') | |
my_proc = Process(target=lambda : vid.streams.get_highest_resolution().download(f'./{folder_name}/')) | |
my_proc.start() | |
procs_running.append(my_proc) | |
print(f'DOWNLOADED: {vid.streams[0].title}') | |
# jpin waits for procs to end then temrinates. This makes sure videos that are downloading in procs all finish | |
for ijk in procs_running: | |
ijk.join() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if breaking (after march 19th), change a line in ~/.local/lib/python3.10/pytube/cipher.py or whatever /lib/ you have your python stored in pytube/pytube#1519 (comment)