Tuesday, October 14, 2008

Apple TV / Boxee / TV Shows Integration

So this past week I have been messing around with Boxee for the Apple TV. Boxee is a media center application that is based on the XBMC (Xbox Media Center) that has been ported to other OS's (Windows/Mac). While the XBMC has been ported to them as well, Boxee has some Social Networking integration that I find rather interesting...

Anyway, I installed this software on my Apple TV because, well, it looked cool and I was tired of trying to get my Apple TV to talk to my network, and this seemed like a good solution to my issue

Little did I know that this would open up a whole new avenue for playing videos :)

After waiting ever-so-patiently (almost to the point of forgetting about it) I received by alpha (oh, I forgot to mention it Boxee is in the alpha stages... very extreme alpha) invitation to Boxee...

While you don't need the invitation to install the software, it gives you a login to use to social networking side of the program.

So I installed it on my Apple TV using the atvusb-creator (found here), which is a really nifty app if you want to install ssh (which if you don't have, shame on you) or some bin stuff that you need if you're working on the Apple TV (no keyboard support remember?)

In order to get this working, you need to do the following steps:
  1. Insert a “bootable” USB drive into your Mac
  2. Run the ATVUSB-Creator and select which plug-ins you’d like to install
  3. Remove the USB drive and plug it into your Apple TV
  4. Power on your Apple TV and the patchstick will run the ATV bootloader
  5. After the bootloader finishes, remove it and restart your Apple TV
  6. It now has options for Boxee / XBMC on the main menu
  7. Click on Boxee, then select update (this will download boxee from the Internet)
  8. Once boxee is done installing, restart your Apple TV
  9. click “Boxee”, then select “Boxee” in the sub-menu to start boxee.
So after completing the steps outlined above, and you've received and setup your alpha account, you get this:


Which is ever so cool, heh, sorry, I'm really big on interfaces and I'm kinda down with this one.

So... after fiddling around with this for a while, setting up my SMB share on my desktop (which was made much easier by Boxee) and watching a few episodes of Stargate to test out how it works I started to look a bit closer at what we have here.

And to my surprise, I found the following:


And what do we have here you ask? Only the most awesome aspect of Boxee that I've seen yet... torrent integration!

After a little digging I found that Boxee integrated rtorrent into it's media center app. rtorrent is a command line bittorrent client written in C++. After reading a bit more into Boxee I found that it watches a directory for torrent files, and when you place on there, it automatically starts downloading it, with a bunch of nifty little settings like setting the up/down speed, max/min number of peers as well as port ranging, so if you have more than one torrent going on different computers it doesn't freak out :)

So, after finding said feature, I decided to test it out by throwing a few torrents that I have on my laptop into the directory (/Users/frontrow/Library/Application Support/BOXEE/UserData/Torrents/) to see how well it works, and I have to say, I'm pretty impressed, after a few hours of downloading, I have a nice little library built up:


