Update deprecated kodi api functions

This commit is contained in:
Odd Stråbø 2020-04-02 15:44:59 +02:00
parent d79b5077ae
commit a9793eb1c9
5 changed files with 32 additions and 23 deletions

View file

@ -61,10 +61,7 @@ class UsersConnect(xbmcgui.WindowXMLDialog):
item = xbmcgui.ListItem(label)
item.setProperty('id', user_id)
if self.kodi_version > 15:
item.setArt({'Icon': user_image})
else:
item.setIconImage(user_image)
item.setArt({'icon': user_image})
return item

View file

@ -3,11 +3,11 @@ from __future__ import division, absolute_import, print_function, unicode_litera
#################################################################################################
import json
import logging
import sys
import os
from six import iteritems
from six.moves.urllib.parse import parse_qsl, urlencode
from kodi_six import xbmc, xbmcvfs, xbmcgui, xbmcplugin, xbmcaddon
@ -206,9 +206,11 @@ def dir_listitem(label, path, artwork=None, fanart=None):
''' Gets the icon paths for default node listings
'''
li = xbmcgui.ListItem(label, path=path)
li.setThumbnailImage(artwork or "special://home/addons/plugin.video.jellyfin/resources/icon.png")
li.setArt({"fanart": fanart or "special://home/addons/plugin.video.jellyfin/resources/fanart.png"})
li.setArt({"landscape": artwork or fanart or "special://home/addons/plugin.video.jellyfin/resources/fanart.png"})
li.setArt({
"thumb": artwork or "special://home/addons/plugin.video.jellyfin/resources/icon.png",
"fanart": fanart or "special://home/addons/plugin.video.jellyfin/resources/fanart.png",
"landscape": artwork or fanart or "special://home/addons/plugin.video.jellyfin/resources/fanart.png",
})
return li
@ -712,12 +714,10 @@ def create_listitem(item):
li.setProperty('resumetime', str(item['resume']['position']))
li.setProperty('totaltime', str(item['resume']['total']))
li.setArt(item['art'])
li.setThumbnailImage(item['art'].get('thumb', ''))
li.setIconImage('DefaultTVShows.png')
li.setProperty('dbid', str(item['episodeid']))
li.setProperty('fanart_image', item['art'].get('tvshow.fanart', ''))
for key, value in item['streamdetails'].iteritems():
for key, value in iteritems(item['streamdetails']):
for stream in value:
li.addStreamInfo(key, stream)

View file

@ -460,6 +460,7 @@ def has_attribute(obj, name):
except AttributeError:
return False
def set_addon_mode():
''' Setup playback mode. If native mode selected, check network credentials.

View file

@ -388,7 +388,6 @@ class API(object):
return request_method(url, **request_settings)
def login(self, server_url, username, password=""):
path = "Users/AuthenticateByName"
authData = {
@ -432,7 +431,7 @@ class API(object):
response = self.send_request(server_address, "system/info/public")
try:
return response.json() if response.status_code == 200 else {}
except JSONDecodeError as e:
except json.JSONDecodeError as e:
LOG.error("Failed to get server public info. JSON error: %s" % e)
LOG.error(response.content)
return {}
@ -444,4 +443,3 @@ class API(object):
response = self.send_request(server_address, "system/info/public")
url = response.url.replace('/system/info/public', '')
return url

View file

@ -325,8 +325,10 @@ class Actions(object):
if intro or obj['Type'] == 'Trailer':
listitem.setArt({'poster': ""}) # Clear the poster value for intros / trailers to prevent issues in skins
listitem.setIconImage('DefaultVideo.png')
listitem.setThumbnailImage(obj['Artwork']['Primary'])
listitem.setArt({
'icon': 'DefaultVideo.png',
'thumb': obj['Artwork']['Primary'],
})
if obj['Premiere']:
obj['Premiere'] = obj['Premiere'].split('T')[0]
@ -487,12 +489,17 @@ class Actions(object):
'playcount': obj['PlayCount'],
'overlay': obj['Overlay']
}
listitem.setIconImage(obj['Artwork']['Thumb'])
listitem.setThumbnailImage(obj['Artwork']['Primary'])
listitem.setArt({
'icon': obj['Artwork']['Thumb'],
'thumb': obj['Artwork']['Primary'],
})
self.set_artwork(obj['Artwork'], listitem, obj['Type'])
if obj['Artwork']['Primary']:
listitem.setThumbnailImage(obj['Artwork']['Primary'])
listitem.setArt({
'thumb': obj['Artwork']['Primary'],
})
if not obj['Artwork']['Backdrop']:
listitem.setArt({'fanart': obj['Artwork']['Primary']})
@ -572,7 +579,9 @@ class Actions(object):
'title': obj['Title']
}
listitem.setProperty('path', obj['Artwork']['Primary'])
listitem.setThumbnailImage(obj['Artwork']['Primary'])
listitem.setArt({
'thumb': obj['Artwork']['Primary'],
})
if obj['Type'] == 'Photo':
metadata.update({
@ -588,10 +597,14 @@ class Actions(object):
})
listitem.setProperty('plot', obj['Overview'])
listitem.setProperty('IsFolder', 'false')
listitem.setIconImage('DefaultPicture.png')
listitem.setArt({
'icon': 'DefaultPicture.png',
})
else:
listitem.setProperty('IsFolder', 'true')
listitem.setIconImage('DefaultFolder.png')
listitem.setArt({
'icon': 'DefaultFolder.png',
})
listitem.setProperty('IsPlayable', 'false')
listitem.setLabel(obj['Title'])