Created
October 31, 2023 05:06
-
-
Save realamirhe/75e3410da65cbb81a8fc21305051cf33 to your computer and use it in GitHub Desktop.
download youtube playlist
This file contains hidden or 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
| # !pip install python-slugify pytube -q | |
| from pytube import Playlist | |
| from slugify import slugify | |
| playlist_url = 'https://www.youtube.com/playlist?list=PLUl4u3cNGP63Wy1oqQW2oD2HBdDSY8Ghi' | |
| playlist = Playlist(playlist_url) | |
| print(f'Downloading: {playlist.title}') | |
| output_dir = slugify(playlist.title) | |
| # !mkdir -p $output_dir | |
| for video in playlist.videos: | |
| ( | |
| video | |
| .streams | |
| .filter(progressive=True, file_extension='mp4') | |
| .order_by('resolution') | |
| .desc() | |
| .first() | |
| .download(output_path=output_dir) | |
| ) | |
| zip_size_in_GB = 1 | |
| zip_size_in_GB = f"{zip_size_in_GB}g" | |
| output_zip = f"{output_dir}.zip" | |
| # !zip -s $zip_size_in_GB $output_zip $output_dir/*mp4 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run gist in this collab