mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-10 12:16:12 +00:00
fix for missing artists links in kodi
This commit is contained in:
parent
3579fa3ca8
commit
acef00f2bb
2 changed files with 29 additions and 12 deletions
|
@ -131,6 +131,15 @@ class ReadEmbyDB():
|
||||||
if (jsonData[u'Items'] != ""):
|
if (jsonData[u'Items'] != ""):
|
||||||
result = jsonData[u'Items']
|
result = jsonData[u'Items']
|
||||||
|
|
||||||
|
#only return valid albums - which have artists
|
||||||
|
tempresult = []
|
||||||
|
for item in result:
|
||||||
|
if item["AlbumArtists"]:
|
||||||
|
tempresult.append(item)
|
||||||
|
|
||||||
|
result = tempresult
|
||||||
|
|
||||||
|
|
||||||
# Work around to only return items from the given list
|
# Work around to only return items from the given list
|
||||||
if (result != None and len(result) > 0 and len(itemList) > 0):
|
if (result != None and len(result) > 0 and len(itemList) > 0):
|
||||||
newResult = []
|
newResult = []
|
||||||
|
|
|
@ -27,7 +27,7 @@ import xml.etree.cElementTree as ET
|
||||||
|
|
||||||
addon = xbmcaddon.Addon(id='plugin.video.emby')
|
addon = xbmcaddon.Addon(id='plugin.video.emby')
|
||||||
addondir = xbmc.translatePath(addon.getAddonInfo('profile'))
|
addondir = xbmc.translatePath(addon.getAddonInfo('profile'))
|
||||||
dataPath = os.path.join(addondir,",musicfiles")
|
dataPath = os.path.join(addondir,",musicfiles" + os.sep)
|
||||||
|
|
||||||
|
|
||||||
class WriteKodiMusicDB():
|
class WriteKodiMusicDB():
|
||||||
|
@ -136,7 +136,7 @@ class WriteKodiMusicDB():
|
||||||
self.addOrUpdateArt(API().getArtwork(MBitem, "Disc"), artistid, "artist", "discart", cursor)
|
self.addOrUpdateArt(API().getArtwork(MBitem, "Disc"), artistid, "artist", "discart", cursor)
|
||||||
self.addOrUpdateArt(API().getArtwork(MBitem, "Backdrop"), artistid, "artist", "fanart", cursor)
|
self.addOrUpdateArt(API().getArtwork(MBitem, "Backdrop"), artistid, "artist", "fanart", cursor)
|
||||||
|
|
||||||
def addOrUpdateAlbumToKodiLibrary( self, embyId ,connection, cursor, isSingle=False):
|
def addOrUpdateAlbumToKodiLibrary( self, embyId ,connection, cursor):
|
||||||
|
|
||||||
addon = xbmcaddon.Addon(id='plugin.video.emby')
|
addon = xbmcaddon.Addon(id='plugin.video.emby')
|
||||||
WINDOW = xbmcgui.Window(10000)
|
WINDOW = xbmcgui.Window(10000)
|
||||||
|
@ -178,12 +178,6 @@ class WriteKodiMusicDB():
|
||||||
if MBitem.get("DateCreated"):
|
if MBitem.get("DateCreated"):
|
||||||
dateadded = MBitem["DateCreated"].split('.')[0].replace('T', " ")
|
dateadded = MBitem["DateCreated"].split('.')[0].replace('T', " ")
|
||||||
|
|
||||||
if isSingle:
|
|
||||||
releasetype = "single"
|
|
||||||
name = None
|
|
||||||
else:
|
|
||||||
releasetype = "album"
|
|
||||||
|
|
||||||
##### ADD THE ALBUM ############
|
##### ADD THE ALBUM ############
|
||||||
if albumid == None:
|
if albumid == None:
|
||||||
|
|
||||||
|
@ -221,7 +215,14 @@ class WriteKodiMusicDB():
|
||||||
|
|
||||||
#link album to artist
|
#link album to artist
|
||||||
artistid = None
|
artistid = None
|
||||||
for artist in MBitem.get("AlbumArtists"):
|
album_artists = None
|
||||||
|
if MBitem.get("AlbumArtists"):
|
||||||
|
album_artists = MBitem.get("AlbumArtists")
|
||||||
|
elif MBitem.get("ArtistItems"):
|
||||||
|
album_artists = MBitem.get("ArtistItems")
|
||||||
|
|
||||||
|
#some stuff here to get the albums linked to artists
|
||||||
|
for artist in album_artists:
|
||||||
cursor.execute("SELECT kodi_id FROM emby WHERE emby_id = ?",(artist["Id"],))
|
cursor.execute("SELECT kodi_id FROM emby WHERE emby_id = ?",(artist["Id"],))
|
||||||
result = cursor.fetchone()
|
result = cursor.fetchone()
|
||||||
if result:
|
if result:
|
||||||
|
@ -296,14 +297,21 @@ class WriteKodiMusicDB():
|
||||||
result = cursor.fetchone()
|
result = cursor.fetchone()
|
||||||
if result:
|
if result:
|
||||||
albumid = result[0]
|
albumid = result[0]
|
||||||
if not albumid:
|
if albumid == None:
|
||||||
#no album = single in kodi, we need to create a single album for that
|
#no album = single in kodi, we need to create a single album for that
|
||||||
albumid = self.addOrUpdateAlbumToKodiLibrary(MBitem["Id"],connection, cursor, True)
|
cursor.execute("select coalesce(max(idAlbum),0) as albumid from album")
|
||||||
|
albumid = cursor.fetchone()[0]
|
||||||
|
albumid = albumid + 1
|
||||||
|
pathsql="insert into album(idAlbum, strArtists, strGenres, iYear, dateAdded) values(?, ?, ?, ?, ?)"
|
||||||
|
cursor.execute(pathsql, (albumid, artists, genres, year, dateadded))
|
||||||
|
|
||||||
|
|
||||||
playurl = PlayUtils().getPlayUrl(server, MBitem["Id"], MBitem)
|
playurl = PlayUtils().getPlayUrl(server, MBitem["Id"], MBitem)
|
||||||
#for transcoding we need to create a fake strm file because I couldn't figure out how to set a http or plugin path in the music DB
|
#for transcoding we need to create a fake strm file because I couldn't figure out how to set a http or plugin path in the music DB
|
||||||
if playurl.startswith("http"):
|
if playurl.startswith("http"):
|
||||||
#create fake strm file
|
#create fake strm file
|
||||||
|
if not xbmcvfs.exists(dataPath):
|
||||||
|
xbmcvfs.mkdir(dataPath)
|
||||||
filename = item["Id"] + ".strm"
|
filename = item["Id"] + ".strm"
|
||||||
path = dataPath
|
path = dataPath
|
||||||
strmFile = os.path.join(dataPath,filename)
|
strmFile = os.path.join(dataPath,filename)
|
||||||
|
|
Loading…
Reference in a new issue