(2021-12-28, 19:41)corus Wrote: Hi @mardukL, very nice !
I guess this is what @DaVu had in mind with using a smart playlist but I didn't find anything to create a "virtual xsp" so I gave up this idea very quickly...
But so as you, I learned more again and realized how powerful Kodi can be in terms of customization
Thank you very much for your input too!
Here an updated version of my script with @mardukL solution:
python:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import requests
import json
import urllib.parse
class ShowContentWithActor:
def __init__(self, actor, content):
self.kodi_ip = "KODI_IP"
self.kodi_port = 8080
params = {"sort": {"order": "ascending", "method": "year", "ignorearticle": True},
"filter": {"actor": "%s" % actor}}
if content == "movies":
result = self.sendKodiRequest("VideoLibrary.GetMovies", params)
video_db = "videodb://movies/titles/?xsp="
if content == "tvshows" or content == "episodes":
result = self.sendKodiRequest("VideoLibrary.GetTvshows", params)
if content == "tvshows":
video_db = "videodb://tvshows/titles/?xsp="
else:
content = "tvshows"
video_db = "videodb://tvshows/titles/-1/-1/?xsp="
actor_result = result.get("result")
if actor_result.get(content):
decoded_xsp = '{"rules":{"and":[{"field":"actor","operator":"is","value":["%s"]}]},"type":"%s"}' % (actor, content)
url = video_db + urllib.parse.quote(decoded_xsp.encode())
self.sendKodiRequest("GUI.ActivateWindow", {"window": "videos", "parameters": ["%s" % url]})
else:
self.sendKodiRequest("GUI.ShowNotification", {"title": "sorry...", "message": "no %s Items with %s found" % (content, actor)})
def sendKodiRequest(self, method, params=dict()):
payload = {"jsonrpc": "2.0", "id":1}
payload.update({"method": method, "params": params})
url = "http://%s:%s/jsonrpc" % (self.kodi_ip, self.kodi_port)
try:
r = requests.post(url, data=json.dumps(payload))
if r.status_code == 200:
return r.json()
except Exception as e:
print("Connection Error")
return False
ShowContentWithActor("kat dennings", "tvshows")
Nice, espeacially for remote it.
And thanks and problem, i also liked to learn a little bit more about py and using json rpc recently.
The xsp method is not my idea, just found it here ( skinning related )
-
https://forum.kodi.tv/showthread.php?tid=341640
So i just had to figure out how can encode/decode via python.
Terms 'virtual' xsp:
kodi folderpath s can make use of xsp appended 'url' s
- you can test them by
1.
create a smart playlist and navigate into it
or
create a custom library node and navigate to
or
just navigate to
library://videos/ and go into any path startig at this root dir
2.
than return the Container FolderPath
maybe
via Container.FolderPath ( for the container itself ) or listitem.folderpath ( for a specific item )
e.g.
- xbmc.getInfoLabel('Container.FolderPath')
or
via json :
https://kodi.wiki/view/JSON-RPC_API/v12#...InfoLabels
3.
you 'll notice that you get an 'percent' encoded url.
as that is for sure not really readable by humans,
url - decode them to take a look at the syntax ( dict?) and for sure using it as "template" for creating a definition for a script using
those 'virtual' nodes. ( as it can be customiced without provide a file, just encode it and send it to kodi).
EDIT: @
corus
you can ommit the optional "sort" param
python:
"sort": { "order": "ascending", "method": "year", "ignorearticle": true }
as it just use for the exist check, i forget it too
python:
params = {"filter": {"actor": "%s" % actor}}
should be enough
edit again:
overread at first look, and
unsure if typo on your end, but another thing to note is that episodes can have cast members, which arent part of the tv shost cast and vice versa.
so even if episodes share root url with tv shows, the check exist for episode castmembers has to excluded from tv shows query
use
VideoLibrary.GetEpisodes instead.
also for the xsp/smartplaylist , its important to differ the content type between shows n episodes.
the show 'the simpsons' is a good example to test ( if you got it stored, liam neeson, william dafoe, woody harrelson and more can be found in episodes but will not return results on tvshow.)
so , best is test any show you got ,where you can imagine an 'cameo' actor for an episode which is not part of the show itself.
exist_results = xbmc.executeJSONRPC(' {"jsonrpc": "2.0", "method": "VideoLibrary.Get%s", "params": { "sort": { "order": "ascending", "method": "year", "ignorearticle": true }, "filter": { "actor": "%s" } }, "id": "lib%s" }' % (container_content,actor_name_id,container_content)).find('"total":0')
from
python:
if content == "movies":
result = self.sendKodiRequest("VideoLibrary.GetMovies", params)
video_db = "videodb://movies/titles/?xsp="
if content == "tvshows" or content == "episodes":
result = self.sendKodiRequest("VideoLibrary.GetTvshows", params)
if content == "tvshows":
video_db = "videodb://tvshows/titles/?xsp="
else:
content = "tvshows"
video_db = "videodb://tvshows/titles/-1/-1/?xsp="
to something like
python:
result = self.sendKodiRequest("VideoLibrary.Get%s" % content, params)
if content == "movies" or content == "tvshows":
video_db = "videodb://%s/titles/?xsp=" % content
else:
video_db = "videodb://tvshows/titles/-1/-1/?xsp="