Skip to content

Commit

Permalink
fix instance chooser when no public instance is available
Browse files Browse the repository at this point in the history
  • Loading branch information
lekma committed Dec 27, 2024
1 parent 07d86ef commit ac882b1
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 3 deletions.
2 changes: 1 addition & 1 deletion addon.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.invidious"
name="Invidious"
version="3.2.6"
version="3.2.7"
provider-name="lekma">

<requires>
Expand Down
29 changes: 27 additions & 2 deletions lib/invidious/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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__),
(
Expand Down Expand Up @@ -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 -------------------------------------------------------------------
Expand Down Expand Up @@ -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):
Expand Down
11 changes: 11 additions & 0 deletions lib/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -77,6 +86,8 @@ def clearHistory():
"selectInstance": selectInstance,
"selectLocale": selectLocale,
"selectRegion": selectRegion,
#"addApiToken": addApiToken,
#"removeApiTokens": removeApiTokens,
"addChannelToFeed": addChannelToFeed,
"removeChannelFromFeed": removeChannelFromFeed,
"clearChannelsFromFeed": clearChannelsFromFeed,
Expand Down
32 changes: 32 additions & 0 deletions resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 ""
16 changes: 16 additions & 0 deletions resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,22 @@

</group>

<!--<group id="tokens" label="49200">
<setting id="addApiToken" type="action" label="49210" help="49211">
<level>0</level>
<data>RunScript($ID,addApiToken)</data>
<control type="button" format="action" />
</setting>
<setting id="removeApiTokens" type="action" label="49220">
<level>0</level>
<data>RunScript($ID,removeApiTokens)</data>
<control type="button" format="action" />
</setting>
</group>-->

</category>

</section>
Expand Down

0 comments on commit ac882b1

Please sign in to comment.