3939DOWNLOAD_SPECIFIC_SUBTITLE = config_manager .get_list ('M3U8_DOWNLOAD' , 'specific_list_subtitles' )
4040MERGE_SUBTITLE = config_manager .get_bool ('M3U8_DOWNLOAD' , 'merge_subs' )
4141CLEANUP_TMP = config_manager .get_bool ('M3U8_DOWNLOAD' , 'cleanup_tmp_folder' )
42+ GET_ONLY_LINK = config_manager .get_int ('M3U8_DOWNLOAD' , 'get_only_link' )
4243FILTER_CUSTOM_RESOLUTION = str (config_manager .get ('M3U8_CONVERSION' , 'force_resolution' )).strip ().lower ()
4344RETRY_LIMIT = config_manager .get_int ('REQUESTS' , 'max_retry' )
4445MAX_TIMEOUT = config_manager .get_int ("REQUESTS" , "timeout" )
@@ -211,10 +212,10 @@ def log_selection(self):
211212 # Get available subtitles and their languages
212213 available_subtitles = self .parser ._subtitle .get_all_uris_and_names () or []
213214 available_sub_languages = [sub .get ('language' ) for sub in available_subtitles ]
214-
215+
215216 # If "*" is in DOWNLOAD_SPECIFIC_SUBTITLE, all languages are downloadable
216217 downloadable_sub_languages = available_sub_languages if "*" in DOWNLOAD_SPECIFIC_SUBTITLE else list (set (available_sub_languages ) & set (DOWNLOAD_SPECIFIC_SUBTITLE ))
217-
218+
218219 if available_sub_languages :
219220 console .print (
220221 f"[cyan bold]Subtitle [/cyan bold] [green]Available:[/green] [purple]{ ', ' .join (available_sub_languages )} [/purple] | "
@@ -260,7 +261,7 @@ def download_video(self, video_url: str):
260261
261262 if result .get ('stopped' , False ):
262263 self .stopped = True
263-
264+
264265 return self .stopped
265266
266267 def download_audio (self , audio : Dict ):
@@ -304,7 +305,7 @@ def download_all(self, video_url: str, audio_streams: List[Dict], sub_streams: L
304305 """
305306 return_stopped = False
306307 video_file = os .path .join (self .temp_dir , 'video' , '0.ts' )
307-
308+
308309 if not os .path .exists (video_file ):
309310 if self .download_video (video_url ):
310311 if not return_stopped :
@@ -421,8 +422,20 @@ def start(self) -> Dict[str, Any]:
421422 - is_master: Whether the M3U8 was a master playlist
422423 Or raises an exception if there's an error
423424 """
425+
426+ if GET_ONLY_LINK :
427+ console .print (f"URL: [bold red]{ self .m3u8_url } [/bold red]" )
428+ return {
429+ 'path' : None ,
430+ 'url' : self .m3u8_url ,
431+ 'is_master' : getattr (self .m3u8_manager , 'is_master' , None ),
432+ 'msg' : None ,
433+ 'error' : None ,
434+ 'stopped' : True
435+ }
436+
424437 console .print ("[cyan]You can safely stop the download with [bold]Ctrl+c[bold] [cyan] \n " )
425-
438+
426439 if TELEGRAM_BOT :
427440 bot = get_bot_instance ()
428441
@@ -440,7 +453,7 @@ def start(self) -> Dict[str, Any]:
440453 if TELEGRAM_BOT :
441454 bot .send_message ("Contenuto già scaricato!" , None )
442455 return response
443-
456+
444457 self .path_manager .setup_directories ()
445458
446459 # Parse M3U8 and determine if it's a master playlist
@@ -524,15 +537,15 @@ def _print_summary(self, use_shortest):
524537
525538 if missing_ts :
526539 panel_content += f"\n { missing_info } "
527-
540+
528541 new_filename = self .path_manager .output_path
529542 if missing_ts and use_shortest :
530543 new_filename = new_filename .replace (".mp4" , "_failed_sync_ts.mp4" )
531544 elif missing_ts :
532545 new_filename = new_filename .replace (".mp4" , "_failed_ts.mp4" )
533546 elif use_shortest :
534547 new_filename = new_filename .replace (".mp4" , "_failed_sync.mp4" )
535-
548+
536549 if missing_ts or use_shortest :
537550 os .rename (self .path_manager .output_path , new_filename )
538551 self .path_manager .output_path = new_filename
@@ -541,4 +554,4 @@ def _print_summary(self, use_shortest):
541554 panel_content ,
542555 title = f"{ os .path .basename (self .path_manager .output_path .replace ('.mp4' , '' ))} " ,
543556 border_style = "green"
544- ))
557+ ))
0 commit comments