diff options
Diffstat (limited to 'src/model/youload_playlist.py')
-rw-r--r-- | src/model/youload_playlist.py | 16 |
1 files changed, 11 insertions, 5 deletions
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" |