Remove Connect

This commit is contained in:
Claus Vium 2019-02-02 14:51:59 +01:00
parent 59c1dd42e3
commit 481ee11301
17 changed files with 7 additions and 508 deletions

View file

@ -352,10 +352,6 @@ msgctxt "#30547"
msgid "Display message"
msgstr "Nachricht anzeigen"
msgctxt "#30600"
msgid "Sign in with Jellyfin Connect"
msgstr "Mit Jellyfin Connect anmelden"
msgctxt "#30602"
msgid "Password"
msgstr "Passwort"
@ -412,10 +408,6 @@ msgctxt "#30617"
msgid "Server or port cannot be empty"
msgstr "Server oder Port muss eingetragen werden"
msgctxt "#30618"
msgid "Change Jellyfin Connect user"
msgstr "Jellyfin Connect Benutzer wechseln"
msgctxt "#33000"
msgid "Welcome"
msgstr "Willkommen"

View file

@ -346,10 +346,6 @@ msgctxt "#30547"
msgid "Display message"
msgstr ""
msgctxt "#30600"
msgid "Sign in with Jellyfin Connect"
msgstr ""
msgctxt "#30602"
msgid "Password"
msgstr ""
@ -406,10 +402,6 @@ msgctxt "#30617"
msgid "Server or port cannot be empty"
msgstr ""
msgctxt "#30618"
msgid "Change Jellyfin Connect user"
msgstr ""
msgctxt "#33000"
msgid "Welcome"
msgstr ""

View file

@ -351,10 +351,6 @@ msgctxt "#30547"
msgid "Display message"
msgstr "Afficher le message"
msgctxt "#30600"
msgid "Sign in with Jellyfin Connect"
msgstr "S'identifier avec Jellyfin Connect"
msgctxt "#30602"
msgid "Password"
msgstr "Mot de passe"
@ -411,10 +407,6 @@ msgctxt "#30617"
msgid "Server or port cannot be empty"
msgstr "Le serveur ou le port ne peuvent pas être vides"
msgctxt "#30618"
msgid "Change Jellyfin Connect user"
msgstr "Changer d'utilisateur Jellyfin Connect"
msgctxt "#33000"
msgid "Welcome"
msgstr "Bienvenue"

View file

@ -350,10 +350,6 @@ msgctxt "#30547"
msgid "Display message"
msgstr "Mostra messggio"
msgctxt "#30600"
msgid "Sign in with Jellyfin Connect"
msgstr "Accedi con Jellyfin Connect"
msgctxt "#30602"
msgid "Password"
msgstr "Password"
@ -410,10 +406,6 @@ msgctxt "#30617"
msgid "Server or port cannot be empty"
msgstr "Server o porta non possono essere vuoti"
msgctxt "#30618"
msgid "Change Jellyfin Connect user"
msgstr "Cambia utente Jellyfin Connect"
msgctxt "#33000"
msgid "Welcome"
msgstr "Benvenuto"

View file

@ -350,10 +350,6 @@ msgctxt "#30547"
msgid "Display message"
msgstr "Melding tonen"
msgctxt "#30600"
msgid "Sign in with Jellyfin Connect"
msgstr "Aanmelden met Jellyfin Connect"
msgctxt "#30602"
msgid "Password"
msgstr "Wachtwoord"
@ -410,10 +406,6 @@ msgctxt "#30617"
msgid "Server or port cannot be empty"
msgstr "Server of poort kan niet leeg zijn"
msgctxt "#30618"
msgid "Change Jellyfin Connect user"
msgstr "Jellyfin Connect gebruiker wijzigen"
msgctxt "#33000"
msgid "Welcome"
msgstr "Welkom"

View file

@ -350,10 +350,6 @@ msgctxt "#30547"
msgid "Display message"
msgstr "Wyświetl wiadomość"
msgctxt "#30600"
msgid "Sign in with Jellyfin Connect"
msgstr "Zaloguj z Jellyfin Connect"
msgctxt "#30602"
msgid "Password"
msgstr "Hasło"
@ -410,10 +406,6 @@ msgctxt "#30617"
msgid "Server or port cannot be empty"
msgstr "Nazwa hosta i port nie mogą być puste"
msgctxt "#30618"
msgid "Change Jellyfin Connect user"
msgstr "Zmień użytkownika Jellyfin Connect"
msgctxt "#33000"
msgid "Welcome"
msgstr "Witaj"

View file

