busted

Whoops! We got a DMCA notice at work today from our ISP, and I’m to blame. It was an accident, honest! I had (allegedly!) been downloading episode five of The Wire’s current season and neglected to shut off my Bittorrent app before leaving home. Apparently HBO took notice and didn’t take kindly to it.

First: I’m currently an HBO subscriber, so I’m feeling pretty karmically okay about all of this.

Second: I may have been downloading a bunch of other season 6 eps at the same time (I had a plane ride ahead of me and catching up to do!) but HBO apparently only noticed the torrent for episode 5 — a lousy torrent made from an HBO screener DVD, incidentally, with horribly clipping audio throughout. It wasn’t even the good stuff! It makes me wonder if they’re particularly sensitive to leaked screeners.

Third: although I’m being flip, this is still an embarrassing and stupid mistake. The last thing I want to do was expose the company to liability so that I can timeshift my preferred crime dramas. The odds of dire consequences arising from this particular incident seem to be fairly nonexistent, but it’s certainly something I want to avoid in the future. Having no faith in myself, I turn to technology.

OS X maintains an app called Kicker that does various things when network events occur — things like changing wifi access points. It also has an XML configuration file you can modify that’ll allow you to run your own scripts. Scripts like this one:

#!/bin/sh
#get the ssid of the network
ssid=`ioreg -l -n AirPortDriver | grep APCurrentSSID | sed 's/^.*= "\(.*\)".*$/\1/; s/ /_/g'`
#fill in your own values for ssid and location below
if [ $ssid = "YourWirelessNetwork" -o $ssid = "YourOtherWirelessNetwork" ]
then
`killall Transmission`
fi
exit 0

Transmission is the name of the app I use for Bittorrent. You’ll want to change that and the wifi network placeholders (capitalization matters!). Then you’ll want to save that file somewhere safe and `chmod +x whatever_you_called_it`. Then follow these directions for editing Kicker.xml so that it’ll run your script. Voila! The script will run whenever you change networks. It’ll check the name of the network and, if there’s a match, terminate the Transmission application (potentially messily, I should add — this may be bad for your downloads in progress).

All in all, a pretty clever way to avoid my own stupidity. Hopefully someone else will find it useful, too.

UPDATE: Hmm. After installing this setup I began to experience some pretty weird system blocking errors — most noticeably Terminal.app freezing, but other weirdness, too. You may want to hold off on it for now. I’m giving it another go using a Ruby script that forks immediately in the hopes that this will prevent anything from sticking:

#!/usr/bin/ruby
pid = fork do
#get the ssid of the network
ssid = `ioreg -l -n AirPortDriver | grep APCurrentSSID | sed 's/^.*= "\(.*\)".*$/\1/; s/ /_/g'`
#fill in your own values for ssid and location below
if ((ssid =~ /YourWirelessNetwork/i) || (ssid =~ /YourOtherWirelessNetwork/i))
`killall Transmission&`
end
end

8 Responses to “busted”

  1. ben wolfson says:

    Why do you have the killall invocations in backticks? You don’t store the output anywhere.

  2. Tom says:

    Well, the answer is “because it’s the first way of invoking shell commands that comes to mind”. But from your question I take it there’s a good computer-sciencey reason for not doing it this way unless I need the output, and that instead I should be using whatever the Ruby version of exec() or shell() is.

  3. ben wolfson says:

    (I mean in the shell script, naturally, not the ruby, about which I know nothing. You’ve also got a rather specific Other Network in the ruby version, which may or may not be intentional, and if it’s case insensitve, why vary cases?)

  4. Tom says:

    Aha! Of course that makes perfect sense about not needing backticks. Bash still doesn’t come that naturally to me and I was working off of someone else’s script that did do something with the output in that if..fi block.
    I noticed the lingering SSID, too, and cleaned it up before seeing your comment, but thank you for pointing it out. As for the case sensitivity: it’s left there both for readability and as a lingering effect of converting the Bash script into Ruby.
    I added the /i to ensure that there would be one less thing to trip up people trying to use the script. Besides, I don’t have a lot of faith in SSIDs’ case sensitivity — I believe it’s decorative from the spec’s point of view, which makes it hard to know whether to account for it or not.

  5. I’m far from someone who would advocate not hacking some sort of OS X XML file to accomplish cool things, but I’m also far from someone who would not take every opportunity to plug another Mac dev’s software — you should check this app out:
    http://centrix.ca/NetworkLocation/

  6. Tom says:

    nice! I went looking for an app just like that, but the best I came up with during my admittedly brief searches was sleepwatcher, which would’ve done in a pinch but wasn’t quite what I wanted.
    I’ll probably give my custom script a few more chances to prove itself. But if it screws up again Network Location looks very appealing.

  7. JasonT says:

    I’m a bit unclear as to why you get DMCA notices about this at work but things are hunky-dory (for both you and me) when you download at home…

  8. Alan says:

    BitTorrent is the wrong technology for this form of copyright infringement.
    You need http://usenet-news.net/

Leave a Reply