Kodi Community Forum

Full Version: Webpage to display Player.GetItem ["art"]?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I am very new to JSON and am not very good with js as is.

I am trying to display tvshow.poster in a <img>.

Code:
http://localhost:8080/jsonrpc?request=jsonrpc? {"jsonrpc": "2.0", "method": "Player.GetItem", "params": { "properties": ["title", "album", "artist", "season", "episode", "runtime", "showtitle","tvshowid", "file", "art"], "playerid": 1 }, "id": "1"}

When I run the above in the url of a browser i get:

Quote:{"id":1,"jsonrpc":"2.0","result":{"item":{"art":{"thumb":"image://http%3a%2f%2fthetvdb.com%2fbanners%2fepisodes%2f247808%2f4676426.jpg/","tvshow.banner":"image://http%3a%2f%2fthetvdb.com%2fbanners%2fgraphical%2f247808-g4.jpg/","tvshow.fanart":"image://http%3a%2f%2fthetvdb.com%2fbanners%2ffanart%2foriginal%2f247808-5.jpg/","tvshow.poster":"image://http%3a%2f%2fthetvdb.com%2fbanners%2fposters%2f247808-6.jpg/"},"id":37,"label":"Moot Point","title":"Moot Point","type":"episode"}}}

So I have
$raw_art = ""; //raw art = the url from above with %2f etc instead of /
$art = rawurldecode($raw_art); // converts it from %2f to / etc

Now I want my webpage to run this and then take the url for only tvshow.poster & movie.post (I think there is that as well?) and the echo that into a img

Code:
<img src="<?php echo $poster ?>" width="136" height="200">

How do I run a JSON command in php and then take the required element (tvshow.poster) into $raw_art?

This is what I have so far

http://pastebin.com/YXfKTi8y

Any help would be great.

Thanks in advanced
this is how i use it with curl in php:

PHP Code:
                                $therequest urlencode("\"jsonrpc\": \"2.0\", \"method\": \"Player.GetItem\", \"params\": { \"properties\": [\"album\",\"artist\",\"director\",\"writer\",\"tagline\",\"episode\",\"file\",\"title\",\"showtitle\",\"season\",\"genre\",\"year\",\"rating\",\"runtime\",\"firstaired\",\"plot\",\"fanart\",\"thumbnail\",\"tvshowid\"], \"playerid\": 0 }, \"id\": \"1\"");
                                
$jsoncontents "$ip/jsonrpc?request={".$therequest."}";
                                
$ch curl_init();
                                
curl_setopt($chCURLOPT_RETURNTRANSFER1);
                                
curl_setopt($chCURLOPT_URL"$jsoncontents");
                                
curl_setopt ($chCURLOPT_CONNECTTIMEOUT1);
                                
$output curl_exec($ch); 

you can then set variables by json decoding the $output from above and referencing parts of the json structure:

PHP Code:
$jsonnowplaying json_decode($output,true);
$thetitle $jsonnowplaying['result']['item']['title']; 

for your example you can use:

PHP Code:
$therequest urlencode("\"jsonrpc\": \"2.0\", \"method\": \"Player.GetItem\", \"params\": { \"properties\": [\"art\"], \"playerid\": 1 }, \"id\": \"1\"");
$jsoncontents "$ip/jsonrpc?request={".$therequest."}";
$ch curl_init();
curl_setopt($chCURLOPT_RETURNTRANSFER1);
curl_setopt($chCURLOPT_URL"$jsoncontents");
curl_setopt ($chCURLOPT_CONNECTTIMEOUT1);
$output curl_exec($ch);
$jsonnowplaying json_decode($output,true);
$tvshowposter $jsonnowplaying['result']['item']['art']['tvshow.poster'];