Plex @ aTV - think different...

So after hours of wading through chinese forums using a very poor google translation :) I finally found this:-

http://translate.google.com/translate?sl=zh-CN&tl=en&js=n&prev=_t&hl=en&ie=UTF-8&eotf=1&u=http%3A%2F%2Fbbs.weiphone.com%2Fread-htm-tid-5128270.html

This guy gives instruction on how to setup a node.js dns and web server, he includes all the source files. However I've been trying for the past couple of hours and I can't get it to work at all :( I set it up just like the instructions say but every time I select Trailers on the ATV I get the message "Trailers is unavailable. Try again later."

If anyone wants to try this then be aware you'll need to 1) register an account on the forum to download the files and 2) change the IP_DNS value in the file utils.js to mach the DNS server that your ISP gives you. For exampe I needed to change it to:-

const IP_DNS = "194.168.4.100"



The DNS part seems to work, store requests get passed through and trailer requests get trapped and sent to the local webserver. However the webserver part doesn't seem to work. Needs someone smarter than me to take a look at it ;)

Do we have any Cantonese/Mandarin (i guess we do not know which it is) speakers who are technical and could check the electronic translation above? 

>> This is where things get weird each time I enter and exit the Trailer app I get a different request. These are the first 3 I got:

Hm... if the apple app won't work, have you tried what the network traffic of youtube/vimeo is like? With an fixed/official API they should have a fixed address, shouldn't they? This might make things less complicated :-)

I’ve now got it working perfectly, seems there was some errors in the code posted on that Chinese forum, weather Apple broke it with a firmware upgrade or the code was just wrong, I don’t know, but I had to rewrite the application.js file, but now it works, I’m able to get the trailer app to display my own XML pages and play video from my local server. The node.js DNS server that guy on the forum wrote seems to be Windows only, looking at the code, it seems to be missing the code to return an IP address on both Mac and Linux. However both routines could be easily added.

I've now got it working perfectly, seems there was some errors in the code posted on that Chinese forum, weather Apple broke it with a firmware upgrade or the code was just wrong, I don't know, but I had to rewrite the application.js file, but now it works, I'm able to get the trailer app to display my own XML pages and play video from my local server. The node.js DNS server that guy on the forum wrote seems to be Windows only, looking at the code, it seems to be missing the code to return an IP address on both Mac and Linux. However both routines could be easily added.

Great start. Mind sharing the code?

Now we need an XML translation between PMS and the Apple formatted XML. 
 

Not at all, I'll just tidy the code up a bit and try and get the DNS server running on Mac, then I'll post it.

Nice work, it will be interesting to see what this looks like. Let me know if you want any testing done.

I see from your DNS server you are in the UK as well :slight_smile:

I see from your DNS server you are in the UK as well :)

 Yep, sure am, good old blighty. As I said I'm just gonna clean up the code and throw together some example xml pages, then I'll post it, I've now got it working on both Windows and Mac.

Hey guys, just wanted to say that it's really great to see some activity here! Very curious to find out what this little project might turn into...

Old outdated instructions, DO NOT USE!

New code and instructions:- https://github.com/iBaa/PlexConnect Use the XML_Template branch.

 

Ok so heres the files:- http://www69.zippyshare.com/v/34170150/file.html
 

ATVBrowser - An ATV2/3 trailer app hack.

CREDITS:-
I take no credit for writing the DNS Proxy and Web server code, that was written by a guy/gal on the Weiphone BBS by the username of lionphone. I just modified the code to work for me. This is the original forum post:- http://bbs.weiphone.com/read-htm-tid-5128270.html

DISCLAIMER:-
Standard disclaimer here, by using this code/source package you do so at your own risk. If you lose data, your computer melts, your house blows up or your current planet of residents is destroyed I take no responsibility. Basically don't blame me if anything goes wrong :)


INSTRUCTIONS:-

1. Download the ATVBrowser zip file from the above link.

2. Windows:- Unzip the package to any location you like, just keep the directory structure intact.
2. Mac:- Unzip the package to your Home folder, keep the directory structure intact.
  
3. You need two pieces of information, the IP address of the computer your running the DNS Proxy and Web server on and the DNS address of your ISP.

4. Open up the following file /ATVBrowser/atv.js and change the IP address on the second line to the IP address of your computer.

5. Open up the following file /ATVBrowser/utils.js and change the IP address on the second line to the IP address of your ISP's DNS.

6. You will need any m4v video file that will play on the ATV, it can be a iTunes store purchased file with DRM if you like.

7. Rename the video file to test.m4v and copy it into the /ATVBrowser/assets directory.

Now we need to install Node.js

1. Goto www.nodejs.org/download

2. Windows:- Download and run the Windows Installer(.msi). VERY IMPORTANT!!! You need the full Windows installer and you need to reboot your computer for your PATH variable to be updated.
2. Mac:- Download and install the Mac OSX Installer(.pkg) Universal package. VERY IMPORTANT!!! You need the full installer and not just the binaries.
  
Running it all

