Skip to content

Commit

Permalink
Fix repeated subtitle queries/prompts anxdpanic#1056
Browse files Browse the repository at this point in the history
  • Loading branch information
MoojMidge committed Jan 10, 2025
1 parent 82bd28c commit 9ac3514
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
10 changes: 4 additions & 6 deletions resources/lib/youtube_plugin/youtube/helper/stream_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -1473,9 +1473,6 @@ def _process_captions(self, subtitles, responses):
subs_data = None

for client_name, response in responses.items():
if subs_data:
break

captions = response['captions']
client = response['client']
do_query = client.get('_query_subtitles')
Expand All @@ -1488,9 +1485,8 @@ def _process_captions(self, subtitles, responses):
subtitles.load(captions, client['headers'].copy())
default_lang = subtitles.get_lang_details()
subs_data = subtitles.get_subtitles()

if subs_data:
return default_lang, subs_data
if subs_data or subs_data is False:
return default_lang, subs_data

video_id = self.video_id
client_data = {'json': {'videoId': video_id}}
Expand Down Expand Up @@ -1520,6 +1516,8 @@ def _process_captions(self, subtitles, responses):
subtitles.load(captions, caption_headers)
default_lang = subtitles.get_lang_details()
subs_data = subtitles.get_subtitles()
if subs_data or subs_data is False:
return default_lang, subs_data

return default_lang, subs_data

Expand Down
15 changes: 6 additions & 9 deletions resources/lib/youtube_plugin/youtube/helper/subtitles.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
xbmcvfs,
)
from ...kodion.constants import (
TRANSLATION_LANGUAGES,
PLAY_PROMPT_SUBTITLES,
TEMP_PATH,
TRANSLATION_LANGUAGES,
)
from ...kodion.network import BaseRequestsClass
from ...kodion.utils import make_dirs
Expand Down Expand Up @@ -202,20 +202,17 @@ def get_lang_details(self):
}

def get_subtitles(self):
if self.prompt_override:
selection = SUBTITLE_SELECTIONS['prompt']
else:
selection = self.sub_selection
selection = self.sub_selection

if self.prompt_override or selection == SUBTITLE_SELECTIONS['prompt']:
return self._prompt()

if selection == SUBTITLE_SELECTIONS['none']:
return None

if selection == SUBTITLE_SELECTIONS['all']:
return self.get_all()

if selection == SUBTITLE_SELECTIONS['prompt']:
return self._prompt()

selected_options = SUBTITLE_SELECTIONS[selection]

allowed_langs = []
Expand Down Expand Up @@ -359,7 +356,7 @@ def _prompt(self):
else:
self._context.log_debug('Subtitles._prompt'
' - Subtitle selection cancelled')
return None
return False

lang, language = choice
self._context.log_debug('Subtitles._prompt - selected: |{lang}|'
Expand Down

0 comments on commit 9ac3514

Please sign in to comment.