The other awesome thing I found out about this is that when a new video is added to the library, Boxee will go out and find the relevant information for the show/movie as well as the synopsis for an episode (with a cool feature to hide said synopsis if you haven't watched the show yet).

So after thinking about this for a while, I realized that this would be a great feature if I could somehow integrate my TV Shows application with Boxee. TV Shows is a Mac program that lets you subscribe to a show and it will go out to the intertubes that look for new episodes of shows that you are subscribed to:


As you can see, I've built quite a subscription to shows...

So, you may be asking yourself at this point, doesn't this guy have a DVR that can record his shows for him?

Well, yes of course I do, but sometimes I want to watch something without having to fast forward through commercial, or maybe my dvr freaks out and doesn't record an episode. So this is really handy because I work nights and am usually not home to watch TV anyway.

So, after thinking about it for a few hours, I decided that the best thing would be to figure out a way to have my mac automatically move any new torrents that TV Shows downloads into the directory for Boxee to download for me.

This is where my new friend Python comes in. After fiddling around with it for a while, I wrote a nice little script to move any new torrents that TV Shows gets into a mounted SMB share from the Apple TV. So I came up with the following:

#! /usr/bin/env python

import os
import array
import pickle
import shutil

os.chdir('/Users/mike/Movies')

for i in os.listdir(os.getcwd()):
if '.torrent' in i:
shutil.move(i, '/Volumes/frontrow/Library/Application Support/BOXEE/UserData/Torrents/')
Pretty nifty huh? Well, after a bit of testing I realized that I wanted a bit more functionality
built into this. After some searching, I found that most UNIX systems have a built in sendmail application, totally sweet!

So, after a bit more testing, adding a few lines here and there, I came up with the following:

#! /usr/bin/env python

import os
import array
import pickle
import shutil
import time

MAIL = "/usr/sbin/sendmail"

count = 0

mssg = 'To: youremail@example.com \n' \
+ 'From: MikesTorrentBot\n' \
+ 'Subject: New Torrents Added to AppleTV on ' \
+ str(time.strftime('%x')) + ' at ' + str(time.strftime('%X')) + '\n\n' \
+ 'The following torrents were added the the appletv:\n\n'

os.chdir('/Users/mike/Movies')

for i in os.listdir(os.getcwd()):
if '.torrent' in i:
shutil.move(i, '/Volumes/frontrow/Library/Application Support/BOXEE/UserData/Torrents/')
mssg += i + '\n'

if '.torrent' in mssg:
p = os.popen("%s -t" % MAIL, 'w')
p.write(mssg)
exitcode = p.close()
if exitcode:
print "Exit code: %s" % exitcode

Basically what this little script does is scrape the /Users/mike/Movies directory (this is where TV Shows drops new torrents when it finds them) and if it finds one then it will move the torrent into the mounted SMB share and send me an email with the date and time telling me what torrent it moved.

So this is all well and good, but this isn't going to accomplish anything without me running it every 15/30 minutes, and I'm not home when I need this to run, so I need to find a way to have this run without me there.

My first instinct would be to setup a cron job to do this, which I did, because, well, that's how I roll :p But this got me thinking, how does TV Shows run every half hour without being a cron job? So I did some digging and stumbled upon launchd which is a daemon that takes over for cron on macs. After looking over the launchd entires, I found that this is where TV Shows runs every half hour. So I create a little plist file to run my script every 15 minutes:

[~]$> cat /Users/mike/Library/LaunchAgents/net.mike.robotorrent.plist
"



Disabled

Label
net.mike.robotorrent
ProgramArguments

/Users/mike/Movies/torrent

RunAtLoad

StandardErrorPath
/Users/mike/Desktop/Robotorrent.log
StartCalendarInterval

Minute
25

StartInterval
900

"

I placed this plist file in /Users/mike/LaunchAgents/ and ran the following command to load the plist into launchd:
launchctl load /Users/mike/LaunchAgents/net.mike.robotorrent.plist

Once you run this command it'll load the plist and run the command specified in the Program Arguments key at the interval defined in StartInterval. It will start the interval at the minutes specified in StartCalendarInterval - Minutes. It'll also write an error log into a file on my desktop so I can come and check it when I get home in the evening to see if there were any errors in the script.

So once I loaded this into launchd I sat back and waited to see if this thing would work like it's supposed to, and lo and behold, TV Shows downloaded a new torrent, my script kicked off at the specified time and sent me an email letting me know that it added the new torrent to the directory on the Apple TV. I then switched to the Apple TV and found that it was already downloading the new show.

Totally killer

So I know this post isn't very instructive in the way of trying to do this, since it very macish and most of the people I know don't have mac, but I thought it was cool.

The next step for my script is to pretty much kill the TV Shows daemon and write a wrapper for it into my script so I don't have to wait for it to run to run my script. Initially, I was going to port the TV Shows script to python and integrating it that way, but since I'm reluctant to learn Ruby (which is what the core of TV Shows is written in) I decided that it would be easier to just write a wrapper.

The same goes for the mounted SMB share on my mac, I'm going to modify the script to see if the share is mounted, and if it isn't, it will go ahead and mount it and continue on.

Well, I think that's enough for now, so in the words of my coworker:

Happy Hacking!

Oh yeah, and I forgot... Clay's Mom :p

Had to put that in there :)

Monday, September 15, 2008

Yikes...

Well, it's been quite a while since my last update, so I think we're going to make this a two-fer :p

Time:

A discuss between me and Clay got me thinking about this subject

It all started when I made a comment to @MarsRover on Twitter when it was discussing a sol (a Martian day). A sol is 24 Hours 39 Minutes and 35Seconds. However, this is based on Earth time, which is 1.58 Maritan Seconds per Earth Second.

Now this got me thinking about the nature of time itself. The way that I see it, time doesn't exist, at least in the standard concept of the idea. We as humans see time as flowing, like traveling down a river in one direction, never stopping, not being able to go back.

The way that I envision time, is that it is static, unmoving, constant. The general consensus of time is that it is a dimension that exists within our own, meaning that there are three spatial dimensions and a fourth dimension of time that exists within these three dimensions. For the purposes of this argument we'll forgo the in-depth discussion on the tesseract and the actual dimensional construct of our known universe... we'll save that for later :p

So you have three spatial dimensions, which are unmoving, obviously, because they are the world in which we see, and then you have the fourth temporal dimension, which is also unmoving, so you may be asking yourself, how does time move?

Now this is the crux of my argument, the actual passing of time itself. This does not exist, at all. Time does not flow, it does not move, it's static, like the three dimensions that we occupy. The reason that we see time as moving is because of the construct of our human mind which deals with the passing of one moment to another. Crazy, no?

Time as a moving object, does not exist, it exists as a static, constant part of our known universe. Which is how I see our universe, never moving, just static, moments don't pass, we just think that they do because of the way that we evolved.

Ok, I think that's enough on that subject, now we are going to move onto the second subject, which I think is going to cause a lot of controversy amount my readers, well, if I have any that is :p

Faith/Religion

OK, now I that this is big no-no to discuss on these here interwebs, but I've been thinking a lot about this lately and there are a few things that I want to get off my mind and I think you should hear it.

Now, for the longest time, I've been Catholic, well, ever since I was born, but at this point in my life, I really don't see myself as Catholic anymore. This isn't to say that I don't believe in a high being or anything like that, just that my idea of faith is radically different than anything that's currently out there.

I am first and foremost a man of science, I've always been, since my misspent days as a youth where I would enjoy reading about science and mathematics. I've always put a large quantity of trust in science and math, mainly because it's something that verifiable, that you can prove. Now that's not saying that I don't have a faith in any sort, but at this point, I consider myself a deist, that is, I do believe in something, but it's not anything that is currently offered in any sort of organized religion.

Even in my set of beliefs were covered in any sort of organized religion, I don't think that I would want to be a part of it. Why, you may be asking? Well, because I don't put any stock in them, no matter what they are. This is mainly because I don't believe that you should construct a belief system around a certain faith, which is where I think most religions get it wrong.

And I'm not saying that they're wrong, it's not in my nature to do that, nor is it my right to tell someone that I think they're system of beliefs is wrong, who am I to question that? I can't, no can any of you out there, and you know why? Because I dare you to use any argument about how one religion is wrong and your's is right that cannot be used in reverse.

No at some point in this reading, I'm sure that you've asked yourself: "Since this guy isn't Catholic, then he must be amoral, or at least with some sort of skewed morality" That, my friends, is most certainly not the case.

I live my life by a specific set of rules, that I have defined myself, what I saw in my journeys and dealings with the rest of humanity. I define what I do, how I act and what I feel by what I believe is right, which is the complete opposite (at least from what I gather) what any organized religion teaches. This is my main disagreement with organized religion. I have a problem with any system of beliefs that tells you how to act, with some sort of punishment in the afterlife if you disobey. I believe that we, as human beings, have this incredible gift of free will, that we can make our life whatever we want of it, we can choose to do immense good, or do incredible evil, we have that choice, and nothing, no religion, no group of people can tell you otherwise, you have that choice, and no one can take that way from you.

Heh, well, that certainly went on longer that I anticipated :p

Ok, so in closing, I would like to propose a riddle to all my readers out there:

Let's say you have 7 metallic balls, and a set of scales, meaning those scales on lady justice that we see so prevalently in the halls of justice :p In this set of 7 balls, one weighs more that the other 6. Using only two weighings, how do you determine that which ball is heavier than the rest?

If you can answer this question, maybe you should be a programmer :p Or at the very least, you're quite good at problem solving

Btw, this question was posed by one of my coworkers while we were discussing interview tactics, which, the question posed above, is not allowed to be asked, according to state law.