@ -12,7 +12,7 @@ import xbmcvfs
import client
from database import get_credentials, save_credentials
from dialogs import ServerConnect, UsersConnect, LoginConnect, LoginManual, ServerManual
from dialogs import ServerConnect, UsersConnect, LoginManual, ServerManual
from helper import _, settings, addon_id, event, api, dialog, window
from emby import Emby
from emby.core.connection_manager import get_server_address, CONNECTION_STATE
@ -164,8 +164,7 @@ class Connect(object):
'connect_manager': self.connect_manager,
'username': user.get('DisplayName', ""),
'user_image': user.get('ImageUrl'),
'servers': state.get('Servers', []),
'jellyfin_connect': False if user else True
'servers': state.get('Servers', [])
})
dialog.doModal()
@ -173,12 +172,6 @@ class Connect(object):
LOG.debug("Server selected: %s", dialog.get_server())
return
elif dialog.is_connect_login():
LOG.debug("Login with jellyfin connect")
try:
self.login_connect()
except RuntimeError: pass
elif dialog.is_manual_server():
LOG.debug("Adding manual server")
try:
@ -218,35 +211,6 @@ class Connect(object):
else:
raise RuntimeError("Server is not connected")
def setup_login_connect(self):
''' Setup jellyfin connect by itself.
'''
client = self.get_client()
client.set_credentials(get_credentials())
manager = client.auth
try:
self.login_connect(manager)
except RuntimeError:
return
credentials = client.get_credentials()
save_credentials(credentials)
def login_connect(self, manager=None):
''' Return connect user or raise error.
'''
dialog = LoginConnect("script-jellyfin-connect-login.xml", *XML_PATH)
dialog.set_args(**{'connect_manager': manager or self.connect_manager})
dialog.doModal()
if dialog.is_logged_in():
return dialog.get_user()
else:
raise RuntimeError("Connect user is not logged in")
def login(self):
users = self.connect_manager['public-users']

View file

@ -1,5 +1,4 @@
from serverconnect import ServerConnect
from usersconnect import UsersConnect
from loginconnect import LoginConnect
from loginmanual import LoginManual
from servermanual import ServerManual

View file

@ -1,147 +0,0 @@
# -*- coding: utf-8 -*-
##################################################################################################
import logging
import os
import xbmcgui
import xbmcaddon
from helper import _, addon_id, settings, dialog
##################################################################################################
LOG = logging.getLogger("JELLYFIN."+__name__)
ACTION_PARENT_DIR = 9
ACTION_PREVIOUS_MENU = 10
ACTION_BACK = 92
SIGN_IN = 200
CANCEL = 201
ERROR_TOGGLE = 202
ERROR_MSG = 203
ERROR = {
'Invalid': 1,
'Empty': 2
}
##################################################################################################
class LoginConnect(xbmcgui.WindowXMLDialog):
_user = None
error = None
def __init__(self, *args, **kwargs):
xbmcgui.WindowXMLDialog.__init__(self, *args, **kwargs)
def set_args(self, **kwargs):
# connect_manager, user_image, servers, jellyfin_connect
for key, value in kwargs.iteritems():
setattr(self, key, value)
def is_logged_in(self):
return True if self._user else False
def get_user(self):
return self._user
def onInit(self):
self.user_field = self._add_editcontrol(755, 338, 40, 415)
self.setFocus(self.user_field)
self.password_field = self._add_editcontrol(755, 448, 40, 415, password=1)
self.signin_button = self.getControl(SIGN_IN)
self.remind_button = self.getControl(CANCEL)
self.error_toggle = self.getControl(ERROR_TOGGLE)
self.error_msg = self.getControl(ERROR_MSG)
self.user_field.controlUp(self.remind_button)
self.user_field.controlDown(self.password_field)
self.password_field.controlUp(self.user_field)
self.password_field.controlDown(self.signin_button)
self.signin_button.controlUp(self.password_field)
self.remind_button.controlDown(self.user_field)
def onClick(self, control):
if control == SIGN_IN:
# Sign in to jellyfin connect
self._disable_error()
user = self.user_field.getText()
password = self.password_field.getText()
if not user or not password:
# Display error
self._error(ERROR['Empty'], _('empty_user_pass'))
LOG.error("Username or password cannot be null")
elif self._login(user, password):
self.close()
elif control == CANCEL:
# Remind me later
self.close()
def onAction(self, action):
if (self.error == ERROR['Empty']
and self.user_field.getText() and self.password_field.getText()):
self._disable_error()
if action in (ACTION_BACK, ACTION_PARENT_DIR, ACTION_PREVIOUS_MENU):
self.close()
def _add_editcontrol(self, x, y, height, width, password=0):
media = os.path.join(xbmcaddon.Addon(addon_id()).getAddonInfo('path'), 'resources', 'skins', 'default', 'media')
control = xbmcgui.ControlEdit(0, 0, 0, 0,
label="User",
font="font13",
textColor="FF52b54b",
disabledColor="FF888888",
focusTexture="-",
noFocusTexture="-",
isPassword=password)
control.setPosition(x, y)
control.setHeight(height)
control.setWidth(width)
self.addControl(control)
return control
def _login(self, username, password):
result = self.connect_manager['login-connect'](username, password)
if result is False:
self._error(ERROR['Invalid'], _('invalid_auth'))
return False
self._user = result
username = result['User']['Name']
settings('connectUsername', value=username)
settings('idMethod', value="1")
dialog("notification", heading="{jellyfin}", message="%s %s" % (_(33000), username.decode('utf-8')),
icon=result['User'].get('ImageUrl') or "{jellyfin}",
time=2000,
sound=False)
return True
def _error(self, state, message):
self.error = state
self.error_msg.setLabel(message)
self.error_toggle.setVisibleCondition('true')
def _disable_error(self):
self.error = None
self.error_toggle.setVisibleCondition('false')

