diff options
author | nathansmithsmith <nathansmith7@mailfence.com> | 2023-11-09 18:40:27 +0000 |
---|---|---|
committer | nathansmithsmith <nathansmith7@mailfence.com> | 2023-11-09 18:40:27 +0000 |
commit | c01b36209a12fe7b19ee4ba8a3a467697d9bbf5f (patch) | |
tree | 09b39f8cb6288c127be2534dcf3305e9a29f9791 | |
parent | a923bfde6c4612f013c40354a3726aa1f06de15c (diff) | |
download | youload-c01b36209a12fe7b19ee4ba8a3a467697d9bbf5f.tar.gz youload-c01b36209a12fe7b19ee4ba8a3a467697d9bbf5f.tar.bz2 youload-c01b36209a12fe7b19ee4ba8a3a467697d9bbf5f.zip |
Folder already exists error handled
-rw-r--r-- | src/model/youload_app.py | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/src/model/youload_app.py b/src/model/youload_app.py index b75aee6..6d20b22 100644 --- a/src/model/youload_app.py +++ b/src/model/youload_app.py @@ -45,7 +45,7 @@ class YouloadApp(App): self.folder_display = Label(text=str(Path.home()), size_hint=(0.4, 1.0)) # choose folder button. - self.choose_folder_button = Button(text="Choose folder", size_hint=(0.2, 1.0)) + self.choose_folder_button = Button(text="Folder", size_hint=(0.2, 1.0)) self.choose_folder_button.bind(on_press=self.choose_folder_cb) # Info line. @@ -77,32 +77,36 @@ class YouloadApp(App): # Download the videos in a different thread so the ui still works. def download_playlist_thread(self): - self.download_status.text = "Fetching playlist" - self.submit.text = "Stop" - self.is_downloading = True - - # Get playlist. try: + self.download_status.text = "Fetching playlist" + self.submit.text = "Stop" + self.is_downloading = True + + # Get playlist. playlist = YouLoadPlayList(self.url) - except KeyError: - self.download_status.text = "Error getting playlist" - return - playlist.set_download_directory(self.folder_display.text) - playlist.prepare_for_download() - self.downloads_display.text = f"Downloading to {playlist.folder_name}\n" + # Set directory and other stuff. + playlist.set_download_directory(self.folder_display.text) + playlist.prepare_for_download() + self.downloads_display.text = f"Downloading to {playlist.folder_name}\n" + + # Download each video + for i in range(playlist.video_count): + # Stop this mother fucker + if self.should_stop_download: + break - # Download each video - for i in range(playlist.video_count): - # Stop this mother fucker - if self.should_stop_download: - break + self.download_status.text = f"Downloading {i+1}/{playlist.video_count}" + self.downloads_display.text += playlist.download_video(i) + "\n" - self.download_status.text = f"Downloading {i+1}/{playlist.video_count}" - self.downloads_display.text += playlist.download_video(i) + "\n" + # Complete download. + self.download_status.text = "Download complete" + except FileExistsError: + self.download_status.text = "Folder already exists" + except KeyError: + self.download_status.text = "Error getting playlist" self.submit.text = "Download" - self.download_status.text = "Download complete" self.is_downloading = False def stop_download(self): |