+4
Discuss

How to: Plex Tiles!

iam 5 years ago in Panels (dashboards) / Special Tiles updated by Jon Rohan 5 years ago 17

Image 4495

I started this project some time ago just don't have time to make it a "official project/app."

Overview

A (very basic) PHP file uses the Tautulli API to get the most recently played movie TV show ETC and re-displays the image.


Possible upgrades if anyone is interested in forking it.  Adding a global host and API Key, adding global specific methods to each action, image caching ETC..

Prerequisites

  • Some basic tech knowledge  (I will answer some questions but have no plans of fully supporting this.)
  • Plex (obviously)
  • Tautulli - https://tautulli.com/  (Even if you don't want to do this, is still a great tool.)
  • PHP web server

1.  Enable the Tautulli API from: /settings#tab_tabs-web_interface

2. Get Tautulli API Key also at the bottom of that page.

3.  Note all the section ids from /libraries using Tautulli (example: /library?section_id=8)

4. Save the attached file (recently_played.phprecently_played.php) to your web server.

5. Edit that file and add your $host and $api_key values (from step #2)

6. Add the media title to AT.  This will be your web server url along with the section id.  Example: https://domain.com/recently_played.php?section=4

I think i'm pretty close to getting this to work... What does the 8660 in the php file represent on this line:
$host = "http://domain.com:8660"

The :8660 represents the port that Tautulli is running on, this can be configured in Tautulli settings.  I don't recall what the default is.

That is the url/default port of Tautulli.

+1

STILL AT IT... So, I have edited the first few (HIGHLIGHTED) lines of the php file to the following information which I believe is what the instructions shows, but I'm still unable to pull up any images in the AT using the media tiles into a Panel specifically for the Plex Posters.

This screenshot is the page result when I go to: http://mypublicipaddress/recently_played.php?section=16

Is there an issue with anything I have edited or is there something wrong with the php file?

Any help is greatly appreciated.

Discuss

At first glance I would think you need to enable short tags in your php.ini, or just replace <?php to the start of the file.

Did you var_dump some value to make sure php is actually processing the file?

My only other guess is you need to chmod the file to make sure your server has rights to it.

I too am having this same issue....

I dont have a ton of knowledge with PHP though so I could be failing somewhere else. 

I am getting these errors... 

user@h-server:/opt/Tautulli$ sudo php -S <ip>:80 recently_added.php
PHP 7.0.33-0ubuntu0.16.04.5 Development Server started at Wed Dec 25 11:36:13 2019
Listening on http://<ip>:80
Document root is /opt/Tautulli
Press Ctrl-C to quit.
[Wed Dec 25 11:36:16 2019] PHP Notice: Undefined property: stdClass::$data in /opt/Tautulli/recently_added.php on line 10
[Wed Dec 25 11:36:16 2019] PHP Notice: Trying to get property of non-object in /opt/Tautulli/recently_added.php on line 10
[Wed Dec 25 11:36:16 2019] PHP Notice: Undefined index: section in /opt/Tautulli/recently_added.php on line 8
[Wed Dec 25 11:36:16 2019] PHP Notice: Undefined property: stdClass::$data in /opt/Tautulli/recently_added.php on line 10
[Wed Dec 25 11:36:16 2019] PHP Notice: Trying to get property of non-object in /opt/Tautulli/recently_added.php on line 10
[Wed Dec 25 11:36:16 2019] PHP Notice: Undefined index: section in /opt/Tautulli/recently_added.php on line 13


You need to add the IP address/URL and your API key.

I omitted them from the screenshot

Did you enable API in settings -> web interface?  It's all the way at the bottom.

I was able to get mine to pull the latest played poster from each section. How do I change it to show the last 3, 5, 10, etc?

Also, how do I change the PHP file to allow me to pull Recently Added, Most Popular, etc? Now Playing would be nice to have as well -- is this possible?

I assume the trick is editing this section of the code, but I'm not sure which parameters need to be input.

      $jsonurl = $host . '/api/v2?apikey=' . $api_key . '&cmd=get_history&length=1§ion_id='. $_GET

Thanks!!

You could add another index value that you pass in to the file to show the image you want.

If I recall correctly, you can update:

$img = $json->response->data->data[0]->thumb;

to:

$img = $json->response->data->data[$_GET['index']]->thumb;

Then the URL you put into the media tile would be:

/recently_played.php?section=X&index=1

So of you wanted to show the last 5 entries, the media tiles would be:

/recently_played.php?section=X&index=1

/recently_played.php?section=X&index=2

/recently_played.php?section=X&index=3

/recently_played.php?section=X&index=4

/recently_played.php?section=X&index=5

+1

"Recently Added" is a bit tricky with TV posters but that endpoint is:

cmd=get_recently_added&count=1section_id=". $_GET['section']

"Most Popular" can be used by updating the cmd to:

cmd=get_home_stats&time_range=". $range;

$range = # of days of history for instance last 14 days, 30 days ETC.

I don't know if now playing is shown in history but all the other endpoints are outlined:

https://github.com/Tautulli/Tautulli/blob/master/API.md

I'd love to get this to work, I've got no knowledge of PHP what so ever thou. 

I do have a IIS running on my Windows Server, can I use PHP for IIS to run this?

I'm not familiar with PHP for IIS but it's basic PHP so you shouldn't have any problems.

Ok I'm just getting lost now... lol

I thought I did it... Then first attempt gives 

So I changed the start to <?php (as per your comment below) and then it creates an image file but totally blank...

Any idea where I'm going wrong? Really wanna be able to add this to my Actiontiles. But just struggling. Any help would be much appreciated.


I've put my recently_played.php file below...


Add http:// to your $host var.

Fore easy debugging add:

var_dump($var_name);

exit;


After every line to verify the results then test from there.

example:

$jsonurl = $host . '/api/v2?apikey=' . $api_key . '&cmd=get_history&length=1§ion_id='. $_GET['section'];

var_dump($jsonurl);

exit;

That should show a valid URL, you can also use post man or the browser to verify.  Repeat that process after each line to make sure you get the expected results.

Ok, so I added the http:// and the vardump and I'm getting a NULL response now in the browser.. Not sure how I've messed it up so early. Defo right info from Tautulli so not sure where I'm going wrong...

Obvs have removed my api key for posting online. lol