(2020-10-13, 20:51)matthuisman Wrote: No common settings should need to be touched.
What have you changed there?
Nah, just my own settings for the modifyed proxy.py (
heavily based on code from @
gus92): audio description tracks, forced subtitles tracks, language filter..
For some reasons I can't find "script.module.slyguy" in the list of installed addons, so I cannot edit the settings in kodi. And my "language_filter" setting is always blank, no matter what I do (I surely do something wrong somewhere). I consider moving these settings to "slyguy.disney.plus", and then pass them in headers as you do with "_proxy_default_language". But since all my modifications are overwritten at every update, I just keep my changes in one module (so there is just one module to merge/sync code after every update).
@
DiogoSilva48 This is how my
_default_audio_fix method looks like in proxy.py:
python:
def _default_audio_fix(self, m3u8):
if '#EXT-X-MEDIA' not in m3u8:
return m3u8
def _process_media(line):
attribs = {}
for key, value in re.findall('([\w-]+)="?([^",]*)[",$]?', line):
attribs[key.upper()] = value.strip()
return attribs
# Settings #
load_audio_description_tracks = settings.getBool('audio_description_tracks')
load_forced_subtitles = settings.getBool('forced_subtitles')
audio_codec = settings.get("audio_codec")
if audio_codec == "All": audio_codec = ""
lang_list = []
#for lang in settings.get('language_filter').split(" "): lang_list.append(lang.lower()) # Does not work for some reason?
lang_list.append("en") # English
lang_list.append("no") # Norwegian
# /Settings #
default_groups = []
groups = defaultdict(list)
default_language = self.headers.get('_proxy_default_language')
for line in m3u8.splitlines():
if line.startswith('#EXT-X-MEDIA'):
attribs = _process_media(line)
if not attribs:
continue
# FIX es-ES fr-FR languages #
language = attribs.get('LANGUAGE')
if language:
split = language.split('-')
if len(split) > 1 and split[1].lower() == split[0].lower():
attribs['LANGUAGE'] = split[0]
#############################
if attribs.get('GROUP-ID'):
groups[attribs['GROUP-ID']].append([attribs, line])
if attribs.get('DEFAULT') == 'YES' and attribs['GROUP-ID'] not in default_groups:
default_groups.append(attribs['GROUP-ID'])
# Filter subtitles and audio #
if len(lang_list) > 0:
language = attribs.get('LANGUAGE')
if language and not (language.lower().startswith(tuple(lang_list))) and language != default_language:
m3u8 = m3u8.replace(line, "#DELETED")
if not load_forced_subtitles:
if attribs.get('TYPE') == 'SUBTITLES' and attribs.get('FORCED') == 'YES':
m3u8 = m3u8.replace(line, "#DELETED")
# /Filter subtitles and audio #
# Filter audio #
if attribs.get('TYPE') == 'AUDIO':
if not load_audio_description_tracks:
if attribs.get('CHARACTERISTICS') == 'public.accessibility.describes-video':
m3u8 = m3u8.replace(line, "#DELETED")
if audio_codec != "":
if attribs.get('GROUP-ID') != audio_codec:
m3u8 = m3u8.replace(line, "#DELETED")
# /Filter audio #
if default_language:
for group_id in groups:
if group_id in default_groups:
continue
languages = []
for group in groups[group_id]:
attribs, line = group
attribs['AUTOSELECT'] = 'NO'
attribs['DEFAULT'] = 'NO'
if attribs['LANGUAGE'] not in languages or attribs.get('TYPE') == 'SUBTITLES':
attribs['AUTOSELECT'] = 'YES'
if attribs['LANGUAGE'] == default_language:
attribs['DEFAULT'] = 'YES'
languages.append(attribs['LANGUAGE'])
for group_id in groups:
for group in groups[group_id]:
attribs, line = group
new_line = '#EXT-X-MEDIA:' if attribs else ''
for key in attribs:
new_line += u'{}="{}",'.format(key, attribs[key])
m3u8 = m3u8.replace(line, new_line.rstrip(','))
return m3u8
In setting.xml for "script.module.slyguy" I have added these lines:
xml:
<setting label="Load audio description tracks" id="audio_description_tracks" type="bool" default="false"/>
<setting label="Audio codec" id="audio_codec" type="labelenum" values="All|eac-3|aac-128k|aac-64k" default="All"/>
<setting label="Load forced subtitles" id="forced_subtitles" type="bool" default="false"/>
<setting label="Preferred subtitle languages (codes separated by spaces)" id="language_filter" type="text" default="" />