That's right. With some free tools, a little configuration, and a few hundred lines of Perl, you can automatically download new episodes of TV shows to your Mac. But that's not all. This solution will also automatically convert the shows and import them into iTunes with the TV show name, episode name, season number, and episode number. Let's get started!
How This Works
Let's talk for a minute about how this solution works, and what it will do. First, you'll subscribe to TV shows with an application called TVShows 2. It will always be watching for new torrents of the TV shows that you subscribe to. When TVShows 2 finds a new episode, it will automatically download the torrent, and then Transmission will start downloading the file. After the download completes, Transmission will call a helper file which you'll create later. That file will callimport.pl
, which will convert, name, and import your brand new episode into iTunes.First, Some Words of Warning
By now, you've probably realized what this means. You could download practically any TV show to your Mac, automatically and for free. But you might be breaking the law by doing so. You should not download TV shows unless a copyright owner has released them for free distribution. It's your responsibility to comply with federal and international regulations.If nothing else, please consider the people who create and produce the shows you love. These people rely on advertising revenue for their livelihoods, and a show's continued success depends on the number of viewers who regularly, and legally, watch it. Wouldn't you want to be paid for the work you do?
Getting the Right Tools for the Job
First, go ahead and download the following applications and files:- The super-cool TVShows 2 application
- Transmission (a BitTorrent client)
- HandbrakeCLI (a command line interface to the best video converting tool available)
- A few pre-made Perl scripts that I wrote myself
Subscribing to TV Shows
TVShows 2 is a free preference pane that lives in System Preferences. Once installed and configured, it watches for new episodes and automatically downloads new files when they become available. This is the backbone of our automated TV show downloading system, but it's worth noting that this application can also be used independently, without our nifty Perl scripts.Now you should use TVShows 2 to subscribe to your favorite TV shows. Here's how:
- From the Apple menu, select System Preferences.
- Select TV Shows, as shown below.
- Click the Add Show button, as shown below.
- Subscribe to whichever shows you want to automatically download.
Configuring TVShows 2
Next, let's configure TVShows 2 to work with Transmission and our Perl scripts. This will help create a seamless integration between the applications, so you won't even notice the episodes downloading. Everything will happen in the background, without you having to do anything.Here's how to configure TVShows 2:
- In the TVShows 2 preferences pane, click Preferences. The window shown below appears.
- Verify that Episode naming convention is set to S01E01.
- Verify that the Automatically open each Torrent file after download checkbox is selected.
- Select an a Episode save location. It doesn't matter what you select - just remember what it is.
- Close System Preferences
Configuring Transmission
Now let's configure Transmission, the free BitTorrent client, to automatically download the torrents that are found by TVShows 2. Without this application, you wouldn't have a way of downloading the episodes to your Mac! Here's how to configure Transmission:- Open the Transmission application.
- From the Transmission menu, select Preferences.
- Click Transfers. The window shown below appears.
- Verify that the Start transfers when added checkbox is selected.
- Verify that the Display a window when opening a torrent file checkbox is deselected.
Preparing Perl
Once you have downloaded and installed the applications, use the skills you learned in Using CPAN to Extend Perl on Mac OS X to download the following dependencies from CPAN:- Log::Log4perl
- LWP::UserAgent
- HTTP::Request
- HTTP::Response
chmod +x import.pl
Remember? You learned how to do that in Getting Started with Perl on Mac OS X.Putting the Pieces Together
Things are coming together nicely. We've installed the Perl dependancies and configured TVShows 2 and Transmit. Now we just need to glue everything together so it works seamlessly and automatically! Here's how:- Open a text editor, such as TextWrangler.
- Paste following in a file named
begin_import.sh
:
#!/bin/bash
cd ~/Desktop/ && ./import.pl $TR_TORRENT_NAME" - That code will work if you are downloading your TV Shows to your desktop. If not, change
~/Desktop
to the appropriate directory. - Save the file in a safe place.
- Open the Transmission application.
- From the Transmission menu, select Preferences.
- Click Transfers, and then click Management. The window shown below appears.
- Select the Call script checkbox.
- From the file selection window that appears, select the
begin_import.sh
so it's called when Transmission completes a download.
Final Thoughts
To recap, here's what's happening. TVShows 2 is always watching for new torrents of TV shows. When it finds one, it automatically downloads the torrent and Transmission starts downloading the file. When the download completes, Transmission calls the helper file (begin_import.sh
), which calls import.pl
,
and converts, names, and imports your brand new episode into iTunes. Of
course, once the shows are in iTunes, you can transfer them to your
iPad, iPhone, or iPod Touch.Enjoy your new TV shows! To keep improving your Perl chops, you may want to dive into those files that you downloaded from GitHub and look around. If you see something wonky, or if you have an improvement, be sure to fork the repo and submit changes! Retweet this story
No comments:
Post a Comment