Wow, this is awesome! Nice work Baa and roidy (and thanks to f00b4r for the heads up). Was out of this thread for a bit as I had to do take care of other projects (bills need to be paid and all), but I'm happy to take point on the XML parsing.
I haven't tried Baa's python Webserver, but roidy's node.js hack worked nicely for me. I can't be certain (because I don't remember if I installed node.js on my Plex box or not), but I do know that node.js is part of the Plex Web setup.. so I'm thinking that PMS is already running node on everyone's machines. Anyhow, that's not so important, you guys seem to have the DNS aspect covered... looks like all we need is to parse the Plex XML and spit out Apple TV XML.
f00b4r, if you do get any semblance of documentation on the Plex XML, that would be super useful. Otherwise, I'll just start plugging away at reverse engineering the schema.
f00b4r, if you do get any semblance of documentation on the Plex XML, that would be super useful. Otherwise, I'll just start plugging away at reverse engineering the schema.
I have an offer of help from "hippojay", the author of the PleXBMC plugin (the one that allows you to use XBMC to connect as a Plex client, including using the iOS client as a controller etc..).
He is willing to help with understanding the plex XML structures and other internals that he has picked up.
Does everyone think it is worth setting up a IRC channel, Trello board, github page etc.. or something to get this a bit more organised and prevent duplication of effort?
Does everyone think it is worth setting up a IRC channel, Trello board, github page etc.. or something to get this a bit more organised and prevent duplication of effort?
I definitely think a github page for roidy's ATVBrowser script would be good. I've already started adding to the code (getting node to parse plex's XML script using xml2js), but I don't have anything workable yet.
Does everyone think it is worth setting up a IRC channel, Trello board, github page etc.. or something to get this a bit more organised and prevent duplication of effort?
Yes... I think a github page would be worth it. I have never dealt with it, though - much less have a login so far.
My understanding is, that you need some kind of an administrator to review and publish the final code? Who is up to that task?
I have an offer of help from "hippojay", the author of the PleXBMC plugin (the one that allows you to use XBMC to connect as a Plex client, including using the iOS client as a controller etc..).
He is willing to help with understanding the plex XML structures and other internals that he has picked up.
That is great news! It can only help, can't it?
"hippojay" for sure is welcome... I already kind of X-rayed his PleXBMC to get some information about the plex interface.
I've invited another friend (who is not on these forums).
He's a web-app developer and has already begun work on writing an XML conversion between Plex and the Apple XML. Hopefully he'll join up and add some demo code to the glassboard.
I've since setup the nodejs and been successful running the code provided by Roidy.
My next thoughts (pending we can get the XML down, seems totally do-able) is how the heck are we going to get subtitles to work with this method? Seems like that may be impossible unless someone knows how to request a stream from the Plex XML service. I suppose then you could ask the transcoder to hard burn?
Two things preventing me from going the .js route:
- I don't know anything about .js - I might be able to read the code, but that is it. With python I have a lot more experience (about 4 weeks... :-)
- I didn't want to install yet another framework... Having node.js already available with Plex Media Manager definitively would solve this thought.
So - which route should we take from here?
I guess, the basic concept seems viable... now we need to decide how to go on!
I'm going to put my vote in for Node, for two reasons...
i) Plex Web is already built off of Node, integration would likely be easier in the long run (plus there appears to already be helper functions written to use the transcoder).
ii) Seems like there's already some packages in the Node.js packaged modules site related to Plex Media Server (https://npmjs.org/browse/keyword/plex) ... and here's the one where I smack myself on the forehead:
I've invited another friend (who is not on these forums).
He's a web-app developer and has already begun work on writing an XML conversion between Plex and the Apple XML. Hopefully he'll join up and add some demo code to the glassboard.
I've since setup the nodejs and been successful running the code provided by Roidy.
My next thoughts (pending we can get the XML down, seems totally do-able) is how the heck are we going to get subtitles to work with this method? Seems like that may be impossible unless someone knows how to request a stream from the Plex XML service. I suppose then you could ask the transcoder to hard burn?
Fun little project we have here.
Good news on more hands.
I guess the question is how do they get them working when you use Plex in a browser, would it not be the same method? The people who could answer that can probably also answer about the availability of js.node in the media server.
Does someone want to ask those questions in the Plex web forum (i would but i am not fully sure what i should be asking about)?
I guess the question is how do they get them working when you use Plex in a browser, would it not be the same method? The people who could answer that can probably also answer about the availability of js.node in the media server.
Does someone want to ask those questions in the Plex web forum (i would but i am not fully sure what i should be asking about)?
...and amazingly got a super fast response from ericmatthys:
1) Node.js is used a little in development, but not at all in production. The media server has an HTTP server that is used to serve up Plex/Web and everything from there is handled client-side.
2) Here's a Google doc with some documentation on the HTTP API.
So, it seems PMS is its own HTTP server, and Node isn't used in production. So, I suppose its up in the air whether to use Python/C/JS or whatever for this. I still like sticking with Node, as someone's already built a parser which works.
Javascript is closer to Java than C, imho.. but not too painful to learn.. very painful to debug, however :D
I would like to say that it's vice versa, as this family tree also shows. Also JavaScript was designed to be run by the browser, not as a backend server (compared to for example Java which works great as a backend language). Of course we have node.js now which changes this. JavaScript doesn't even have classes, it's prototype-based. Wikipedia explains it better, but what I'm saying is that don't compare Java and JavaScript as they don't have much in common.
Back to the topic. The DNS server could be easily done with BIND, it's simple to create a file for a certain domain and redirect requests to your own server. Of course now you got that working with node there's no need to do it yet another way. But you could do this all with BIND + Apache (or nginx etc.) + any programming language (for parsing the xml). Java has some great libraries for handling xml, but any language should be fine.
1) Today, I looked into javascript - just to know what we are talking about :-)
I kind of worked my way through "javascript in 10 minutes" by Spencer Tipping (https://github.com/spencertipping/js-in-ten-minutes). Okay, it took more than half an hour, but honestly: After that read, I have NO idea, why anybody would code in that language :wacko: .
2) I checked back at SpaceDog's linked thread, if there is any chance to hook directly into the PMS web server, like adding an additional interface (or plugin architecture) to supplement Plex, DLNA, whatever they already have there. Negative, at least for now - we got to set up an additional web server... :(
3) JSON - yet another description language? We have to translate from PMS-XML to aTV-XML. There are plenty of libraries (libxml2, lxml, ElementTree, ...). What could JSON help?
EDIT:
4) In case someone want to play a little with the PMS HTTP/XML side, here is a very small (thus "LilPlex") C command line app, that I started a while ago: http://www48.zippyshare.com/v/9757336/file.html
Basically you can request all those XML information and navigate through you Plex library - down to the point where it would throw out a weblink to replay a media file: just copy it into VLC or something.
Disclaimer: It works great in you local held media library, it might get into trouble for everything more special (like transcoding, channels, ...)
But it might give you some details about the PMS browsing.
I would like to say that it's vice versa, as this family tree also shows. Also JavaScript was designed to be run by the browser, not as a backend server (compared to for example Java which works great as a backend language). Of course we have node.js now which changes this. JavaScript doesn't even have classes, it's prototype-based. Wikipedia explains it better, but what I'm saying is that don't compare Java and JavaScript as they don't have much in common.
I was more referring to the syntax, but ya.. you're not wrong.
If someone wants to do a fork using BIND, please feel free. We've already got the working Node DNS from Roidy, so that's the route I'm going to spend my efforts on. The Plex/Web forum told me that Node is only used in development, and not in PMS, and if people don't want to install more libs on their machine, I get that. Me however, I want to get this happening so I can retire using my iOS app to do AirPlay and use my remote.. I'm lazy that way :)
As my Javascript is stronger than my C, for me Node is the logical option, however, if someone else is strong is C, Python or whatever and want to go that route, I say right on! The general design methodology will likely be the same regardless of what language we're using, so I'm sure there'll still be some very useful information sharing.
3) JSON - yet another description language? We have to translate from PMS-XML to aTV-XML. There are plenty of libraries (libxml2, lxml, ElementTree, ...). What could JSON help?
For any sort of parsing/XML conversion, we're going to need an object (array, dictionary, what-have-you). JSON plays nice with JS (and Node).
My next thoughts (pending we can get the XML down, seems totally do-able) is how the heck are we going to get subtitles to work with this method? Seems like that may be impossible unless someone knows how to request a stream from the Plex XML service. I suppose then you could ask the transcoder to hard burn?
Fun little project we have here.
I've been thinking about the transcoder too, since its going to rear its head soon. It seems to me the best route would be to try and find some info on the Plex/Web transcoder, because it does use M3U playlists for mobile devices (I did check that). I don't recall off the top of my head if Plex/Web does subtitles though. In any case, it should be looked into.