Hi Zag, thanks for the interest.
Here it is, please keep in mind this is my first
Jason in py-thong hack:
Make the folder
Kodi/addons/script.myscript/ and add these two files:
Note, to anyone else reading this, you should probably have a look at
http://kodi.wiki/view/Add-on_structure#D..._structure for what an addon folder should contain should you decide to release it)
addon.xml
Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.myscript" name="MyScript" version="5.0.0" provider-name="Torben">
<requires>
<import addon="xbmc.python" version="2.20.0"/>
<import addon="script.module.simplejson" version="3.3.0"/>
</requires>
<extension point="xbmc.python.script" library="mydefault.py">
<provides>executable</provides>
</extension>
<extension point="xbmc.addon.metadata">
<summary lang="en">Get Albumartist DBID from AlbumDBID</summary>
<description lang="en">This script returns the ArtistDBID from a passed AlbumDBID</description>
<language></language>
<platform>all</platform>
<license>GNU GENERAL PUBLIC LICENSE Version 2</license>
<forum></forum>
<website></website>
<email></email>
<source></source>
</extension>
</addon>
mydefault.py
Code:
import xbmc, xbmcgui, xbmcaddon, sys
from operator import itemgetter
if sys.version_info >= (2, 7):
import json
else:
import simplejson as json
# Define global variables
WINDOW = xbmcgui.Window( 10000 )
__addon__ = xbmcaddon.Addon()
__addonversion__ = __addon__.getAddonInfo('version')
__addonid__ = __addon__.getAddonInfo('id')
__addonname__ = __addon__.getAddonInfo('name')
# Get value passed from KODI
ALBUMDBID = sys.argv[1]
# Lookup Album details in the library to get at the artist id:
json_query = xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "AudioLibrary.GetAlbumDetails", "params": {"albumid": %d, "properties": ["artistid"]}, "id": 1 }' % int(ALBUMDBID))
json_query = unicode(json_query, 'utf-8', errors='ignore')
json_response = json.loads(json_query)
if json_response.has_key('result') and (json_response['result'] != None) and json_response['result'].has_key('albumdetails'):
WINDOW.setProperty( 'dbLookParamFound' , str(json_response['result']['albumdetails']['artistid'][0]) )
Run the script and pass the
Album DBID from Kodi. Here is an example that runs onclick in a panel with albums:
Code:
<onclick>RunScript(script.myscript, $INFO[listitem.dbid])</onclick>
Now you can access the artist DBID in the skin using
window(Home).Property(dbLookParamFound), here is an example where it is used to fill a dynamic list with albums by artist:
Code:
<content sortby="year" sortorder="descending" target="music">musicdb://artists/$INFO[Window(Home).Property(dbLookParamFound)]/</content>
At least in the latest Jarvis