View file

@ -36,7 +36,7 @@ class LoginManual(xbmcgui.WindowXMLDialog):
xbmcgui.WindowXMLDialog.__init__(self, *args, **kwargs)
def set_args(self, **kwargs):
# connect_manager, user_image, servers, emby_connect
# connect_manager, user_image, servers
for key, value in kwargs.iteritems():
setattr(self, key, value)

View file

@ -24,7 +24,6 @@ CANCEL = 201
MESSAGE_BOX = 202
MESSAGE = 203
BUSY = 204
EMBY_CONNECT = 205
MANUAL_SERVER = 206
##################################################################################################
@ -45,7 +44,7 @@ class ServerConnect(xbmcgui.WindowXMLDialog):
xbmcgui.WindowXMLDialog.__init__(self, *args, **kwargs)
def set_args(self, **kwargs):
# connect_manager, user_image, servers, jellyfin_connect
# connect_manager, user_image, servers
for key, value in kwargs.iteritems():
setattr(self, key, value)
@ -76,9 +75,6 @@ class ServerConnect(xbmcgui.WindowXMLDialog):
if self.user_image is not None:
self.getControl(USER_IMAGE).setImage(self.user_image)
if not self.jellyfin_connect: # Change connect user
self.getControl(EMBY_CONNECT).setLabel("[B]%s[/B]" % _(30618))
if self.servers:
self.setFocus(self.list_)
@ -109,12 +105,7 @@ class ServerConnect(xbmcgui.WindowXMLDialog):
def onClick(self, control):
if control == EMBY_CONNECT:
self.connect_manager.clear_data()
self._connect_login = True
self.close()
elif control == MANUAL_SERVER:
if control == MANUAL_SERVER:
self._manual_server = True
self.close()

View file

@ -69,8 +69,6 @@ class ConnectionManager(object):
return self.connect
elif key == "login":
return self.login
elif key == "login-connect":
return self.login_to_connect
elif key == "connect-user":
return self.connect_user()
elif key == "connect-token":
@ -159,38 +157,6 @@ class ConnectionManager(object):
return servers
def login_to_connect(self, username, password):
if not username:
raise AttributeError("username cannot be empty")
if not password:
raise AttributeError("password cannot be empty")
try:
result = self._request_url({
'type': "POST",
'url': self.get_connect_url("user/authenticate"),
'data': {
'nameOrEmail': username,
'password': self._get_connect_password_hash(password)
},
'dataType': "json"
})
except Exception as error: # Failed to login
LOG.error(error)
return False
else:
credentials = self.credentials.get_credentials()
credentials['ConnectAccessToken'] = result['AccessToken']
credentials['ConnectUserId'] = result['User']['Id']
credentials['ConnectUser'] = result['User']['DisplayName']
self.credentials.get_credentials(credentials)
# Signed in
self._on_connect_user_signin(result['User'])
return result
def login(self, server, username, password=None, clear=True, options={}):
if not username:

View file

@ -82,7 +82,7 @@ class WSClient(threading.Thread):
message = json.loads(message)
data = message.get('Data', {})
if message['MessageType'] in ('RefreshProgress'):
if message['MessageType'] in ('RefreshProgress',):
LOG.debug("Ignoring %s", message)
return

View file

@ -308,9 +308,6 @@ class Service(xbmc.Monitor):
self.connect.register(data['Id'])
xbmc.executebuiltin("Container.Refresh")
elif method == 'JellyfinConnect':
self.connect.setup_login_connect()
elif method == 'AddServer':
self.connect.setup_manual_server()

