![]() |
v19 Filter movies by actor and list them in the GUI - Printable Version +- Kodi Community Forum (https://forum.kodi.tv) +-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32) +--- Forum: Kodi Application (https://forum.kodi.tv/forumdisplay.php?fid=93) +---- Forum: JSON-RPC (https://forum.kodi.tv/forumdisplay.php?fid=174) +---- Thread: v19 Filter movies by actor and list them in the GUI (/showthread.php?tid=366073) Pages:
1
2
|
Filter movies by actor and list them in the GUI - corus - 2021-12-20 What I try to accomplish is, I search my videodb for all movies with a specific actor and want to display those movies. But only by an API call. The best idea I had was to use GUI.ActivateWindow and pass a list of movieid's as parameters:
but I guess this isn't possible this way?!? Or since there is a built in filter in Kodi where I can filter by actors, is there a way to do the same just by using the API? Any ideas are welcome, thanks in advance. RE: Filter movies by actor and list them in the GUI - DaVu - 2021-12-23 Your best bet would be to create smart playlists and add a rule. Limit to "Actor" and for the condition "contains" and then the name of the actor you are searching for. You could try adding playlists via API or modify them: https://kodi.wiki/view/JSON-RPC_API/v12#Playlist.Add RE: Filter movies by actor and list them in the GUI - DaVu - 2021-12-24 It turns out that I was wrong xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"GUI.ActivateWindow", "params":{"window": "videos", "parameters":["videodb://movies/actors/<place_id_here>", "return"]}, "id":1}') Should do what you want. You just have to know the actor-ID. Spoke to @ronie and he told me that this should be possible this way. Haven't tried myself yet, but I would not doubt him ![]() RE: Filter movies by actor and list them in the GUI - corus - 2021-12-24 First, thanks for your and @ronie 's help ! Your hint with the smart playlist was a good start, I wrote a little python script to ssh into Kodi and echo a smart playlist with the desire actor and open it with GUI.ActivateWindow. This works but its a bit ugly using ssh therefore... So I was glad to hear that it should be possible with those parameters but unfortunately it doesn't work. As far as I read, Kodi is using as actor-id the full name, so I tried I also tried with %20 or + because of the spaces but the list keeps empty. I also couldn't found anything else related to a cast or actor id in the json-rpc docs. Edit: Okay, I just did take a look into the database, there are actor_id's and with those id's it does work. But now the question is, can I get those id's with the json rpc somehow? Otherwise I guess I have to query the database directly, since I use python it shouldn't be to hard and still cleaner then using ssh and echo ![]() RE: Filter movies by actor and list them in the GUI - DaVu - 2021-12-24 The "ID" is number, not a name. I played a bit with the command and unforunately we do not have anything to get a current list of actor names and their respective IDs. What I've done so far is to check my "MyVideo119.db" file (with some SQL-viewer) and inside that I found a list of actors with their IDs. Making this possible via "VideoLibrary.GetActors" would make a nice feature request ![]() The 2nd unfortunate thing is, that those IDs are not the same on different Kodi installation each with their own libraries. That might be different in case you are using a MySQL centralized database. For me, as I don't use a MySQL DB, I checked on my main HTPC and on my laptop and those IDs for the actors differ. So you have to check for yourself which ID will match. the command I used is: curl -X POST -H "content-type:application/json" http://192.168.1.162:8080/jsonrpc -u kodi:1234 -d '{"jsonrpc":"2.0","id":1,"method":"GUI.ActivateWindow","params":{"window":"videos", "parameters":["videodb://movies/actors/1"]}}' You have to replace the IP and the username:passwort ofc ![]() For me and my current installtion, the ID "1" shows movies of "Paul Walker". That might be different for you. (2021-12-24, 13:03)corus Wrote: This works but its a bit ugly using ssh therefore...Regarding the playlists....as said, you can use JSON for that as well. There's no need to use SSH. But in the end it's up to you what fits your needs ![]() RE: Filter movies by actor and list them in the GUI - corus - 2021-12-24 I guess this could be a nice feature since I read a couple of threads about a similar question. Yes I do use a centralized MySQL database and I think for now I will query the id with python directly from the database, should be the cleanest way until we can use the json rpc. Thanks again for your help and merry Christmas ![]() RE: Filter movies by actor and list them in the GUI - DaVu - 2021-12-24 Same to you and glad I could help ![]() RE: Filter movies by actor and list them in the GUI - corus - 2021-12-24 In case someone else want to do something similar:
RE: Filter movies by actor and list them in the GUI - DaVu - 2021-12-24 Nice 👍 RE: Filter movies by actor and list them in the GUI - User 405025 - 2021-12-26 hi, even if a fetching of actor db id is a bit cumbersome it's may not needed for your wished 'action' (show movies by actor x) i am just at the beginning by learning python, but this method / source is maybe helpfull. It queries the lib using the filter param. So , that you can check against in the json result tuple (may search/find/split : ' "total":* ' ) ( thats the part which i cannot provide and need to learn , but i am sure you can and know how to do it) And than using activate window using encoded xsp append if total result is greater than 0 A important thing to note is the diff betweeen movie,tvshow,episode (actor id wise, and path wise). Hope it helps even if my python skill is pretty low. Sources
EDIT: the python code box auto convert itself, after put in into syntax=python so the variables in the python code above should look this way movie_split_suffix = 'videodb://movies/titles/?xsp=%7B%22rules%22%3A%7B%22and%22%3A%5B%7B%22field%22%3A%22actor%22%2C%22operator%22%3A%22contains%22%2C%22value%22%3A%5B%22' movie_split_postfix = '%22%5D%7D%5D%7D%2C%22type%22%3A%22movies%22%7D' RE: Filter movies by actor and list them in the GUI - User 405025 - 2021-12-28 @corus , i learned more, got it workin this way.... json rpc used query lib to check for existing actor_name_id in movie and/or tvshow library using the filter param : - https://kodi.wiki/view/JSON-RPC_API/v12#VideoLibrary.GetMovies - https://kodi.wiki/view/JSON-RPC_API/v12#VideoLibrary.GetTVShows activate window using virtual xsp in path: - https://kodi.wiki/view/JSON-RPC_API/v12#GUI.ActivateWindow notify popup when no actor_name_id found : - https://kodi.wiki/view/JSON-RPC_API/v12#GUI.ShowNotification - unsure if faster than the the other way...
RE: Filter movies by actor and list them in the GUI - corus - 2021-12-28 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:
RE: Filter movies by actor and list them in the GUI - User 405025 - 2021-12-28 (2021-12-28, 19:41)corus Wrote: Hi @mardukL, very nice !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#XBMC.GetInfoLabels 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
as it just use for the exist check, i forget it too 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
to something like
RE: Filter movies by actor and list them in the GUI - corus - 2021-12-29 Quote:overread at first look, and No it's not a typo, but (and please correct me if I'm wrong), you can't query VideoLibrary.GetEpisodes without a tvshowid parameter what you won't get unless you query the TvShow first. Quote: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.)It's a good point, and I tested it, you are right with a VideoLibrary.GetTvshows query I don't get those actors. But to be honest it's not this important. I just thought last week, wouldn't it be nice if I could just ask my smart speaker "show me all movies with Ryan Reynolds", and thanks to you this is working now in a clean way without any SSH or MySQL queries ![]() RE: Filter movies by actor and list them in the GUI - DaVu - 2021-12-30 In case of filters, those have to be done differently: For example: {"jsonrpc":"2.0","id":1,"method":"VideoLibrary.GetMovies", "params":{"filter":{"field":"actor","operator":"is","value":"Sigourney Weaver"}}} This is also documented on our wiki: https://kodi.wiki/view/JSON-RPC_API/Examples In that case you are able to use the name instead of the actorID. Unfortunately you can't combine "GUI.ActivateWindow" with filters like that. I'm currently working on a JSON method "VideoLibrary.GetActor". Not as trivial as I thought, but I guess I can get some help from Team members. Might be helpful for scripts where you can store values in variables and create individual calls. |