PlexConnect running on a QNAP NAS

Hi fellow Plexians!

 

I've managed to get PlexConnect running on a QNAP TS-459 Pro II (3.8.2) and ATV3 (5.2.1), so I thought to share a short install guide. I'm no hacker why my solutions might no be the most elegant ones, but they work, at least for me. Please provide your experiences.

  1. First, download and extract PlexConnect package (this is release 0.1)
    https://github.com/iBaa/PlexConnect/archive/v0.1-iOS-pre5.1.zip
  2. Then configure the DNS setting on your ATV, see below link, and follow steps 3-5, in the same guide, to edit the "Settings.py" file.
    https://github.com/iBaa/PlexConnect/wiki/OSX-and-ATV-with-5.2-firmware-and-ethernet-internet-connection-installation-guide
  3. Install and activate Python for QNAP. Version 2.7 is available in the QPKG Center.
  4. Check if your web server on the QNAP is running. If so, you might need to change the port 80 to something else or turn off the web server.
  5. Use SSH to log on as admin to the QNAP. Upload all the PlexConnect files to a preferable location. I placed my files here. 
    /root/Library/PlexConnect/
    Might be better locations?
  6. Then open up a Terminal window and connect to your QNAP. Locate your folder and execute PlexConnect.py.
    cd /root/Library/PlexConnect
    ​./PlexConnect.py
  7. PlexConnect should now be running and you will see the output in your terminal window. Hopefully without any errors. Mine worked at the first try so I haven't any hints for troubleshooting. On the downside, when you close the terminal you will terminate PlexConnect. But I managed in a simple way to get the PlexConnect autorun on my QNAP, explained in the next steps.
  8. In order to run PlexConnect on NAS startup you need to create a run script that is disguised as QPKG. I followed all steps in the "QPKG-based method" in the guide below.
    http://wiki.qnap.com/wiki/Running_Your_Own_Application_at_Startup
  9. My "autorun.sh" script looks like this.
    #!/bin/sh
    /share/MD0_DATA/.qpkg/Python/bin/python /root/Library/PlexConnect/PlexConnect.py -d
  10. Remember to set the execute bit and then restart your NAS. Hopefully PlexConnect will automatically run when your NAS has booted up.

Good luck! :D

Thanks for the detailed worksheet. My SSH skills are near nil and I got stuck at the following step.

"5. Use SSH to log on as admin to the QNAP. Upload all the PlexConnect files to a preferable location. I placed my files here."

 

I'm able to SSH to the QNAP, no problem. How do I create a folder in the root folder and how do I copy the installation python files to that folder? Is this accomplished via the QNAP Web UI or SSH? If via SSH, could you elaborate on the required steps?

Thanks in advance.

Thanks for the detailed worksheet. My SSH skills are near nil and I got stuck at the following step.

"5. Use SSH to log on as admin to the QNAP. Upload all the PlexConnect files to a preferable location. I placed my files here."

 

I'm able to SSH to the QNAP, no problem. How do I create a folder in the root folder and how do I copy the installation python files to that folder? Is this accomplished via the QNAP Web UI or SSH? If via SSH, could you elaborate on the required steps?

Thanks in advance.

1. To create a folder, type "mkdir" and give it a name

2. I usually copy files to one of my folders on Qnap and then use "cp" command to copy files from /share/HDA_DATA/Multimedia/Inbox to wherever you need to copy things.

Thanks for the feedback. I was able to use the 'mkdir' command and then after much futzing, I was able to figure out the 'scp' command when logged into Terminal on my Mac.

