Skip to content

Instantly share code, notes, and snippets.

@Tknott95
Last active March 21, 2023 19:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tknott95/78b150bfab24af7aa0f50717fa7eeea6 to your computer and use it in GitHub Desktop.
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
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()
@Tknott95
Copy link
Author

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment