New hack: running the PlexConnect python script on your jailbroken ATV2

For those of you running ATV2 devices with a jailbreak you now have another, currently unsupported but tested as working, option open to you.

 

  1. Grab this file: https://yangapp.googlecode.com/files/python_2.7.3-3_iphoneos-arm.deb
  2. Transfer it to your ATV2
  3. SSH into your ATV2
  4. Install using: dpkg -i python_2.7.3-3_iphoneos-arm.deb
  5. Run PlexConnect (remember you do not need sudo as you are already logged in as root)

The  ATV2's host file could probably be altered so that you could disable the PlexConnect DNS server component but i have not really played around with it too much.

It does however open up more possibilities for a very portable media centre when daemon code and MyPlex support is added (you could take it anywhere and access your content, shared or otherwise).

 

Have a play about and provide some feedback if you want :D

 

What address do you set the Apple TV's DNS field to? 127.0.0.1?

And how much hard drive space will this consume on an Apple TV because I assume it needs to install Python, as well?

For those of you running ATV2 devices with a jailbreak you now have another, currently unsupported but tested as working, option open to you.

  1. Grab this file: https://yangapp.googlecode.com/files/python_2.7.3-3_iphoneos-arm.deb
  2. Transfer it to your ATV2
  3. SSH into your ATV2
  4. Install using: dpkg -i python_2.7.3-3_iphoneos-arm.deb
  5. Run PlexConnect (remember you do not need sudo as you are already logged in as root)

The  ATV2's host file could probably be altered so that you could disable the PlexConnect DNS server component but i have not really played around with it too much.

It does however open up more possibilities for a very portable media centre when daemon code and MyPlex support is added (you could take it anywhere and access your content, shared or otherwise).

Have a play about and provide some feedback if you want :D

I set the ATV's DNS to the IP of the ATV, although 127.0.0.1 will probably work as well.

It also works if you disable the PlexConnect DNS server and edit the ATV's host file to point trailers.apple.com to the IP of your PMS.

After further though though you should be careful with the host file route if you plan to ever move the ATV from your home network (using the PlexConnect DNS server will probably work as a portable solution when MyPlex is up and running).

Hard drive space should not be an issue.

Okay, cool. I'm going to try this out. Two more questions, though. To start it, you just ssh in and type "PlexConnect.py" but how do you stop it running? And how do you uninstall it? Can I just delete the .deb file and PlexConnect folder or does it install stuff all over the place?

I set the ATV's DNS to the IP of the ATV, although 127.0.0.1 will probably work as well.

It also works if you disable the PlexConnect DNS server and edit the ATV's host file to point trailers.apple.com to the IP of your PMS.

After further though though you should be careful with the host file route if you plan to ever move the ATV from your home network (using the PlexConnect DNS server will probably work as a portable solution when MyPlex is up and running).

Hard drive space should not be an issue.

stopping would be .

uninstalling "rm -rf " or something.

I guess currently the issue with the "very portable media centre" is, that you need another computer to ssh into the aTV to activate that code. This is where the daemon comes into play...

EDIT: the shutdown might not work with . you might need ... 

Thanks for clarifying. 

I see that it installs Python, so that would remain behind unless there is a uninstall python script included which I didn't see when I unpacked the .deb file. But I guess it doesn't hurt to have it installed and I can just restore the Apple TV and then jailbreak it again if something goes wrong.

stopping would be .

uninstalling "rm -rf " or something.

I guess currently the issue with the "very portable media centre" is, that you need another computer to ssh into the aTV to activate that code. This is where the daemon comes into play...

This hack is very much for playing around at the moment, it will be much more useful when run as a daemon is part of the code.

There is info on how to modify the code to do this and use launchctl in the forum but obviously we cannot support that.

I ran into errors during installation:

Apple-TV:/private/var/mobile root# dpkg -i python_2.7.3-3_iphoneos-arm.deb

Selecting previously deselected package python.

(Reading database … 1745 files and directories currently installed.)

Unpacking python (from python_2.7.3-3_iphoneos-arm.deb) …

dpkg: dependency problems prevent configuration of python:

python depends on libffi; however:

Package libffi is not installed.

python depends on sqlite3; however:

Package sqlite3 is not installed.

dpkg: error processing python (–install):

dependency problems - leaving unconfigured

Errors were encountered while processing:

python

Hmm I did originally install an earlier version of python via “apt-get install python” but that caused PlexConnect to error.

Roidy found that later package which I installed over the top.

I ran into errors during installation:
 

apt-get install sqlite3, then try the install again.

I'm able to get in running, and I changed my hosts file by adding

trailers.apple.com      
the trailers app still opens up normally.  Has anyone got this working?

Yes, did you flush the DNS cache on the ATV?

I can write a launchctl script when I have some time.  If someone is feeling adventurous, you can read up on it here http://n8henrie.com/2012/07/scheduling-ios-apps/.  

thanks for the quick reply!  I don't know how to flush the cache.  When I get home, I'll try restarting it and trying it again.  Do you know of another way?

It is the same command as OSX but you may want to check the kernel version as I cannot remember if it is in sync with 10.8 or earlier.

Alternatively you can pull the plug.

Btw we should have a proper daemon code option in the released code soon, which will make it much easier to run on the ATV2.

plist in /System/Library/LaunchDaemons/
the file needs to have the string property appended with .plist as per the XML property list keys
 

XML PROPERTY LIST KEYS 
The following keys can be used to describe the configuration details of your daemon or agent.  Property	 lists are Apple's standard configuration file format. Please see plist(5) for more information. Please note: property list files are expected to have their name end in ".plist".  Also please note that it is the expected convention for launchd property list files to be named .plist.  Thus, if your job label is "com.apple.sshd", your plist file should be named "com.apple.sshd.plist".


change "var/root/PlexConnect/PlexConnect.py" to be where you installed it, in my case, in the home directory for root.

<?xml version="1.0" encoding="UTF-8"?>



  Label
  --RENAME THIS TO YOUR FILENAME MINUS .plist--
  ProgramArguments
  
  /usr/bin/python
  /var/root/PlexConnect/PlexConnect.py
  
  RunAtLoad
  


Can we bring this topic back up now that we have the daemon code and myplex incorporated. I would like to install this on a jailbroken ATV2 used at a remote location. I would like plex connect to run at startup on the Apple TV so the trailers app could be used to access my plex. I could also go down the method of installing an app using the add site method but it looks like both methods have kind of died out.


It’s late tonight but I am gonna try too get all this working tomorrow. Is anybody currently using only their Apple TV to run plexconnect?

The auto start stuff for OSX and then likely iOS should be sorted in the next few days, including a script to run that will automatically do all the launchctl stuff for you :wink:
I will test it when done.

The auto start stuff for OSX and then likely iOS should be sorted in the next few days, including a script to run that will automatically do all the launchctl stuff for you ;)
I will test it when done.

Awesome.  Any luck with this?  Are you creating a script that will create a plist file and put all the stuff in the right places?  Just curious how you are attacking this?

I had a play about with this at the weekend but ran out of time (got slowed down by SSH connectivity getting screwed up by NitoTV updates - found a fix though).
There is a pull request on GitHub that is being tidied up at the moment, essentially:

- it gets the Linux daemon code working on OSX by performing an OS detection; if it finds it to be OSX (or iOS I believe, as they share the Darwin kernel) then it waits for the network interfaces to be active before starting the daemon (this is what prevented it from working at boot previously).
- it also come with a plist and script that yo can run which will check for certs, generate them if needed and setup PlexConnect to launch as a daemon at boot (no need for an admin password and the daemon will auto restart itself if it crashes)
- the auto install script needed a little tweaking (see GitHub) but does work :slight_smile:

Hopefully this works on iOS without tweaking and combined with the add site hack (enabling you to disable the PlexConnect DNS server) makes a nice portable media player for this with jail broken ATV devices.
I was getting issues getting it to auto restart on boot but I will continue to have a play with it :slight_smile:

Thanks.  Yea after I posted last night I messed around and got it working.  Then this morning I worked on autostart and used the same plist I am using for Mac from the gituhub commit from dlmarston.  I just copied that over and it seems to work just fine using the daemon.bash.  I do however have a time.sleep(10) built into plexconnect.py on my mac and now atv until the bugs are worked out with the startup network detection.

Please let me know if you guys come up with a better way but for now All I have to do is change the dns ip to the ip address that is pulled from any dhcp router and it will automatically work.  Pretty cool.  Next to play around with addsite.

Well it seems there is a crash happening about every 60 seconds when watching a movie this way.  I am not sure where to check logs on this.