Skip to content

Commit

Permalink
Update subtitle handling
Browse files Browse the repository at this point in the history
- Enable use of translated subtitles for all android clients
- Use ISA to provide better subtitle details to Kodi, if ISA and MPEG-DASH are enabled
  - New option to display all subtitles, including auto-generated and auto-translated subs
- Closes #121, #201, #247, #305, #489
  • Loading branch information
MoojMidge committed Feb 23, 2024
1 parent fd995b2 commit 546c98e
Show file tree
Hide file tree
Showing 10 changed files with 332 additions and 148 deletions.
4 changes: 4 additions & 0 deletions resources/language/resource.language.en_au/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -1396,3 +1396,7 @@ msgstr ""
msgctxt "#30773"
msgid "Show video details in video lists"
msgstr ""

msgctxt "#30774"
msgid "All available"
msgstr ""
4 changes: 4 additions & 0 deletions resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -1396,3 +1396,7 @@ msgstr ""
msgctxt "#30773"
msgid "Show video details in video lists"
msgstr ""

msgctxt "#30774"
msgid "All available"
msgstr ""
4 changes: 4 additions & 0 deletions resources/language/resource.language.en_nz/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -1392,3 +1392,7 @@ msgstr ""
msgctxt "#30773"
msgid "Show video details in video lists"
msgstr ""

msgctxt "#30774"
msgid "All available"
msgstr ""
4 changes: 4 additions & 0 deletions resources/language/resource.language.en_us/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -1397,3 +1397,7 @@ msgstr ""
msgctxt "#30773"
msgid "Show video details in video lists"
msgstr ""

msgctxt "#30774"
msgid "All available"
msgstr ""
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ class XbmcContext(AbstractContext):
'subscriptions': 30504,
'subtitles.download': 30705,
'subtitles.download.pre': 30706,
'subtitles.all': 30774,
'subtitles.language': 30560,
'subtitles.no_auto_generated': 30602,
'subtitles.with_fallback': 30601,
Expand Down
3 changes: 2 additions & 1 deletion resources/lib/youtube_plugin/kodion/items/xbmc/xbmc_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ def video_playback_item(context, video_item, show_fanart=None):
'isPlayable': str(video_item.playable).lower(),
}

manifest_type = None
if (alternative_player
and settings.alternative_player_web_urls()
and not license_key):
Expand Down Expand Up @@ -291,7 +292,7 @@ def video_playback_item(context, video_item, show_fanart=None):
'thumb': image,
})

if video_item.subtitles:
if video_item.subtitles and manifest_type != 'mpd':
list_item.setSubtitles(video_item.subtitles)

item_info = create_info_labels(video_item)
Expand Down
27 changes: 19 additions & 8 deletions resources/lib/youtube_plugin/kodion/script_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,33 @@ def _config_actions(action, *_args):
(language, 'en')
)),
language,
'%s (%s)' % (language, localize('subtitles.no_auto_generated'))
'%s (%s)' % (language, localize('subtitles.no_auto_generated')),
]

if settings.use_mpd_videos():
sub_opts.append(localize('subtitles.all'))
elif sub_setting == 5:
sub_setting = 0
settings.set_subtitle_languages(sub_setting)

sub_opts[sub_setting] = ui.bold(sub_opts[sub_setting])

result = ui.on_select(localize('subtitles.language'),
sub_opts,
preselect=sub_setting)
if result > -1:
settings.set_subtitle_languages(result)
sub_setting = result
settings.set_subtitle_languages(sub_setting)

result = ui.on_yes_no_input(
localize('subtitles.download'),
localize('subtitles.download.pre')
)
if result > -1:
settings.set_subtitle_download(result == 1)
if not sub_setting or sub_setting == 5:
settings.set_subtitle_download(False)
else:
result = ui.on_yes_no_input(
localize('subtitles.download'),
localize('subtitles.download.pre')
)
if result > -1:
settings.set_subtitle_download(result == 1)

elif action == 'listen_ip':
local_ranges = ('10.', '172.16.', '192.168.')
Expand Down
2 changes: 2 additions & 0 deletions resources/lib/youtube_plugin/youtube/client/request_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class YouTubeRequestClient(BaseRequestsClass):
},
'android': {
'_id': 3,
'_query_subtitles': True,
'json': {
'params': '2AMBCgIQBg',
'context': {
Expand Down Expand Up @@ -79,6 +80,7 @@ class YouTubeRequestClient(BaseRequestsClass):
# Limited to 720p on some videos
'android_embedded': {
'_id': 55,
'_query_subtitles': True,
'json': {
'params': '2AMBCgIQBg',
'context': {
Expand Down
Loading

0 comments on commit 546c98e

Please sign in to comment.