I always thought it would be cool to have a display outside my media room that would show the poster of the movie or TV show that is currently playing. I searched the internet and found similar projects, which were all windows programs. There was just one problem… I wanted to run this project on a Raspberry Pi 3 running Linux. So, unsatisfied with the solutions I found online, I decided to build my own.
UPDATE: Code now updated to use X-Plex-Token.
Server Software :
Web Server – I am running NGINX.
Browser that runs in Kiosk mode – I am running Chromium.
Php – Programming language in which I ended up hacking together this code.
Sketch Up – To design the frame.
The Build :
Once this was complete, I measured the screen and loaded up Sketch Up to design the frame. Admittedly, this is where I made my first mistake of the project. Since I do not normally work with wood, I did not realize that the stated size of wood and the actual size of wood is different. (Example a 1×3 is not 1 inch by 3 inches. It is actually 3/4″ x 2-1/2″). Doh. So all the time and work I spent designing the frame in Sketch Up ended up being scrapped.
One of the design issues I needed to solve was how to keep the screen in the frame. I wanted to be able to easily remove the screen, but it also needed to be securely mounted in the frame. The easiest solution I could come up with was to use some simple L brackets. The front of the screen presses against the outside frame border and the L brackets were screwed in on the backside of the frame, pressing the screen forward and holding it in place.
Another design concern was mounting the complete assembly to the wall. Just like fastening the screen in the frame, I needed to be able to remove the completed frame from the wall easily. I came up with a solution that involved making a home made mount out of a few brackets, a dowel rod, and a 2 inch by 2 inch strip of wood. The mount is a strip of wood with two short dowels sticking out of the top and a few metal brackets to help keep it stable in the wall, along with one long screw through the strip into the wall stud. The frame then had two holes drilled into the top that lined up with the dowel rods on the mount. To hang the frame on the wall, I simply line up the holes in the frame to the dowels on the mount and slide it down. If I need to remove the frame for any reason I push up on the frame and it slides off the dowels.
I made a small hole in the left side of the frame (the side that would not be easily seen) through which I ran the screen control wires to the outer part of the frame. This gave me access to the power, brightness, etc. buttons since I would not have access to the back of the frame once it was mounted to the wall.
Next, it was time to stain. This is where I made my second mistake. The first stain was not correct and the frame had to be sanded down and re-stained. Second lesson learned… Always test stain on a scrap piece of wood. It may save you a lot of time and stress.
The Program :
Disclaimer – I am a network engineer, not a programmer. I play around with code. I am publishing this to give back to the communities that have helped me learn. There may be better ways of scraping the Plex Posters, but this is the way I chose to do it. I am open to suggestions. Use at your own risk.
Get it on Github
So, I had full intentions of writing the program in Python. However, after messing around with it for a few weeks, I realized my Python skills are lacking. It was a fun Python learning experience, but I wanted to finish the project and had to switch to another language.
I decided to rewrite the program in PHP and make it browser based. This allows me to have the Raspberry Pi boot to the desktop, automatically start a browser in kiosk mode, and open the PHP site.
How it Works :
This script scraps http://<IP Address of Plex server>:32400/status/sessions for clients and displays the poster of the currently playing movie or TV show. If nothing is currently playing, it will pull a random poster of an unwatched movie.
A functioning Plex Server
Web Server – I am running NGINX
PHP – I am running version 5.6.22
X-Plex-Token – Find out how to get your token here.
Custom Text on top and bottom of posters.
Cache posters locally.
- Copy all the files into the root of your web server.
- Fix permission on cache folder
chmod 777 cache
- Edit the config.php file. (Do not forget to do this)
- Open the URL to your server in a broswer.
The Finished Project :
Rasbian Jessie Setup Tips (Use at own risk) :
Rotate Screen 90 Degrees :
Add the following line to the bottom of your /boot/config.txt
Remove Raspberry Pi Power Warning :
Add the following line to the bottom of your /boot/config.txtavoid_warnings=2
Fix color depth on Raspberry Pi :
Add the following lines to the bottom of your /boot/config.txtframebuffer_depth=32 framebuffer_ignore_alpha=1
Stop Raspberry Pi screen form going blank :
Uncomment the following line in/etc/lightdm/lightdm.confxserver-command=X -s 0 -dpms
Auto start Chromium in Kiosk on Raspberry Pi Jessie :
( I used this repo to install Chromium deb http://dl.bintray.com/kusti8/chromium-rpi jessie main )
vim /home/pi/.config/autostart/chromium.desktop and add copy and paste the following[Desktop Entry] Type=Application Exec=/usr/bin/chromium-browser --noerrdialogs --disable-session-crashed-bubble --disable-infobars --kiosk http://&amp;lt;IP Address of server&amp;gt; Hidden=false X-GNOME-Autostart-enabled=true Name[en_US]=AutoChromium Name=AutoChromium Comment=Start ChromiumPlease follow and like us: