pkscout / script.artistslideshow

Addon to download images and additional information from fanart.tv, theaudiodb.com, and Last.FM of the currently playing artist. The images, along with local fanart, and info can be used by the skin to create a slideshow for the artist being listened to.
http://wiki.xbmc.org/index.php?title=Add-on:Artist_Slideshow
GNU General Public License v2.0
16 stars 17 forks source link

Parsing error with artist name having "/" in its name? #50

Closed Martin-Allard closed 6 years ago

Martin-Allard commented 6 years ago

Hi!

For some time the AS is stuck when the script is executing. Tonight I digged a little bit and I think my issue is related to the name of some of my artist. (artist name in the form "artist1 / artist2")

The error I get in kodi.log is:


8:16:01.794 T:1428157344 ERROR: EXCEPTION: argument "path" for method "XBMCAddon::xbmc::getCacheThumbName" must be unicode or str 18:16:01.814 T:1428157344 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--

So I opened default.py script and added the log entry "w.log( ["Get hash of %s" % (artist_info['artist'])], xbmc.LOGNOTICE )"


def _upgrade_get_artists_hashmap( self ):
    hDialog = xbmcgui.DialogProgressBG()
    hDialog.create( smartUTF8(language(32011)), smartUTF8(language(32012)) )
    hashmap = _ordereddict()
    response = xbmc.executeJSONRPC ( '{"jsonrpc":"2.0", "method":"AudioLibrary.GetArtists", "params":{"albumartistsonly":false, "sort":{"order":"ascending", "ignorearticle":true, "method":"artist"}},"id": 1}}' )
    try:
        artists_info = _json.loads(response)['result']['artists']
    except (IndexError, KeyError, ValueError):
        artists_info = []
    except Exception as e:
        lw.log( ['unexpected error getting JSON back from Kodi', e] )
        artists_info = []
    if artists_info:
        total = float( len( artists_info ) )
        count = 1
        for artist_info in artists_info:
            artist = smartUTF8( artist_info['artist'] ).decode('utf-8')
            lw.log( ["Get hash of %s" % (artist_info['artist'])], xbmc.LOGNOTICE )    <--- This line!
            artist_hash = itemHash( artist_info['artist'] )
            hashmap[artist_hash] = artist_info['artist']
            lw.log( ["%s has a hash of %s" % (artist, artist_hash)] )
            hDialog.update( int(100*(count/total)), smartUTF8( language(32011) ), artist )
            count += 1
        hashmap[itemHash( "Various Artists" )] = "Various Artists" 
    hDialog.close()
    return hashmap`

The result I got was this:


18:16:01.793` T:1428157344 NOTICE: [Artist Slideshow] Get hash of Emir Kusturica & The No Smoking Orchestra 18:16:01.793 T:1428157344 NOTICE: [Artist Slideshow] Get hash of Enigma 18:16:01.793 T:1428157344 NOTICE: [Artist Slideshow] Get hash of Enrico Rava 18:16:01.794 T:1428157344 NOTICE: [Artist Slideshow] Get hash of [u'Enrico Rava', u'Dino Saluzzi Quintet'] 18:16:01.794 T:1428157344 ERROR: EXCEPTION: argument "path" for method "XBMCAddon::xbmc::getCacheThumbName" must be unicode or str 18:16:01.814 T:1428157344 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--

So the error seems to be with xbmc.executeJSONRPC returning an array when artist name is having a slash, and I presume that this part of the script does not support processing array of artist... I also checked in my music.db and I realized that the entry "Enrico Rava / Dino Saluzzi" is the first entry that use the " artist1 / artist2 ". I've got "artist1/artist2" and this does not generate error (maybe the space is important for kodi?)

Please note that I know nothing about Kodi API itself and I am very newbie with python script so I'm doing a big guess about what happening! (but I am a senior embedded programmer for more than a decade, so I'm not afraid to jump in code I don't know in language I do not know!)

If its matter, I use kodi 17.6 and the version 2.1.2 or Artist Slide Show.

I really enjoy your plugin so I hope you will find a fix for my issue!

Martin

pkscout commented 6 years ago

That is a recently known issue. I have added some additional error checking to the next version to skip the times when the Kodi JSONRPC returns a list as the artist name rather than a string (it's suppose to separate artists into separate entries in the JSON return, but sometimes it returns a list of names instead). The good news is that AS only uses that hash during a one time upgrade routine (for older versions of AS), so here's a workaround. We're basically going to trick AS into thinking it's already done the upgrade.

  1. Go to your userdata/addon_data folder and find script.artistslideshow.
  2. Create a text file in that directory called migrationcheck.nfo and in that file put "2.1.0" (without the quotes).
  3. Create another text file called infocheck.nfo and put "true" in that file (without the quotes).
  4. Create a third text file called imagecheck.nfo and put "true" in that file (without the quotes).

Once you do that, restart Kodi and then try again. That should bypass the problem code.

Martin-Allard commented 6 years ago

Ok thanks, I will try it when I have some time! Glad there is a work around available (and that other googlers will found this info useful!)