OK, this is now solved. It took a while, the way to see the playlist updated with icons and track title and artist (witout having to display the Kodi playlist as described in the original post) is as follows:
First what I had:
SongFiles contains a list of song files as filesystem paths
python:
playList = xbmc.PlayList(xbmc.PLAYLIST_MUSIC)
for filename in SongFiles:
playList.add(url=filename)
And that will show in Chorus and Kore as a list of filesystem paths. Ugly as. The workaround was to force Kodi to display the playlist and this sees Kodi convert the file system paths to rich list items.
It turns out you can build and provide that listitem such that:
python:
playList = xbmc.PlayList(xbmc.PLAYLIST_MUSIC)
for filename in SongFiles:
playList.add(url=filename, listitem=CreateListItem(filename))
works beautifully. The trick is in writing the function CreateListItem().
But here is a way to that using the JSON RPC (it's a tad involved, but gets the job done):
python:
def FilePath_2_KodiPath(Song):
GetFileDetails = { "jsonrpc": "2.0",
"method": "Files.GetFileDetails",
"params": {
"file": f"{Song}",
"media": "music",
"properties": ["albumid"]
},
"id": 1
}
request = json.dumps(GetFileDetails)
response = xbmc.executeJSONRPC(request)
FileDetails = json.loads(response)
_, file_ext = os.path.splitext(Song)
song_id = FileDetails["result"]["filedetails"]["id"]
album_id = FileDetails["result"]["filedetails"]["albumid"]
kodi_path = f" musicdb://songs/{song_id}.{file_ext}?albumid={album_id}"
return kodi_path
def KodiPath(Song):
if Song.startswith("musicdb://"):
return Song
else:
return FilePath_2_KodiPath(Song)
def SongID(Song):
song = KodiPath(Song)
m = re.search('musicdb://songs/(\d+)', song)
song_id = int(m.group(1))
return song_id
def SongProperties(Song):
song_id = SongID(Song)
# This is all the song properties known:
# See: https://github.com/xbmc/xbmc/blob/master...n#L526L541
GetSongDetails = { "jsonrpc": "2.0",
"method": "AudioLibrary.GetSongdetails",
"params": { "songid" : song_id,
"properties": [
"title", "artist", "albumartist", "genre", "year",
"rating", "album", "track", "duration", "comment",
"lyrics", "musicbrainztrackid", "musicbrainzartistid",
"musicbrainzalbumid", "musicbrainzalbumartistid",
"playcount", "fanart", "thumbnail", "file", "albumid",
"lastplayed", "disc", "genreid", "artistid", "displayartist",
"albumartistid", "albumreleasetype", "dateadded",
"votes", "userrating", "mood", "contributors",
"displaycomposer", "displayconductor", "displayorchestra", "displaylyricist",
"sortartist", "art", "sourceid", "disctitle", "releasedate", "originaldate",
"bpm", "samplerate", "bitrate", "channels", "datemodified", "datenew" ]
},
"id": 1}
request = json.dumps(GetSongDetails)
response = xbmc.executeJSONRPC(request)
SongDetails = json.loads(response)
return SongDetails["result"]["songdetails"]
def CreateListItem(Song):
sp = SongProperties(Song)
if (len(sp["artist"]) > 0):
artist = sp["artist"][0]
trackTitle = sp["title"]
album = sp["album"]
trackPath = sp["file"]
thumb = sp["thumbnail"]
duration = int(sp["duration"])
fanart = sp["fanart"]
if (fanart == ""):
cache_name = xbmc.getCacheThumbName( str(artist) )
fanart = f"special://profile/Thumbnails/Music/Fanart/{cache_name}"
listitem = xbmcgui.ListItem(trackTitle)
listitem.setInfo('music', { 'title': trackTitle, 'artist': artist, 'album': album, 'duration': duration })
listitem.setArt({"thumb":thumb, "fanart": fanart})
return listitem
And voila, the playlist in Chorus and in Kore looks neat without touching the Kodi UI.