scp -r ~/Desktop/PlexConnect-XML_templates/* admin@0.0.0.0:/root/Library/PlexConnect/

Where 0.0.0.0 is the local address of my QNAP.

Getting closer.

Cool, I did not know about "scp" - "The general format for the command to upload to the server"

With item #4. What will happen if my QNAP's web server is running? Is it fine to change my web server's port from 80 to any number? Will this prevent from having a conflict with PlexConnect's?

So after disabling Web Server of my QNAP, this is the error:

PlexConnect : ***

PlexConnect : PlexConnect
PlexConnect : Press ENTER to shut down.
PlexConnect : ***
PlexConnect : IP_self: 192.168.0.3
PlexGDM : ***
PlexGDM : looking up Plex Media Server
PlexGDM : ***
PlexGDM : servers discovered: 1
DNSServer : ***
DNSServer : Starting up.
DNSServer : intercept trailers.apple.com: 192.168.0.3
DNSServer : forward other to higher level DNS: 124.106.7.2
DNSServer : ***
WebServer : Failed to connect to port 80 (http): [Errno 98] Address already in use
PlexConnect : WebServer not alive. Shutting down.
DNSServer : Shutting down.

I am probably not the best person for this process but I hope you guys can help me. I was able to set this up on my computer so I am not a total noob but have never SSH'ed in my NAS. How do I go about doing that. I am essentially confused from step 4 onwards. thanks

I noticed that after disabling the webserver my QNAP started another webserver called Qthttpd within a minute or so. I just killed it with 

killall Qthttpd

and then started the PlexConnect.py before it kicked in again.

I am probably not the best person for this process but I hope you guys can help me. I was able to set this up on my computer so I am not a total noob but have never SSH'ed in my NAS. How do I go about doing that. I am essentially confused from step 4 onwards. thanks

ssh admin@0.0.0.0

Change the ip address to that of your qnap.

I enabled back my Web Server, but this time I changed the port to 888.

Ran back ./PlexConnect.py and this is the output:

./PlexConnect.py             

PlexConnect : ***
PlexConnect : PlexConnect
PlexConnect : Press ENTER to shut down.
PlexConnect : ***
PlexConnect : IP_self: 192.168.0.3
PlexGDM : ***
PlexGDM : looking up Plex Media Server
PlexGDM : ***
PlexGDM : servers discovered: 1
DNSServer : ***
DNSServer : Starting up.
DNSServer : intercept trailers.apple.com: 192.168.0.3
DNSServer : forward other to higher level DNS: 124.106.7.2
DNSServer : ***
WebServer : ***
WebServer : WebServer: Serving HTTP on 0.0.0.0 port 80.
WebServer : ***

It has been like this for around 10 minutes or so. Is there something wrong with this?

have you set your dns server in your atv to the ipaddress of the qnap?

Yes. The IP Address of my QNAP is 192.168.0.3 so I changed my aTV3 DNS to 192.168.0.3.

In Settings.py, I changed 8.8.8.8 to 124.106.7.2, which is the DNS given by my ISP.

Thanks for that that was really helpful. I am now stuck on Step 5 sorry.

[~] # mkdir
BusyBox v1.01 (2013.04.25-16:38+0000) multi-call binary
 
Usage: mkdir [OPTION] DIRECTORY...
 
Create the DIRECTORY(ies) if they do not already exist
 
Options:
-m set permission mode (as in chmod), not rwxrwxrwx - umask
-p no error if existing, make parent directories as needed
 
[~] # 
 
 
This is where I am at. I can now SSH in. I type in mkdir and I get this directory. How do I name the folder? I see the scp command in one of the posts but I am having a hard time with this part

ssh admin@0.0.0.0

Change the ip address to that of your qnap.

apatel87, please follow post #4

Yes. The IP Address of my QNAP is 192.168.0.3 so I changed my aTV3 DNS to 192.168.0.3.

In Settings.py, I changed 8.8.8.8 to 124.106.7.2, which is the DNS given by my ISP.

Is it working? The terminal will scroll through as it receives requests from PlexConnect.

In the Setting.py I also changed the following to my PMS ip. 

10.1.1.212 is my PMS ip so change to your PMS ip.

def getIP_PMS():  # default IP, if GDM fails... todo: do we need this fall back?
    return '10.1.1.212'

I added Photo to my Sections. I can access the photos from aTV 3's Trailer. But when I try to access the Music section, it displays 'Trailer is unavailable'.

WebServer : serving application.js
192.168.0.2 - - [08/Jun/2013 12:32:49] "GET /appletv/us/js/application.js HTTP/1.1" 200 -
WebServer : serving /share/HDA_DATA/.qpkg/PlexMediaServer/Library/PlexConnect/assets/plexconnect.xml
192.168.0.2 - - [08/Jun/2013 12:32:49] "GET /plexconnect.xml HTTP/1.1" 200 -
WebServer : serving .xml: /library/sections
192.168.0.2 - - [08/Jun/2013 12:32:50] "GET /library/sections HTTP/1.1" 200 -
WebServer : serving .xml: /channels/all&PlexConnect=Channels
192.168.0.2 - - [08/Jun/2013 12:32:50] "GET /channels/all&PlexConnect=Channels HTTP/1.1" 200 -
WebServer : serving /share/HDA_DATA/.qpkg/PlexMediaServer/Library/PlexConnect/assets/search.xml
192.168.0.2 - - [08/Jun/2013 12:32:50] "GET /search.xml HTTP/1.1" 200 -
WebServer : serving .xml: /&PlexConnect=Settings
192.168.0.2 - - [08/Jun/2013 12:32:50] "GET /&PlexConnect=Settings HTTP/1.1" 200 -
WebServer : serving  /share/HDA_DATA/.qpkg/PlexMediaServer/Library/PlexConnect/assets/settings.js
192.168.0.2 - - [08/Jun/2013 12:32:50] "GET /settings.js HTTP/1.1" 200 -
WebServer : serving .xml: /library/sections/1/recentlyAdded?stack=1&X-Plex-Container-Start=0&X-Plex-Container-Size=25&PlexConnect=SectionPreview-artist
DNSServer : DNS request received!
DNSServer : Source: ('192.168.0.2', 57082)
DNSServer : Domain: itunes-cdn.apple.com.akadns.net
DNSServer : ***forward request
DNSServer : -> DNS response from higher level
192.168.0.2 - - [08/Jun/2013 12:32:51] "GET /library/sections/1/recentlyAdded?stack=1&X-Plex-Container-Start=0&X-Plex-Container-Size=25&PlexConnect=SectionPreview-artist HTTP/1.1" 200 -
DNSServer : DNS request received!
DNSServer : Source: ('192.168.0.2', 55611)
DNSServer : Domain: ax.init-cdn.itunes.apple.com.akadns.net
DNSServer : ***forward request
DNSServer : -> DNS response from higher level
WebServer : serving .xml: /library/sections/1
192.168.0.2 - - [08/Jun/2013 12:32:52] "GET /library/sections/1 HTTP/1.1" 200 -
WebServer : serving .xml: /library/sections/1/all

By the way, is 10.1.1.212 the IP in your aTV's DNS?

EDIT

I added a movie having an M4v filetype. I could play it when accessing via web. So I tried to access it using my aTV and finally I could see the thumbnail of the movie, but when there's this 'Trailer is unavailable' error when trying to play it.

I added Photo to my Sections. I can access the photos from aTV 3's Trailer. But when I try to access the Music section, it displays 'Trailer is unavailable'.

By the way, is 10.1.1.212 the IP in your aTV's DNS?

EDIT

I added a movie having an M4v filetype. I could play it when accessing via web. So I tried to access it using my aTV and finally I could see the thumbnail of the movie, but when there's this 'Trailer is unavailable' error when trying to play it.

If you press the play button rather than the middle select button does it play (i.e. you skip the pre play screen)?

This issue has been fixed i the latest source code.

Which play button do you mean?

Which play button do you mean?

On the ATV remote there is a play button (bottom right) and a select button (in middle of black circle).

If you select a movie or episode it brings you to a pre-play screen.

If you hit the play button when on a movie or episode it will skip the pre-play screen and immediately start playing.

On Elan's branch and some of the older main branch source code there is a bug in the pre-play screen that causes an issue like described.

It is very likely the bug that i described above - the instructions at the top link to Elan's branch.

There have been a lot of bug fixes and changes in the main branch since then!

Not too long before Elan's eye candy is merged back in ;)