Skip to content

Commit

Permalink
Merge pull request #596 from MoojMidge/master
Browse files Browse the repository at this point in the history
v7.0.3
  • Loading branch information
MoojMidge authored Feb 25, 2024
2 parents 59bf158 + 11a82d0 commit f8e8485
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 13 deletions.
2 changes: 1 addition & 1 deletion addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.youtube" name="YouTube" version="7.0.3+beta.5" provider-name="anxdpanic, bromix">
<addon id="plugin.video.youtube" name="YouTube" version="7.0.3" provider-name="anxdpanic, bromix">
<requires>
<import addon="xbmc.python" version="3.0.1"/>
<import addon="script.module.requests" version="2.12.4"/>
Expand Down
6 changes: 6 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v7.0.3
### Fixed
- Fix incorrect labelling of subtitle language in Kodi subtitle selection dialog #595
- Fix failure to play videos when MPEG-DASH and subtitles were enabled in Kodi 20 and lower #595
- Fix Python 2 compatibility

## v7.0.3+beta.5
### Fixed
- Properly fix infotagger error with Kodi v19
Expand Down
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 @@ -1400,3 +1400,7 @@ msgstr ""
msgctxt "#30774"
msgid "All available"
msgstr ""

msgctxt "#30775"
msgid "%s (translation)"
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 @@ -1400,3 +1400,7 @@ msgstr ""
msgctxt "#30774"
msgid "All available"
msgstr ""

msgctxt "#30775"
msgid "%s (translation)"
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 @@ -1396,3 +1396,7 @@ msgstr ""
msgctxt "#30774"
msgid "All available"
msgstr ""

msgctxt "#30775"
msgid "%s (translation)"
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 @@ -1401,3 +1401,7 @@ msgstr ""
msgctxt "#30774"
msgid "All available"
msgstr ""

msgctxt "#30775"
msgid "%s (translation)"
msgstr ""
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ class XbmcContext(AbstractContext):
'subtitles.all': 30774,
'subtitles.language': 30560,
'subtitles.no_auto_generated': 30602,
'subtitles.translation': 30775,
'subtitles.with_fallback': 30601,
'succeeded': 30575,
'trending': 30513,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,23 @@ def get_result(self, func, *args, **kwargs):
cache_id = self._create_id_from_func(partial_func)
return self._get(cache_id)

def run(self, func, seconds, *args, _refresh=False, **kwargs):
def run(self, func, seconds, *args, **kwargs):
"""
Returns the cached data of the given function.
:param func, function to cache
:param seconds: time to live in
:param _refresh: bool, updates cache with new func result
:return:
"""
refresh = kwargs.pop('_refresh', False)
partial_func = partial(func, *args, **kwargs)

# if caching is disabled call the function
if not self._enabled:
return partial_func()

cache_id = self._create_id_from_func(partial_func)
data = None if _refresh else self._get(cache_id, seconds=seconds)
data = None if refresh else self._get(cache_id, seconds=seconds)
if data is None:
data = partial_func()
self._set(cache_id, data)
Expand Down
4 changes: 2 additions & 2 deletions resources/lib/youtube_plugin/kodion/utils/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def _find_best_fit_video(_stream_data):
return selected_stream_data


def create_path(*args, is_uri=False):
def create_path(*args, **kwargs):
path = '/'.join([
part
for part in [
Expand All @@ -178,7 +178,7 @@ def create_path(*args, is_uri=False):
else:
return '/'

if is_uri:
if kwargs.get('is_uri', False):
return quote(path)
return path

Expand Down
12 changes: 6 additions & 6 deletions resources/lib/youtube_plugin/youtube/helper/subtitles.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,26 +231,26 @@ def _prompt(self):
if not num_total:
self._context.log_debug('No subtitles found for prompt')
else:
translation_lang = self._context.localize('subtitles.translation')
choice = self._context.get_ui().on_select(
self._context.localize('subtitles.language'),
[name for _, name in captions] +
[name + ' *' for _, name in translations]
[translation_lang % name for _, name in translations]
)
if choice == -1:
self._context.log_debug('Subtitle selection cancelled')
return None

track = None
if 0 <= choice < num_captions:
track = self.caption_tracks[choice]
kind = track.get('kind')
choice = translations[choice - num_captions]
choice = captions[choice - num_captions]
is_translation = False
elif num_captions <= choice < num_total:
track = self.defaults['translation_base']
kind = 'translation'
choice = translations[choice - num_captions]
is_translation = True
else:
self._context.log_debug('Subtitle selection cancelled')
return None

url = self._get_url(
caption_track=track,
Expand Down
11 changes: 9 additions & 2 deletions resources/lib/youtube_plugin/youtube/helper/video_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -1858,16 +1858,23 @@ def _filter_group(previous_group, previous_stream, item):
set_id += 1

if subs_data:
translation_lang = self._context.localize('subtitles.translation')
for lang_code, subtitle in subs_data.items():
label = language = subtitle['language']
kind = subtitle['kind']
if kind:
if kind == 'translation':
label = '{0} ({1})'.format(language, kind)
label = translation_lang % language
kind = '_'.join((lang_code, kind))
else:
kind = lang_code

url = (unquote(subtitle['url'])
.replace("&", "&amp;")
.replace('"', "&quot;")
.replace("<", "&lt;")
.replace(">", "&gt;"))

output.extend((
'\t\t<AdaptationSet'
' id="', str(set_id), '"'
Expand All @@ -1890,7 +1897,7 @@ def _filter_group(previous_group, previous_stream, item):
# unsure about what value to use for bandwidth
' bandwidth="268"'
'>\n'
'\t\t\t\t<BaseURL>', subtitle['url'], '</BaseURL>\n'
'\t\t\t\t<BaseURL>', url, '</BaseURL>\n'
'\t\t\t</Representation>\n'
'\t\t</AdaptationSet>\n'
))
Expand Down

0 comments on commit f8e8485

Please sign in to comment.