@@ -159,6 +159,15 @@ def add_scheduled_dialog(self):
159159 dialog = ScheduleAddDialog (self )
160160 dialog .exec_ ()
161161 def start_queue (self ):
162+ download_path = self .user_profile .get_download_path ()
163+ if not os .path .exists (download_path ):
164+ QMessageBox .warning (self , "Invalid Download Path" ,
165+ f"Download folder does not exist:\n { download_path } \n \n "
166+ "The folder may have been deleted or the drive may be disconnected.\n "
167+ "Please select a new download location in Settings." )
168+ self .append_log (f"Queue start aborted - invalid path: { download_path } " )
169+ return
170+
162171 count_started = 0
163172 for r in range (self .queue_table .rowCount ()):
164173 st_item = self .queue_table .item (r , 4 )
@@ -170,7 +179,7 @@ def start_queue(self):
170179 playlist = ("playlist" in typ )
171180 current_format = "mp4"
172181 row_idx = r
173- tsk = DownloadTask (url , self .user_profile .get_default_resolution (), self . user_profile . get_download_path () , self .user_profile .get_proxy (), audio_only = audio , playlist = playlist , output_format = current_format , audio_format = self .user_profile .get_audio_format () if audio else None , audio_quality = self .user_profile .get_audio_quality () if audio else "320" , from_queue = True )
182+ tsk = DownloadTask (url , self .user_profile .get_default_resolution (), download_path , self .user_profile .get_proxy (), audio_only = audio , playlist = playlist , output_format = current_format , audio_format = self .user_profile .get_audio_format () if audio else None , audio_quality = self .user_profile .get_audio_quality () if audio else "320" , from_queue = True )
174183 self .run_task (tsk , row_idx )
175184 self .queue_table .setItem (r , 4 , QTableWidgetItem ("Started" ))
176185 count_started += 1
@@ -182,6 +191,11 @@ def remove_scheduled_item(self):
182191 for r in sorted (sel , reverse = True ):
183192 self .scheduler_table .removeRow (r )
184193 def check_scheduled_downloads (self ):
194+ download_path = self .user_profile .get_download_path ()
195+ if not os .path .exists (download_path ):
196+ self .append_log (f"Scheduled download skipped - invalid path: { download_path } " )
197+ return
198+
185199 now = QDateTime .currentDateTime ()
186200 for r in range (self .scheduler_table .rowCount ()):
187201 dt_str = self .scheduler_table .item (r , 0 ).text ()
@@ -192,16 +206,25 @@ def check_scheduled_downloads(self):
192206 t = self .scheduler_table .item (r , 2 ).text ().lower ()
193207 s = (self .scheduler_table .item (r , 3 ).text () == "Yes" )
194208 audio = ("audio" in t )
195- task = DownloadTask (u , self .user_profile .get_default_resolution (), self . user_profile . get_download_path () , self .user_profile .get_proxy (), audio_only = audio , playlist = False , subtitles = s , audio_format = self .user_profile .get_audio_format () if audio else None , audio_quality = self .user_profile .get_audio_quality () if audio else "320" , from_queue = True )
209+ task = DownloadTask (u , self .user_profile .get_default_resolution (), download_path , self .user_profile .get_proxy (), audio_only = audio , playlist = False , subtitles = s , audio_format = self .user_profile .get_audio_format () if audio else None , audio_quality = self .user_profile .get_audio_quality () if audio else "320" , from_queue = True )
196210 self .run_task (task , r )
197211 self .scheduler_table .setItem (r , 4 , QTableWidgetItem ("Started" ))
198212 def start_download_simple (self , url_edit , audio = False , playlist = False ):
199213 link = url_edit .text ().strip ()
200214 if not link :
201215 QMessageBox .warning (self , "Error" , "No URL given." )
202216 return
203- task = DownloadTask (link , self .user_profile .get_default_resolution (), self .user_profile .get_download_path (), self .user_profile .get_proxy (), audio_only = audio , playlist = playlist , audio_format = self .user_profile .get_audio_format () if audio else None , audio_quality = self .user_profile .get_audio_quality () if audio else "320" , from_queue = False )
204- # History will be written directly by the downloader
217+
218+ download_path = self .user_profile .get_download_path ()
219+ if not os .path .exists (download_path ):
220+ QMessageBox .warning (self , "Invalid Download Path" ,
221+ f"Download folder does not exist:\n { download_path } \n \n "
222+ "The folder may have been deleted or the drive may be disconnected.\n "
223+ "Please select a new download location in Settings." )
224+ self .append_log (f"Download aborted - invalid path: { download_path } " )
225+ return
226+
227+ task = DownloadTask (link , self .user_profile .get_default_resolution (), download_path , self .user_profile .get_proxy (), audio_only = audio , playlist = playlist , audio_format = self .user_profile .get_audio_format () if audio else None , audio_quality = self .user_profile .get_audio_quality () if audio else "320" , from_queue = False )
205228 self .run_task (task , None )
206229 def run_task (self , task , row ):
207230 if task .playlist :
@@ -283,12 +306,20 @@ def update_queue_info(self, row, title, channel):
283306 # History will be written directly by the downloader
284307 def open_download_folder (self ):
285308 folder = self .user_profile .get_download_path ()
309+ if not os .path .exists (folder ):
310+ QMessageBox .warning (self , "Folder Not Found" ,
311+ f"Download folder does not exist:\n { folder } \n \n "
312+ "The folder may have been deleted or the drive may be disconnected.\n "
313+ "Please select a new download location in Settings." )
314+ self .append_log (f"Cannot open folder - path does not exist: { folder } " )
315+ return
316+
286317 try :
287318 if sys .platform .startswith ('win' ):
288319 os .startfile (folder )
289- elif sys .platform .startswith ('darwin' ): # macOS
320+ elif sys .platform .startswith ('darwin' ):
290321 subprocess .run (['open' , folder ])
291- else : # Linux
322+ else :
292323 subprocess .run (['xdg-open' , folder ])
293324 except (OSError , subprocess .SubprocessError , FileNotFoundError ) as e :
294325 QMessageBox .warning (self , "Error" , f"Could not open folder: { str (e )} " )
0 commit comments