aboutsummaryrefslogtreecommitdiffstats
path: root/src/model/youload_app.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/model/youload_app.py')
-rw-r--r--src/model/youload_app.py44
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):