From 563499ce3d39be5e906a62260e3098c14994f698 Mon Sep 17 00:00:00 2001 From: nathansmithsmith Date: Sun, 14 Jan 2024 15:32:48 -0700 Subject: Numbers added --- src/model/youload_playlist.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/model/youload_playlist.py') diff --git a/src/model/youload_playlist.py b/src/model/youload_playlist.py index f23533f..a021b83 100644 --- a/src/model/youload_playlist.py +++ b/src/model/youload_playlist.py @@ -31,20 +31,26 @@ class YouLoadPlayList: """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: + def download_video(self, video_num: int, use_prefix: bool) -> str: """Download video at 'video_num'""" video = self.yt_playlist.videos[video_num] video_size = video.streams.get_highest_resolution().filesize + # Create prefix. + filename_prefix = "" + + if use_prefix: + filename_prefix = str(video_num + 1) + " " + # Download this fucker. if self.download_type == "highest": - video.streams.get_highest_resolution().download(output_path=self.folder_name) + video.streams.get_highest_resolution().download(output_path=self.folder_name, filename_prefix=filename_prefix) elif self.download_type == "lowest": - video.streams.get_lowest_resolution().download(output_path=self.folder_name) + video.streams.get_lowest_resolution().download(output_path=self.folder_name, filename_prefix=filename_prefix) elif self.download_type == "audio": - video.streams.get_audio_only().download(output_path=self.folder_name) + video.streams.get_audio_only().download(output_path=self.folder_name, filename_prefix=filename_prefix) else: - video.streams.get_by_resolution(self.download_type).download(output_path=self.folder_name) + video.streams.get_by_resolution(self.download_type).download(output_path=self.folder_name, filename_prefix=filename_prefix) return f"Title: {video.title}, Size: {video_size // (1024 ** 2)} MB" -- cgit v1.2.3