aboutsummaryrefslogtreecommitdiffstats
path: root/src/youload_playlist.py
diff options
context:
space:
mode:
authornathansmithsmith <nathansmith7@mailfence.com>2023-11-09 20:53:10 +0000
committernathansmithsmith <nathansmith7@mailfence.com>2023-11-09 20:53:10 +0000
commit40b98d98f8dcc7b8a6da46e825d667989a436c67 (patch)
tree140e3dcd1d2897feaa9527e756a0d103266ba9a4 /src/youload_playlist.py
parentc01b36209a12fe7b19ee4ba8a3a467697d9bbf5f (diff)
downloadyouload-40b98d98f8dcc7b8a6da46e825d667989a436c67.tar.gz
youload-40b98d98f8dcc7b8a6da46e825d667989a436c67.tar.bz2
youload-40b98d98f8dcc7b8a6da46e825d667989a436c67.zip
Added download types
Diffstat (limited to 'src/youload_playlist.py')
-rw-r--r--src/youload_playlist.py37
1 files changed, 0 insertions, 37 deletions
diff --git a/src/youload_playlist.py b/src/youload_playlist.py
deleted file mode 100644
index 803b1c1..0000000
--- a/src/youload_playlist.py
+++ /dev/null
@@ -1,37 +0,0 @@
-from pytube import Playlist
-import os
-
-def make_alpha_numeric(string: str) -> str:
- return "".join(char for char in string if char.isalnum())
-
-class YouLoadPlayList:
- """A class for download and handling youtube playlists"""
-
- def __init__(self, link: str):
- self.yt_playlist = Playlist(link)
- self.video_count = len(self.yt_playlist.videos)
- self.folder_name = make_alpha_numeric(self.yt_playlist.title)
-
- def generate_video_info(self, video_num: int) -> str:
- """Returns information on video in playlist at 'video_num'"""
-
- video = self.yt_playlist.videos[video_num]
- video_size = video.streams.get_highest_resolution().filesize // 1048576
- return f"Title: {video.title}, Size: {video_size} MB"
-
- def set_download_directory(self, directory: str) -> None:
- """Sets where the playlist folder will be downloaded"""
- self.folder_name = os.path.join(directory, make_alpha_numeric(self.yt_playlist.title))
-
- def prepare_for_download(self) -> None:
- """Gets the playlist ready for download. Creates the output folder and that stuff."""
- os.mkdir(self.folder_name)
-
- def download_video(self, video_num: int) -> str:
- """Download video at 'video_num'"""
- video = self.yt_playlist.videos[video_num]
- video_size = video.streams.get_highest_resolution().filesize
- video.streams.get_highest_resolution().download(output_path=self.folder_name)
-
- return f"Title: {video.title}, Size: {video_size // (1024 ** 2)} MB"
-