Cyberon.org - Notebook


PlexConnect Logo

How to get PLEX on older AppleTV's.


One of the things that is missing on the older AppleTV's (gen 2 or 3) is a Plex-client. Wouldn't it be great to be able to stream your movies and other media from your Plex Media Server (PMS) to your AppleTV?  Well, it is possible, and you don't need to jailbreak your AppleTV. If you have PMS running under Windows or Mac OS it is neatly described in Github on the internet. I will describe here how it's done for a PMS installed in an iocage jail on FreeNAS.
As you have seen, there is the Trailer app on your AppleTV, that plays trailers of movies from a particular Apple site. Some smart guys figured out how to adapt the trailer app to play media from your Plex media server instead. This is how it's done:
First you need to install PlexConnect in the same location as your Plex Media Server (PMS). Apple requires an https connection between Plex Media Server and AppleTV. So we have to generate a selfsigned certificate for PlexConnect and put it in the proper location. 
Second we will configure PlexConnect and last we have to change the DNS setting of the AppleTV and install the selfsigned certificate on the AppleTV as well. This is how its done:

  1. Installing PlexConnect in the FreeNAS PMS Jail.
    Let's download PlexConnect from the github website. For PlexConnect to run it requires python 2.7 and to generate the selfsigned certificates we need openssl. So some additional packages need to be installed in the Jail. Step into your Plex Server iocage Jail and open the Jail shell. Type the following commands:

       - pkg install nano git bash
       - pkg install python27 openssl
       - cd /
       - git clone https://github.com/iBaa/PlexConnect.git
    

    For the selfsigned certificates, type the following commands:

       - cd /PlexConnect/assets/certificates
       - openssl req -new -nodes -newkey rsa:2048 -out trailers.pem -keyout trailers.key -x509 -days 3650 -subj "/C=US/CN=trailers.apple.com"
       - openssl x509 -in trailers.pem -outform der -out trailers.cer && cat trailers.key >> trailers.pem
    

    You will find now in the directory /PlexConnect/assets/certificates three new files: trailers.cer, trailers.key and trailers.pem.
  2. Configuration of PlexConnect in the Jail.
    Let's run now PlexConnect for the first time:

       - cd /
       - /usr/local/bin/python2.7 /PlexConnect/PlexConnect.py
    		

    Stop it with Ctrl+C. In the directory /PlexConnect you will find now a new file Settings.cfg. Most probably this file is OK, but check that the values for ip_pms and for ip_plexconnect are identical to the (hopefully fixed) IP address of your Plex Media Server. The default value for ip_dnsmaster is 8.8.8.8 (Google), but you may change it to for example 208.67.222.222 (OpenDNS).
  3. Running PlexConnect automaticaly in the Jail.
    To start Plexconnect automatically and run it as a daemon in the background, we must point it to Python 2.7. Type the following command in the Jail shell:

       - nano /PlexConnect/PlexConnect_daemon.bash
      		

    Find the line PYTHON="python" and change it to: PYTHON="/usr/local/bin/python2.7". Just to make sure, check if you can start and stop PlexConnect with the following commands:

       - bash /PlexConnect/PlexConnect_daemon.bash start
       - bash /PlexConnect/PlexConnect_daemon.bash stop
      		

    It works, so let's make a bootscript with the name plexconnect. Please be aware, that a bootscript is a plain textfile. If it contains any (invisible) format instructions from texteditors such as Word or TextEdit, it looks good, but it won't work. Very difficult to find such an error! Unfortunately your best bet is to open plexconnect in nano:

       - nano /etc/rc.d/plexconnect
      		

    and type in it the following script :

    #!/bin/sh
    #
    #PROVIDE:  PlexConnect
    #REQUIRE:  Daemon
    #KEYWORD:  Shutdown
    
    . /etc/rc.subr
    
    name=plexconnect
    rcvar=plexconnect_enable
    
    start_cmd="${name}_start"
    stop_cmd="${name}_stop"
    status_cmd="${name}_status"
    extra_commands="status"
    
    plexconnect_start()
    {
    /usr/local/bin/bash /PlexConnect/PlexConnect_daemon.bash start
    }
    plexconnect_stop()
    {
    /usr/local/bin/bash /PlexConnect/PlexConnect_daemon.bash stop
    }
    plexconnect_status()
    {
    /usr/local/bin/bash /PlexConnect/PlexConnect_daemon.bash status
    }
    
    load_rc_config $name
    run_rc_command “$1”
    

    Check carefully for any errors and save the script-file plexconnect. Type in the Jail shell:

       - chmod 0555 /etc/rc.d/plexconnect
       - nano /etc/rc.conf
    		

    At the bottom of this file rc.conf add a line: plexconnect_enable="YES" . Check if your scriptfile works:

       - service plexconnect start
       - service plexconnect stop
       - service plexconnect status
       - service plexconnect start
    		
    If it does not work, there is something wrong with your scriptfile plexconnect. Recheck it for any typo errors.
  4. Configuration of the AppleTV:
    On the AppleTV we need to change it's Network settings and we have to install our selfsigned certificate on it.
    • Network configuration:
      Go to Settings -> General -> Network. Click Wi-Fi -> click your Wi-Fi network name. In Wi-Fi configuration click Configure DNS. Change the DNS setting from "Automatic" to "Manual". Enter the IP address of PlexConnect on your server and click Done.
      Return to the AppleTV main screen, go to Settings -> General and click Network. Check that under DNS you see PlexConnect's IP address.
    • Install the selfsigned certificate on AppleTV:
      Go to Settings -> General. Scroll down to highlight "Send Data to Apple" and set it to "no". With "Send Data to Apple" still highlighted, press the "Play" button (not the round "Select" button in the middle of the remote). You will be prompted to add a profile.
      Enter http://trailers.apple.com/trailers.cer, click "Submit" and you are done!

    Go back the the AppleTV main screen, and click the trailer icon. It should show now the content of your Plex Media Server. If it says "trailers are not available right now, try again later" there is something wrong in the settings of your AppleTV. Just repeat the two steps before....