If you like to know the answer, shoot me an email at salazarmike at gmail dot com

That's all for now kids, till next time

Wednesday, August 27, 2008

Heh... well, apparently not

I intended for this blog to be updated daily, but apparently I'm a bit of a slacker.  Well not really, I've just been busy...

So anyway, in my busy type-schedule for the past couple of days, I've thought about a few things
While I do so enjoy the idea of a personal blog that pretty much just deal with my life, I do believe that people would find it incredibly boring and mundane, which, as it turns out, my life is...

I'm not bashing on myself, but my life is pretty routine, nothing really exciting happens, so I think we'll just go with the flow...

Meaning that whatever I might think would be blog worthy, I'm going to include it here.
For instance, I was thinking the other night, cause, well, that's pretty much when I have the most time on my hands, about the fact that which I think the idea of an arc reactor in Iron Man would be a giant leap forward in terms of power generation, to me, that seems highly unlikely, bear with me a moment.

Firstly, we see in the movie (which I've seen more than once obviously) we see our hero Tony Stark building an arc reactor in a cave somewhere presumably in the Middle East, unlikely, but we'll go with it for now

So the first component that we see in this reactor is palladium.  Now, if you're anything like me, which I certainly hope that you aren't :p, I've heard of palladium in one other use that wasn't quite so widely accepted... and that would be cold fusion.

Our good friends Fleischman and Pons who back in the 80s apparently discovered cold fusion using an electrolytic cell and some heavy water..

Anyway, back to my issue.  So we have the palladium, in some sort of ring configuration and some scraps from missiles that he tore apart for, well, parts.

Now my biggest problem with this miniature arc reactor that it has to apparently power source, I mean, there's nothing that appears to make the thing work, at least not that I can tell.  It appears as though towards the end of the build process he used the battery to kick start the thing, but you can't just pull energy out of thin air...

Well, there is zero point energy, but that's another story for another blog...

So here we have this thing, that doesn't use any typically type of fuel for power generation, that is efficient and safe for use pretty much inside a human being, that discharges some sort of plasmic goo into the cavity...

Do you see where I'm going here people?

Which I think it's a novel idea, I think they could have lent themselves to a little real world physics to make it seem believe, to me at least :p

Ok, well, that's pretty much all I have for today..

Till next time

Sunday, August 24, 2008

So Here It Is

Well, for the past few days I've been having this undeniable urge to write. Not that I'm very creative, or, you know eloquent in any sense of the word, but I thought that I should start writing...

So here it is...

I think that this blog may be an account of my life, as it is. I know that may sound boring to some, but I think that it would also help me in some sense to remember anything that I may have regrettably forget over the past few days..

But who knows, it might be slightly humorous...

Maybe not :p

So here I am, sitting in my apartment at 3:35 in the morning, watching Clerks II and my nose will not stop running. I think this is the first time that I've gotten sick, actually sick this year, which is pretty much on par with my life. When I get it, it basically feels like a cold, lasts about a day and then I'm fine... weird no?

But anyway, I digress...

Let's see, what else should I talk about...

Oh, work

Well, for the most part, it was pretty much on par with any other Saturday that I've worked since I've been there, which mainly means quiet, really quiet. Which was a really good change as I wasn't feeling too hot and I couldn't justify calling someone in because, well, 1) I'm not contagious, and even so, it's just me an Clay on Saturdays and b) I don't want to ruin anyone's weekend.. well, maybe Steve's :p just kidding...

So I spent a good part of the day putting together my zombie G5 mac that I've collected from parts off of the eBays. I got most of them requisite that I thought I would need... I did however, neglect to buy the set of fans that are needed, which kind of sucked because it would even boot :/

Oh well, back to the eBays to find the parts I need.

We also watched a lot of Eureka today, mainly because that's how we roll on Saturdays. After watching the rest of the Season 1 and some of 2, I finally got some of the questions that I had regarding Season 3 answered, because apparently I've been a bad fan and missed a whole season.

What else... what else... I think that pretty much sums up my Saturday, I've been fighting this cold all day long, and I realize that smoking while I'm sick isn't the smartest idea in the world, but hey, it happens. We had our usual Sarovar for dinner, which, as always, was freakin' awesome..

I think that's pretty good for now, stay tuned for more updates to come..