View file

@ -5,8 +5,6 @@
<setting label="30003" id="idMethod" type="enum" values="Manual|Jellyfin Connect" default="0" />
<setting label="30024" id="username" type="text" default="" visible="eq(-1,0)" />
<setting label="30543" id="connectUsername" type="text" default="" visible="!eq(0,) + eq(-2,1)" />
<setting label="30600" type="action" action="RunPlugin(plugin://plugin.video.jellyfin?mode=connect)" visible="eq(-3,1) + eq(-1,)" option="close" />
<setting label="30618" type="action" action="RunPlugin(plugin://plugin.video.jellyfin?mode=connect)" visible="eq(-4,1) + !eq(-2,)" option="close" />
<setting label="30001" id="serverName" type="text" default="" />
<setting label="30000" id="server" type="text" default="" visible="true" />
<setting label="33150" type="action" action="RunPlugin(plugin://plugin.video.jellyfin?mode=updateserver)" visible="!eq(-1,)" option="close" />

View file

@ -1,203 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<window>
<animation type="WindowOpen" reversible="false">
<effect type="zoom" start="80" end="100" center="960,540" delay="160" tween="circle" easin="out" time="240" />
<effect type="fade" delay="160" end="100" time="240" />
</animation>
<animation type="WindowClose" reversible="false">
<effect type="zoom" start="100" end="80" center="960,540" easing="in" tween="circle" easin="out" time="240" />
<effect type="fade" start="100" end="0" time="240" />
</animation>
<controls>
<control type="group">
<control type="image">
<top>-200</top>
<bottom>-200</bottom>
<left>-200</left>
<right>-200</right>
<texture colordiffuse="CC000000">white.png</texture>
<aspectratio>stretch</aspectratio>
<animation effect="fade" end="100" time="200">WindowOpen</animation>
<animation effect="fade" start="100" end="0" time="200">WindowClose</animation>
</control>
<control type="group">
<centerleft>50%</centerleft>
<centertop>50%</centertop>
<width>470</width>
<height>660</height>
<control type="group">
<top>-30</top>
<control type="image">
<left>20</left>
<width>100%</width>
<height>25</height>
<texture>logo-white.png</texture>
<aspectratio align="left">keep</aspectratio>
</control>
</control>
<control type="image">
<width>100%</width>
<height>660</height>
<texture colordiffuse="ff222326" border="10">dialogs/dialog_back.png</texture>
</control>
<control type="group">
<centerleft>50%</centerleft>
<top>10</top>
<width>460</width>
<height>660</height>
<control type="grouplist" id="100">
<orientation>vertical</orientation>
<itemgap>0</itemgap>
<control type="label">
<width>100%</width>
<height>75</height>
<aligny>center</aligny>
<textoffsetx>20</textoffsetx>
<font>font13</font>
<textcolor>white</textcolor>
<textshadow>66000000</textshadow>
<label>[B]$ADDON[plugin.video.jellyfin 30612][/B]</label>
</control>
<control type="group" id="101">
<height>110</height>
<control type="label">
<label>$ADDON[plugin.video.jellyfin 30024]</label>
<textcolor>ffe1e1e1</textcolor>
<shadowcolor>66000000</shadowcolor>
<font>font12</font>
<aligny>top</aligny>
<textoffsetx>20</textoffsetx>
</control>
<control type="label">
<height>50</height>
</control>
<control type="image">
<left>20</left>
<right>20</right>
<height>1</height>
<top>90</top>
<texture colordiffuse="ff525252">white.png</texture>
</control>
</control>
<control type="group" id="102">
<height>110</height>
<control type="label">
<label>$ADDON[plugin.video.jellyfin 30602]</label>
<textcolor>ffe1e1e1</textcolor>
<textshadow>66000000</textshadow>
<font>font12</font>
<aligny>top</aligny>
<textoffsetx>20</textoffsetx>
</control>
<control type="label">
<height>50</height>
</control>
<control type="image">
<description>separator</description>
<left>20</left>
<right>20</right>
<height>1</height>
<top>90</top>
<texture colordiffuse="ff525252">white.png</texture>
</control>
</control>
<control type="button" id="200">
<label>[B]$ADDON[plugin.video.jellyfin 30605][/B]</label>
<width>426</width>
<height>65</height>
<font>font13</font>
<textcolor>ffe1e1e1</textcolor>
<focusedcolor>white</focusedcolor>
<selectedcolor>ffe1e1e1</selectedcolor>
<shadowcolor>66000000</shadowcolor>
<textoffsetx>20</textoffsetx>
<aligny>center</aligny>
<align>center</align>
<texturefocus border="10" colordiffuse="ff52b54b">buttons/shadow_smallbutton.png</texturefocus>
<texturenofocus border="10" colordiffuse="ff464646">buttons/shadow_smallbutton.png</texturenofocus>
<pulseonselect>no</pulseonselect>
<animation effect="slide" time="0" end="17,0" condition="true">Conditional</animation>
</control>
<control type="button" id="201">
<label>[B]$ADDON[plugin.video.jellyfin 30606][/B]</label>
<width>426</width>
<height>65</height>
<font>font13</font>
<textcolor>ffe1e1e1</textcolor>
<focusedcolor>white</focusedcolor>
<selectedcolor>ffe1e1e1</selectedcolor>
<shadowcolor>66000000</shadowcolor>
<textoffsetx>20</textoffsetx>
<aligny>center</aligny>
<align>center</align>
<texturefocus border="10" colordiffuse="ff52b54b">buttons/shadow_smallbutton.png</texturefocus>
<texturenofocus border="10" colordiffuse="ff464646">buttons/shadow_smallbutton.png</texturenofocus>
<pulseonselect>no</pulseonselect>
<animation effect="slide" time="0" end="17,0" condition="true">Conditional</animation>
</control>
<control type="label">
<description>spacer</description>
<height>20</height>
</control>
<control type="group">
<control type="label">
<label>$ADDON[plugin.video.jellyfin 30603]</label>
<font>font_flag</font>
<textcolor>ff464646</textcolor>
<shadowcolor>66000000</shadowcolor>
<wrapmultiline>true</wrapmultiline>
<scroll>true</scroll>
<aligny>top</aligny>
<height>160</height>
<left>20</left>
<right>160</right>
</control>
<control type="group">
<top>10</top>
<right>20</right>
<width>130</width>
<control type="image">
<width>130</width>
<height>130</height>
<description>qrcode</description>
<texture>qrcode_disclaimer.png</texture>
</control>
<control type="label">
<top>135</top>
<align>center</align>
<label>[UPPERCASE]$ADDON[plugin.video.jellyfin 30604][/UPPERCASE]</label>
<font>font_flag</font>
<scroll>true</scroll>
<textcolor>FF52b54b</textcolor>
<shadowcolor>66000000</shadowcolor>
<aligny>top</aligny>
</control>
</control>
</control>
</control>
</control>
<control type="group" id="202">
<top>660</top>
<visible>false</visible>
<control type="image">
<description>Error box</description>
<width>100%</width>
<height>70</height>
<texture colordiffuse="ff222326" border="10">dialogs/dialog_back.png</texture>
</control>
<control type="label" id="203">
<top>10</top>
<height>50</height>
<textcolor>ffe1e1e1</textcolor>
<scroll>true</scroll>
<shadowcolor>66000000</shadowcolor>
<font>font12</font>
<textoffsetx>20</textoffsetx>
<aligny>center</aligny>
<align>center</align>
</control>
</control>
</control>
</control>
</controls>
</window>

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<window>
<defaultcontrol always="true">205</defaultcontrol>
<defaultcontrol always="true">206</defaultcontrol>
<animation type="WindowOpen" reversible="false">
<effect type="zoom" start="80" end="100" center="960,540" delay="160" tween="circle" easin="out" time="240" />
<effect type="fade" delay="160" end="100" time="240" />
@ -160,24 +160,6 @@
<description>spacer</description>
<height>20</height>
</control>
<control type="button" id="205">
<label>[B]$ADDON[plugin.video.jellyfin 30600][/B]</label>
<width>476</width>
<height>65</height>
<font>font13</font>
<textcolor>ffe1e1e1</textcolor>
<focusedcolor>white</focusedcolor>
<selectedcolor>ffe1e1e1</selectedcolor>
<shadowcolor>66000000</shadowcolor>
<textoffsetx>20</textoffsetx>
<aligny>center</aligny>
<align>center</align>
<texturefocus border="10" colordiffuse="ff52b54b">buttons/shadow_smallbutton.png</texturefocus>
<texturenofocus border="10" colordiffuse="ff464646">buttons/shadow_smallbutton.png</texturenofocus>
<pulseonselect>no</pulseonselect>
<onup>155</onup>
<animation effect="slide" time="0" end="17,0" condition="true">Conditional</animation>
</control>
<control type="button" id="206">
<label>[B]$ADDON[plugin.video.jellyfin 30611][/B]</label>
<width>476</width>