@@ -115,30 +115,34 @@ def parse_manifest(self, custom_headers):
115115 # Auto-select subtitles based on selected audio language
116116 selected_audio_language = self .selected_audio .get ('language' ) if self .selected_audio else None
117117
118- if "*" in DOWNLOAD_SPECIFIC_SUBTITLE :
119- self .selected_subs = self .mpd_sub_list
120- elif selected_audio_language and selected_audio_language in DOWNLOAD_SPECIFIC_SUBTITLE :
121- # If audio language is in the specific list, prioritize it
122- self .selected_subs = [
123- sub for sub in self .mpd_sub_list
124- if sub .get ('language' ) == selected_audio_language
125- ]
118+ # Only process subtitles if mpd_sub_list is not None
119+ if self .mpd_sub_list is not None :
120+ if "*" in DOWNLOAD_SPECIFIC_SUBTITLE :
121+ self .selected_subs = self .mpd_sub_list
122+ elif selected_audio_language and selected_audio_language in DOWNLOAD_SPECIFIC_SUBTITLE :
123+ # If audio language is in the specific list, prioritize it
124+ self .selected_subs = [
125+ sub for sub in self .mpd_sub_list
126+ if sub .get ('language' ) == selected_audio_language
127+ ]
128+ else :
129+ # Fallback to configured languages
130+ self .selected_subs = [
131+ sub for sub in self .mpd_sub_list
132+ if sub .get ('language' ) in DOWNLOAD_SPECIFIC_SUBTITLE
133+ ]
134+
135+ # If no subtitles match configuration but we have audio language, auto-select matching subtitle
136+ if not self .selected_subs and selected_audio_language :
137+ matching_subs = [
138+ sub for sub in self .mpd_sub_list
139+ if sub .get ('language' ) == selected_audio_language
140+ ]
141+ if matching_subs :
142+ console .print (f"[yellow]Auto-selecting subtitle for audio language: { selected_audio_language } " )
143+ self .selected_subs = matching_subs
126144 else :
127- # Fallback to configured languages
128- self .selected_subs = [
129- sub for sub in self .mpd_sub_list
130- if sub .get ('language' ) in DOWNLOAD_SPECIFIC_SUBTITLE
131- ]
132-
133- # If no subtitles match configuration but we have audio language, auto-select matching subtitle
134- if not self .selected_subs and selected_audio_language :
135- matching_subs = [
136- sub for sub in self .mpd_sub_list
137- if sub .get ('language' ) == selected_audio_language
138- ]
139- if matching_subs :
140- console .print (f"[yellow]Auto-selecting subtitle for audio language: { selected_audio_language } " )
141- self .selected_subs = matching_subs
145+ self .selected_subs = []
142146
143147 # Print table with selections (only once here)
144148 self .parser .print_tracks_table (self .selected_video , self .selected_audio , self .selected_subs )
@@ -159,7 +163,7 @@ def download_subtitles(self) -> bool:
159163 Download subtitle files based on parser's selected subtitles with retry mechanism.
160164 Returns True if successful or if no subtitles to download, False on critical error.
161165 """
162- if not self .selected_subs :
166+ if not self .selected_subs or self . mpd_sub_list is None :
163167 return True
164168
165169 client = create_client (headers = {'User-Agent' : get_userAgent ()})
@@ -505,7 +509,7 @@ def finalize_output(self):
505509 return None
506510
507511 # Merge subtitles if available
508- if MERGE_SUBTITLE and self .selected_subs :
512+ if MERGE_SUBTITLE and self .selected_subs and self . mpd_sub_list is not None :
509513
510514 # Check which subtitle files actually exist
511515 existing_sub_tracks = []
0 commit comments