mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2025-01-24 17:06:11 +00:00
Pylint + Fix initial setup for fresh installs
This commit is contained in:
parent
d36bb3d232
commit
3d31568518
13 changed files with 37 additions and 45 deletions
|
@ -26,31 +26,31 @@ class ClientInfo(object):
|
||||||
|
|
||||||
self.addon = xbmcaddon.Addon()
|
self.addon = xbmcaddon.Addon()
|
||||||
|
|
||||||
def getAddonName(self):
|
def get_addon_name(self):
|
||||||
# Used for logging
|
# Used for logging
|
||||||
return self.addon.getAddonInfo('name').upper()
|
return self.addon.getAddonInfo('name').upper()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def getAddonId(cls):
|
def get_addon_id(cls):
|
||||||
return "plugin.video.emby"
|
return "plugin.video.emby"
|
||||||
|
|
||||||
def getVersion(self):
|
def get_version(self):
|
||||||
return self.addon.getAddonInfo('version')
|
return self.addon.getAddonInfo('version')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def getDeviceName(cls):
|
def get_device_name(cls):
|
||||||
|
|
||||||
if settings('deviceNameOpt') == "false":
|
if settings('deviceNameOpt') == "false":
|
||||||
# Use Kodi's deviceName
|
# Use Kodi's deviceName
|
||||||
deviceName = xbmc.getInfoLabel('System.FriendlyName').decode('utf-8')
|
device_name = xbmc.getInfoLabel('System.FriendlyName').decode('utf-8')
|
||||||
else:
|
else:
|
||||||
deviceName = settings('deviceName')
|
device_name = settings('deviceName')
|
||||||
deviceName = deviceName.replace("\"", "_")
|
device_name = device_name.replace("\"", "_")
|
||||||
deviceName = deviceName.replace("/", "_")
|
device_name = device_name.replace("/", "_")
|
||||||
|
|
||||||
return deviceName
|
return device_name
|
||||||
|
|
||||||
def getPlatform(self):
|
def get_platform(self):
|
||||||
|
|
||||||
if xbmc.getCondVisibility('system.platform.osx'):
|
if xbmc.getCondVisibility('system.platform.osx'):
|
||||||
return "OSX"
|
return "OSX"
|
||||||
|
@ -69,14 +69,14 @@ class ClientInfo(object):
|
||||||
else:
|
else:
|
||||||
return "Unknown"
|
return "Unknown"
|
||||||
|
|
||||||
def getDeviceId(self, reset=False):
|
def get_device_id(self, reset=False):
|
||||||
|
|
||||||
client_id = window('emby_deviceId')
|
client_id = window('emby_deviceId')
|
||||||
if client_id:
|
if client_id:
|
||||||
return client_id
|
return client_id
|
||||||
|
|
||||||
emby_guid = xbmc.translatePath("special://temp/emby_guid").decode('utf-8')
|
emby_guid = xbmc.translatePath("special://temp/emby_guid").decode('utf-8')
|
||||||
|
|
||||||
###$ Begin migration $###
|
###$ Begin migration $###
|
||||||
if not xbmcvfs.exists(emby_guid):
|
if not xbmcvfs.exists(emby_guid):
|
||||||
addon_path = self.addon.getAddonInfo('path').decode('utf-8')
|
addon_path = self.addon.getAddonInfo('path').decode('utf-8')
|
||||||
|
@ -84,7 +84,7 @@ class ClientInfo(object):
|
||||||
path = os.path.join(addon_path, "machine_guid")
|
path = os.path.join(addon_path, "machine_guid")
|
||||||
else:
|
else:
|
||||||
path = os.path.join(addon_path.encode('utf-8'), "machine_guid")
|
path = os.path.join(addon_path.encode('utf-8'), "machine_guid")
|
||||||
|
|
||||||
guid_file = xbmc.translatePath(path).decode('utf-8')
|
guid_file = xbmc.translatePath(path).decode('utf-8')
|
||||||
if xbmcvfs.exists(guid_file):
|
if xbmcvfs.exists(guid_file):
|
||||||
xbmcvfs.copy(guid_file, emby_guid)
|
xbmcvfs.copy(guid_file, emby_guid)
|
||||||
|
|
|
@ -35,9 +35,9 @@ class ConnectManager(object):
|
||||||
client_info = clientinfo.ClientInfo()
|
client_info = clientinfo.ClientInfo()
|
||||||
self.emby = embyserver.Read_EmbyServer()
|
self.emby = embyserver.Read_EmbyServer()
|
||||||
|
|
||||||
version = client_info.getVersion()
|
version = client_info.get_version()
|
||||||
device_name = client_info.getDeviceName()
|
device_name = client_info.get_device_name()
|
||||||
device_id = client_info.getDeviceId()
|
device_id = client_info.get_device_id()
|
||||||
|
|
||||||
self._connect = connectionmanager.ConnectionManager(appName="Kodi",
|
self._connect = connectionmanager.ConnectionManager(appName="Kodi",
|
||||||
appVersion=version,
|
appVersion=version,
|
||||||
|
|
|
@ -132,7 +132,7 @@ class DownloadUtils():
|
||||||
|
|
||||||
def startSession(self):
|
def startSession(self):
|
||||||
|
|
||||||
self.deviceId = self.clientInfo.getDeviceId()
|
self.deviceId = self.clientInfo.get_device_id()
|
||||||
|
|
||||||
# User is identified from this point
|
# User is identified from this point
|
||||||
# Attach authenticated header to the session
|
# Attach authenticated header to the session
|
||||||
|
@ -163,10 +163,10 @@ class DownloadUtils():
|
||||||
|
|
||||||
def getHeader(self, authenticate=True):
|
def getHeader(self, authenticate=True):
|
||||||
|
|
||||||
deviceName = self.clientInfo.getDeviceName()
|
deviceName = self.clientInfo.get_device_name()
|
||||||
deviceName = deviceName.encode('utf-8')
|
deviceName = deviceName.encode('utf-8')
|
||||||
deviceId = self.clientInfo.getDeviceId()
|
deviceId = self.clientInfo.get_device_id()
|
||||||
version = self.clientInfo.getVersion()
|
version = self.clientInfo.get_version()
|
||||||
|
|
||||||
if authenticate:
|
if authenticate:
|
||||||
auth = (
|
auth = (
|
||||||
|
|
|
@ -143,7 +143,7 @@ def resetDeviceId():
|
||||||
deviceId_old = window('emby_deviceId')
|
deviceId_old = window('emby_deviceId')
|
||||||
try:
|
try:
|
||||||
window('emby_deviceId', clear=True)
|
window('emby_deviceId', clear=True)
|
||||||
deviceId = clientinfo.ClientInfo().getDeviceId(reset=True)
|
deviceId = clientinfo.ClientInfo().get_device_id(reset=True)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.error("Failed to generate a new device Id: %s" % e)
|
log.error("Failed to generate a new device Id: %s" % e)
|
||||||
dialog.ok(
|
dialog.ok(
|
||||||
|
@ -208,8 +208,8 @@ def addUser():
|
||||||
doUtils = downloadutils.DownloadUtils()
|
doUtils = downloadutils.DownloadUtils()
|
||||||
art = artwork.Artwork()
|
art = artwork.Artwork()
|
||||||
clientInfo = clientinfo.ClientInfo()
|
clientInfo = clientinfo.ClientInfo()
|
||||||
deviceId = clientInfo.getDeviceId()
|
deviceId = clientInfo.get_device_id()
|
||||||
deviceName = clientInfo.getDeviceName()
|
deviceName = clientInfo.get_device_name()
|
||||||
userid = window('emby_currUser')
|
userid = window('emby_currUser')
|
||||||
dialog = xbmcgui.Dialog()
|
dialog = xbmcgui.Dialog()
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ class InitialSetup(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
self.addon_id = clientinfo.ClientInfo().getAddonId()
|
self.addon_id = clientinfo.ClientInfo().get_addon_id()
|
||||||
self.user_client = userclient.UserClient()
|
self.user_client = userclient.UserClient()
|
||||||
self.connectmanager = connectmanager.ConnectManager()
|
self.connectmanager = connectmanager.ConnectManager()
|
||||||
|
|
||||||
|
@ -43,10 +43,12 @@ class InitialSetup(object):
|
||||||
###$ Begin migration $###
|
###$ Begin migration $###
|
||||||
if settings('server') == "":
|
if settings('server') == "":
|
||||||
current_server = self.user_client.get_server()
|
current_server = self.user_client.get_server()
|
||||||
server = self.connectmanager.get_server(current_server)
|
if current_server is not None:
|
||||||
settings('ServerId', value=server['Id'])
|
server = self.connectmanager.get_server(current_server)
|
||||||
self.user_client.get_userid()
|
log.info(server)
|
||||||
self.user_client.get_token()
|
settings('ServerId', value=server['Id'])
|
||||||
|
self.user_client.get_userid()
|
||||||
|
self.user_client.get_token()
|
||||||
###$ End migration $###
|
###$ End migration $###
|
||||||
|
|
||||||
if settings('server'):
|
if settings('server'):
|
||||||
|
|
|
@ -13,7 +13,6 @@ import xbmcvfs
|
||||||
|
|
||||||
import api
|
import api
|
||||||
import artwork
|
import artwork
|
||||||
import clientinfo
|
|
||||||
import downloadutils
|
import downloadutils
|
||||||
import embydb_functions as embydb
|
import embydb_functions as embydb
|
||||||
import kodidb_functions as kodidb
|
import kodidb_functions as kodidb
|
||||||
|
@ -36,8 +35,6 @@ class Items(object):
|
||||||
self.embycursor = embycursor
|
self.embycursor = embycursor
|
||||||
self.kodicursor = kodicursor
|
self.kodicursor = kodicursor
|
||||||
|
|
||||||
self.clientInfo = clientinfo.ClientInfo()
|
|
||||||
self.addonName = self.clientInfo.getAddonName()
|
|
||||||
self.doUtils = downloadutils.DownloadUtils()
|
self.doUtils = downloadutils.DownloadUtils()
|
||||||
|
|
||||||
self.kodiversion = int(xbmc.getInfoLabel('System.BuildVersion')[:2])
|
self.kodiversion = int(xbmc.getInfoLabel('System.BuildVersion')[:2])
|
||||||
|
|
|
@ -8,7 +8,6 @@ import xbmc
|
||||||
|
|
||||||
import api
|
import api
|
||||||
import artwork
|
import artwork
|
||||||
import clientinfo
|
|
||||||
|
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
|
||||||
|
@ -25,8 +24,6 @@ class Kodidb_Functions():
|
||||||
|
|
||||||
self.cursor = cursor
|
self.cursor = cursor
|
||||||
|
|
||||||
self.clientInfo = clientinfo.ClientInfo()
|
|
||||||
self.addonName = self.clientInfo.getAddonName()
|
|
||||||
self.artwork = artwork.Artwork()
|
self.artwork = artwork.Artwork()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ import logging
|
||||||
import xbmc
|
import xbmc
|
||||||
import xbmcgui
|
import xbmcgui
|
||||||
|
|
||||||
import clientinfo
|
|
||||||
import downloadutils
|
import downloadutils
|
||||||
import embydb_functions as embydb
|
import embydb_functions as embydb
|
||||||
import playbackutils as pbutils
|
import playbackutils as pbutils
|
||||||
|
@ -26,8 +25,6 @@ class KodiMonitor(xbmc.Monitor):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
self.clientInfo = clientinfo.ClientInfo()
|
|
||||||
self.addonName = self.clientInfo.getAddonName()
|
|
||||||
self.doUtils = downloadutils.DownloadUtils()
|
self.doUtils = downloadutils.DownloadUtils()
|
||||||
|
|
||||||
log.info("Kodi monitor started.")
|
log.info("Kodi monitor started.")
|
||||||
|
|
|
@ -53,7 +53,6 @@ class LibrarySync(threading.Thread):
|
||||||
self.monitor = xbmc.Monitor()
|
self.monitor = xbmc.Monitor()
|
||||||
|
|
||||||
self.clientInfo = clientinfo.ClientInfo()
|
self.clientInfo = clientinfo.ClientInfo()
|
||||||
self.addonName = self.clientInfo.getAddonName()
|
|
||||||
self.doUtils = downloadutils.DownloadUtils().downloadUrl
|
self.doUtils = downloadutils.DownloadUtils().downloadUrl
|
||||||
self.user = userclient.UserClient()
|
self.user = userclient.UserClient()
|
||||||
self.emby = embyserver.Read_EmbyServer()
|
self.emby = embyserver.Read_EmbyServer()
|
||||||
|
@ -313,7 +312,7 @@ class LibrarySync(threading.Thread):
|
||||||
embycursor.close()
|
embycursor.close()
|
||||||
|
|
||||||
settings('SyncInstallRunDone', value="true")
|
settings('SyncInstallRunDone', value="true")
|
||||||
settings("dbCreatedWithVersion", self.clientInfo.getVersion())
|
settings("dbCreatedWithVersion", self.clientInfo.get_version())
|
||||||
self.saveLastSync()
|
self.saveLastSync()
|
||||||
xbmc.executebuiltin('UpdateLibrary(video)')
|
xbmc.executebuiltin('UpdateLibrary(video)')
|
||||||
elapsedtotal = datetime.now() - starttotal
|
elapsedtotal = datetime.now() - starttotal
|
||||||
|
|
|
@ -480,7 +480,7 @@ class Player(xbmc.Player):
|
||||||
# Stop transcoding
|
# Stop transcoding
|
||||||
if playMethod == "Transcode":
|
if playMethod == "Transcode":
|
||||||
log.info("Transcoding for %s terminated." % itemid)
|
log.info("Transcoding for %s terminated." % itemid)
|
||||||
deviceId = self.clientInfo.getDeviceId()
|
deviceId = self.clientInfo.get_device_id()
|
||||||
url = "{server}/emby/Videos/ActiveEncodings?DeviceId=%s" % deviceId
|
url = "{server}/emby/Videos/ActiveEncodings?DeviceId=%s" % deviceId
|
||||||
self.doUtils(url, action_type="DELETE")
|
self.doUtils(url, action_type="DELETE")
|
||||||
|
|
||||||
|
|
|
@ -261,7 +261,7 @@ class PlayUtils():
|
||||||
playurl = self.directPlay()
|
playurl = self.directPlay()
|
||||||
else:
|
else:
|
||||||
itemid = self.item['Id']
|
itemid = self.item['Id']
|
||||||
deviceId = self.clientInfo.getDeviceId()
|
deviceId = self.clientInfo.get_device_id()
|
||||||
playurl = (
|
playurl = (
|
||||||
"%s/emby/Videos/%s/master.m3u8?MediaSourceId=%s"
|
"%s/emby/Videos/%s/master.m3u8?MediaSourceId=%s"
|
||||||
% (self.server, itemid, itemid)
|
% (self.server, itemid, itemid)
|
||||||
|
|
|
@ -39,7 +39,7 @@ class WebSocket_Client(threading.Thread):
|
||||||
|
|
||||||
self.doUtils = downloadutils.DownloadUtils()
|
self.doUtils = downloadutils.DownloadUtils()
|
||||||
self.clientInfo = clientinfo.ClientInfo()
|
self.clientInfo = clientinfo.ClientInfo()
|
||||||
self.deviceId = self.clientInfo.getDeviceId()
|
self.deviceId = self.clientInfo.get_device_id()
|
||||||
self.librarySync = librarysync.LibrarySync()
|
self.librarySync = librarysync.LibrarySync()
|
||||||
|
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
|
|
|
@ -58,7 +58,7 @@ class Service(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
self.clientInfo = clientinfo.ClientInfo()
|
self.clientInfo = clientinfo.ClientInfo()
|
||||||
self.addonName = self.clientInfo.getAddonName()
|
self.addonName = self.clientInfo.get_addon_name()
|
||||||
logLevel = settings('logLevel')
|
logLevel = settings('logLevel')
|
||||||
self.monitor = xbmc.Monitor()
|
self.monitor = xbmc.Monitor()
|
||||||
|
|
||||||
|
@ -68,9 +68,9 @@ class Service(object):
|
||||||
# Initial logging
|
# Initial logging
|
||||||
log.warn("======== START %s ========" % self.addonName)
|
log.warn("======== START %s ========" % self.addonName)
|
||||||
log.warn("Python Version: %s", sys.version)
|
log.warn("Python Version: %s", sys.version)
|
||||||
log.warn("Platform: %s" % (self.clientInfo.getPlatform()))
|
log.warn("Platform: %s" % (self.clientInfo.get_platform()))
|
||||||
log.warn("KODI Version: %s" % xbmc.getInfoLabel('System.BuildVersion'))
|
log.warn("KODI Version: %s" % xbmc.getInfoLabel('System.BuildVersion'))
|
||||||
log.warn("%s Version: %s" % (self.addonName, self.clientInfo.getVersion()))
|
log.warn("%s Version: %s" % (self.addonName, self.clientInfo.get_version()))
|
||||||
log.warn("Using plugin paths: %s" % (settings('useDirectPaths') == "0"))
|
log.warn("Using plugin paths: %s" % (settings('useDirectPaths') == "0"))
|
||||||
log.warn("Log Level: %s" % logLevel)
|
log.warn("Log Level: %s" % logLevel)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue