Add more setting options to change clients

This commit is contained in:
MoojMidge 2023-05-01 15:15:06 +10:00
parent 05d7f447a8
commit 3ed6aa8d52
8 changed files with 60 additions and 11 deletions

View file

@ -1238,3 +1238,11 @@ msgstr ""
msgctxt "#30737"
msgid "Use alternate client details"
msgstr ""
msgctxt "#30738"
msgid "Alternate #1"
msgstr ""
msgctxt "#30739"
msgid "Alternate #2"
msgstr ""

View file

@ -1246,3 +1246,11 @@ msgstr ""
msgctxt "#30737"
msgid "Use alternate client details"
msgstr ""
msgctxt "#30738"
msgid "Alternate #1"
msgstr ""
msgctxt "#30739"
msgid "Alternate #2"
msgstr ""

View file

@ -1238,3 +1238,11 @@ msgstr ""
msgctxt "#30737"
msgid "Use alternate client details"
msgstr ""
msgctxt "#30738"
msgid "Alternate #1"
msgstr ""
msgctxt "#30739"
msgid "Alternate #2"
msgstr ""

View file

@ -1239,3 +1239,11 @@ msgstr ""
msgctxt "#30737"
msgid "Use alternate client details"
msgstr ""
msgctxt "#30738"
msgid "Alternate #1"
msgstr ""
msgctxt "#30739"
msgid "Alternate #2"
msgstr ""

View file

@ -47,4 +47,4 @@ HTTPD_WHITELIST = 'kodion.http.ip.whitelist' # (string)
API_CONFIG_PAGE = 'youtube.api.config.page' # (bool)
ALTERNATIVE_CLIENT = 'youtube.client.alternative' # (bool)
CLIENT_SELECTION = 'youtube.client.selection' # (int)

View file

@ -250,5 +250,5 @@ class AbstractSettings(object):
def hide_short_videos(self):
return self.get_bool(constants.setting.HIDE_SHORT_VIDEOS, False)
def use_alternative_client(self):
return self.get_bool(constants.setting.ALTERNATIVE_CLIENT, False)
def client_selection(self):
return self.get_int(constants.setting.CLIENT_SELECTION, 0)

View file

@ -579,10 +579,12 @@ class VideoInfo(object):
PRIORITISED_CLIENTS = None
def __init__(self, context, access_token='', api_key='', language='en-US'):
settings = context.get_settings()
self.video_id = None
self._context = context
self._data_cache = self._context.get_data_cache()
self._verify = context.get_settings().verify_ssl()
self._verify = settings.verify_ssl()
self._language = language.replace('-', '_')
self._access_token = access_token
self._api_key = api_key
@ -590,17 +592,25 @@ class VideoInfo(object):
self._calculate_n = True
self._cipher = None
if self._context.get_settings().use_alternative_client():
self.PRIORITISED_CLIENTS = (self.CLIENTS['android_embedded'],
client_selection = settings.client_selection()
# Alternate #1
if client_selection == 1:
self.PRIORITISED_CLIENTS = (self.CLIENTS['android'],
self.CLIENTS['android_testsuite'],
self.CLIENTS['web'])
# Alternate #1
elif client_selection == 2:
self.PRIORITISED_CLIENTS = (self.CLIENTS['android_embedded'],
self.CLIENTS['tv'],
self.CLIENTS['web'])
# Default
else:
self.PRIORITISED_CLIENTS = (self.CLIENTS['android_testsuite'],
self.CLIENTS['android_embedded'],
self.CLIENTS['web'])
self.CLIENTS['_common']['hl'] = context.get_settings().get_string('youtube.language', 'en_US').replace('-', '_')
self.CLIENTS['_common']['gl'] = context.get_settings().get_string('youtube.region', 'US')
self.CLIENTS['_common']['hl'] = settings.get_string('youtube.language', 'en_US').replace('-', '_')
self.CLIENTS['_common']['gl'] = settings.get_string('youtube.region', 'US')
@staticmethod
def generate_cpn():

View file

@ -564,10 +564,17 @@
</category>
<category help="" id="advanced" label="30031">
<group id="1">
<setting help="" id="youtube.client.alternative" label="30737" type="boolean">
<setting help="" id="youtube.client.selection" label="30737" type="integer">
<level>0</level>
<default>false</default>
<control type="toggle"/>
<default>0</default>
<constraints>
<options>
<option label="30532">0</option>
<option label="30738">1</option>
<option label="30739">2</option>
</options>
</constraints>
<control format="string" type="spinner"/>
</setting>
<setting help="" id="simple.requests.ssl.verify" label="30578" type="boolean">
<level>0</level>