hjhart / the_rotten_pirate

Automatic torrent downloader (movie lists come from Rotten Tomatoes, torrents and ratings come from The Pirate Bay)
103 stars 12 forks source link

The Rotten Pirate!

(or: "STOP STEALING MY MOVIES YA DAMN KIDS!")

Quick 'n' dirty

Pretty neat, yeah?

Setup

Clone the source and install proper gems

git clone git@github.com:hjhart/the_rotten_pirate.git
cd the_rotten_pirate

At this point if RVM is installed you'll get prompted to trust this new .rvmrc file. I highly recommend you use RVM (for every project really). Allow it and it should create a new gemset for you.

Now, after the proper ruby has been picked and you've got a clean gemset, let's get our gemset populated.

gem install bundler --pre # You may need to install bundler with your fresh gemset – I prefer bundler 1.1 right now
bundle

Run this command to initialize your sqlite database and make working copies of the config files.

rake initialize

Configure stuff!

Important configurations in config/config.yml

Set your download_directory to a directory you want to drop the torrent files to.

Change this to lowest percent (based on RTs TomatoMeter) that you want to download.

If this is turned on The Rotten Pirate will query the comments on The Pirate Bay for ratings. It will then calculate a score and choose the highest "quality" torrent for you to download. Takes considerably longer but is well worth the wait.

The number of search results to query for comments. If there are 30 search results from pirate bay, but you only want to query the top 10 seeded torrents for comments – use this variable.

Don't query for comments unless there are this many seeds on the torrent (there are hardly any comments for lower seeded torrents)

You can point this towards a new-line delimited file – it will download each movie that is listed in the file. (Really nice with the side-project the_mobile_pirate)

If you want to configure prowl notifications, see section below.

Run the process!

rake execute

You'll see the search begin (this can take anywhere from 10 seconds to 5 minutes) and output will follow.

Download a Single Movie

rake download["The Big Lebowski"]

This will run the search operation as configured – and download a single torrent file.

Download an Array of Movies

rake download_from_watch_file

This will run against any text file that is new-line delimited. Parses through the file and downloads each movie. Really a nice to have with the_mobile_pirate.

Run tests

rspec spec

So far this has been tested on ruby-1.9.2-p290 on OSX 10.6

Automate with a cron job

Run crontab -e and paste the following into there to start a new cronjob. It will run every 2 days at 12:30am. Make sure the change cd ~/Sites/the_rotten_pirate to the directory where your code lives.

30 0 1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31 * * /bin/bash -l -c 'cd ~/Sites/the_rotten_pirate && bundle exec rake execute --silent >> /dev/null 2>&1'

Play with code

rake console
TheRottenPirate.execute

The algorithm for scoring torrents

Inside of The Pirate Bay results you'll see comments looking like: "Great movie, A - 10, V - 10"

This means that the audio track is rated a 10, and the video the same. I'm paginating through every page of comments from the pirate bay and analyzing the comments for those sort of ratings. I then average them up. Since one vote of a 9 should be "scored" less than 5 votes of 9's, I'm adding a booster to scores that have a lot of votes. This boost is calculated on a logarithmic scale (So that 40 votes of 5 doesn't end up beating 5 votes of 9). The boost is then summed to the average rating to produce the total.

When you turn on the ["comments"]["quality"] setting in the configuration it will parse through the comments and try to find the highest video quality of all the videos. If you turn it off, it will just grab the search result with the highest seeds (for quick downloading)

Prowl notifications

You'll receive prowl notifications at the end of every run with a rundown of what movies were added.

Potential TODOS

Support

Tested on ruby 1.9.2-p290 on Mac OSX. Also tested on ruby 1.8.7-p330 on Mac OSX.

Counter