Windows:-
1. Open a command prompt and cd into the ATVBrowser directory.
2. Type:- node atv.js then press enter.
3. If all goes well you'll get a message saying the DNS Proxy and Web server are running.

Mac:-
1. Open Terminal. The terminal should start up in your home directory.
2. Type:- cd ATVBrowser followed by enter.
3. Type:- sudo node atv.js followed by enter. You'll need to enter your user password. VERY IMPORTANT!!! You need to use sudo.
4. If all goes well you'll get a message saying the DNS Proxy and Web server are running.

Now goto Setting/General/Network on your ATV and change the DNS address to the IP address of your computer, the one you entered into atv.js.
Browse over to the Trailer app on the ATV and have fun.

Just don't forget that when you've finished playing around you'll need to set you ATV's DNS back to automatic :)

******* Updated Instructions for installing node.js on Windows *******

Old outdated instructions, DO NOT USE!
 

Awesome, I will try this out tomorrow morning.

The original hack required the location in the ATV preferences to be set to ‘United States’, is this still the case and if so do you think it will be easy to alter this for other countries?

No, my ATV remained set to the UK store and it worked fine.

There is only one trailer site which is in the US, and thats why you always get the same trailer results regardless of which countries store you have selected. Once you download the files you'll see that the application.js file, which is the main entry point for the trailer app, is located in a directory called /appletv/us/js. This resolves to a full web address of trailers.apple.com/appletv/us/js/application.js and is always the same regardless of store country, only now were running a local copy of it from a local web server.

I've made some minor changes to the installation instructions and uploaded a new zip file with an updated readme.txt file, if you've already downloaded the old zip file then please redownload the new one.

Could you possibly post a video, or pictures to see what this looks like? I’m really interested in this, but after reading through the thread I’m having a hard time with what the end result really looks like once you go into trailers.

Could you possibly post a video, or pictures to see what this looks like? I'm really interested in this, but after reading through the thread I'm having a hard time with what the end result really looks like once you go into trailers.

If you go to the link in post #21, theres pics of the interface on the bottom of the first post (looks pretty cool):

http://forums.plexapp.com/index.php/topic/57831-plex-atv-think-different/page-2#entry376800

I wonder if we could put m3u8 links on the page and have the Apple TV play it?

Ok so heres the files:- http://www69.zippyshare.com/v/34170150/file.html
 

[...]

Great instructions... I will have to check it out myself.

Thanks for your work in bringing the information together and helping to understand the technique.

I do have a couple of C files and a version in Python (more or less copied from hippojay's PleXBMC plugin) to grab PMS's XMLs from the command line. I guess I have to clean up that code and we have to come up with some glue code between a web server and those routines...

do1mjp.jpg1462b5.jpg29cl79j.jpg10h7py1.jpg2aakhhi.jpg

Here's some images showing it in action, please bear in mind this is just a demo using hand generated xml files. Any full browser would need to generate these xml files from your Plex library, which I'm afraid is beyond me :( I'll leave that up to somebody with a greater knowledge of both Plex and xml.

Hmm i could not get this to work but it looks really promising.

It would redirect the other applications correctly, including jailbreak ones such as the weather app, but i get trailers unavailable every time i select it; it may well be something i am doing but i didn't have time to troubleshoot it (tested on 5.0.2).

OK, I've found the problem, it seems that on 5.0.2 firmware the trailer app looks for application.js in a different location, thats easily fixed. But it also seems that the top menu bar is coded differently, thats harder to fix. In the mean time I've removed the top menu bar and reuploaded the zip package:-

http://www17.zippyshare.com/v/84254696/file.html

Delete the entire ATVBrowser directory and all it's contents and use the new one, I've uploaded. Let me know how it goes, by the way are you using it on Windows or Mac?
 

Roidy,

Are you familiar with the XML view of your plex server? 

Point your browser to :32400/library/sections


Honestly at this point we'd just need someone to write a server-side .js and have node call it - to parse the Plex XML into the Apple XML every time the AppleTV requests the trailers site. 

*edit* https://github.com/Leonidas-from-XIV/node-xml2js <- This looks promising - turns XML into a JS object. 

Found it here: http://blog.nodejitsu.com/6-must-have-nodejs-modules

I'm too new to nodejs and js in general to pull this off right now though.

Anyway, the coding seems straight forward enough. 

This sort of thing would work right out of the box on an unjailbroken ATV. Given the ability to Jailbreak, I suspect that it's entirely possible to change the icon for and rename the stock Trailers app. 

OK, quick update, I've dug out my ATV2 and jailbroke it with 5.0.2 and d'oh! the reason the top menu bar dosen't work is because it's not even supported in the 5.0.2 trailer app at all :) Seems it was only added to the trailer app in newer firmwares. Oh well no big problem, it looks nicer, but you don't really have to use it.

Are you familiar with the XML view of your plex server?  

To be honest I don't use Plex all that much, as I mainly use an ATV3. I have my own reasons for wanting to display content on the trailer app. This just happened to be the only place I could find information and other people trying to make it happen. Now we have the ability to hack the trailer app and display custom content I'll leave it up to someone more knowledgeable in the innerworkings of Plex to figure out the rest.