diff --git a/addon.xml b/addon.xml index 525f4cb..8f836c4 100644 --- a/addon.xml +++ b/addon.xml @@ -1,7 +1,7 @@ diff --git a/lib/invidious/instance.py b/lib/invidious/instance.py index ec36e68..da31176 100644 --- a/lib/invidious/instance.py +++ b/lib/invidious/instance.py @@ -7,9 +7,12 @@ from requests import HTTPError +from xbmcgui import ALPHANUM_HIDE_INPUT + from iapc import public from nuttig import ( - buildUrl, getSetting, maybeLocalize, selectDialog, setSetting + buildUrl, getSetting, maybeLocalize, setSetting, + inputDialog, okDialog, selectDialog ) from invidious.extract import ( @@ -60,12 +63,16 @@ def __setup__(self): if (uri := getSetting("instance.uri", str)): self.__scheme__, self.__netloc__, *unused = urlsplit(uri) self.__url__ = buildUrl(uri, getSetting("instance.path", str)) + self.__uri__ = urlunsplit( + (self.__scheme__, self.__netloc__, "", "", "") + ) else: - self.__scheme__ = self.__netloc__ = self.__url__ = None + self.__scheme__ = self.__netloc__ = self.__url__ = self.__uri__ = None self.__proxy__ = getSetting("instance.proxy", bool) self.__locale__ = getSetting("regional.locale", str) self.__region__ = getSetting("regional.region", str) settings = ( + #("Uri", self.__uri__), ("Url", self.__url__), (41130, self.__proxy__), ( @@ -118,6 +125,8 @@ def selectInstance(self): if index > -1: setSetting("instance.uri", keys[index], str) return True + else: + okDialog(maybeLocalize(90101)) return False # region ------------------------------------------------------------------- @@ -149,6 +158,22 @@ def selectLocale(self): def selectRegion(self): self.__select__(regions, "regional.region", 41222) + # tokens ------------------------------------------------------------------- + + #@public + #def addApiToken(self): + # self.logger.info(f"addApiToken()") + # if ( + # (uri := inputDialog(heading=90007, defaultt=self.__uri__)) and + # (email := inputDialog(heading=90008)) and + # (password := inputDialog(heading=90009, option=ALPHANUM_HIDE_INPUT)) + # ): + # self.__tokens__.registerToken(uri, email, password) + + #@public + #def removeApiTokens(self): + # self.logger.info(f"removeApiTokens()") + # -------------------------------------------------------------------------- def __regional__(self, regional, kwargs): diff --git a/lib/scripts.py b/lib/scripts.py index 5bdd5d1..67bac4b 100644 --- a/lib/scripts.py +++ b/lib/scripts.py @@ -41,6 +41,15 @@ def selectRegion(): return Client().instance.selectRegion() +# tokens ----------------------------------------------------------------------- + +#def addApiToken(): +# return Client().instance.addApiToken() + +#def removeApiTokens(): +# return Client().instance.removeApiTokens() + + # feed ------------------------------------------------------------------------- def addChannelToFeed(channelId, channel): @@ -77,6 +86,8 @@ def clearHistory(): "selectInstance": selectInstance, "selectLocale": selectLocale, "selectRegion": selectRegion, + #"addApiToken": addApiToken, + #"removeApiTokens": removeApiTokens, "addChannelToFeed": addChannelToFeed, "removeChannelFromFeed": removeChannelFromFeed, "clearChannelsFromFeed": clearChannelsFromFeed, diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index 5643a3c..c2d5a3d 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -260,6 +260,22 @@ msgctxt "#49112" msgid "SponsorBlock service settings..." msgstr "" +msgctxt "#49200" +msgid "Tokens" +msgstr "" + +msgctxt "#49210" +msgid "Add api token" +msgstr "" + +msgctxt "#49211" +msgid "You will need to login to retrieve an api token" +msgstr "" + +msgctxt "#49220" +msgid "Remove api tokens" +msgstr "" + # Items infos @@ -350,3 +366,19 @@ msgstr "" msgctxt "#90006" msgid "==>" msgstr "" + +msgctxt "#90007" +msgid "Instance uri" +msgstr "" + +msgctxt "#90008" +msgid "Username" +msgstr "" + +msgctxt "#90009" +msgid "Password" +msgstr "" + +msgctxt "#90101" +msgid "No public instance available" +msgstr "" diff --git a/resources/settings.xml b/resources/settings.xml index de3c60e..6321375 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -261,6 +261,22 @@ + +