Automatically Download all Your Favourite TV Shows and Movies


Special Thanks to user Zilexa on the Raspberry PI foums who wrote the original guide for Xbian. I adapted it for the dfiferent settings in RaspBMC so most of this is his work.
See the orignal thread here

REQUIRED INGREDIENTS:


QUICK SUMMARY HOW IT WILL WORK:
Have you ever heard of imdb.com? This is like the Wikipedia of movies and tv shows. There is a similar site called Trakt.tv. Biggest difference: you can create an account at Trakt.tv, install the addon in XBMC, and it will automatically keep track of what you watched in XBMC and, very important for this guide: what you would like to watch.

Basically, you will not notice anything after adding a running TV Show to Trakt. Once an episode or movie becomes available in the quality you prefer --> it will appear in XBMC.

in detail:
On trakt.tv, you can simply add tv shows to a list. Special software (Flexget) on the RPi keeps an eye on this list of yours. Secondly, this software will use intelligent scripting (nothing you need to do, dont worry) to get the latest episodes or movies from online newsfeeds (torrents) that are meant for this setup. Thirdly, after an episode or movie has been downloaded, XBMC will be notified and add just that download to its library.


PREPARATIONS:


Step A: INSTALL THE RPI WITH RaspBMC
Follow the RaspBMC install instructions here.
NOTE: Make sure you insert the SD card in the RPi and connect all cables BEFORE you connect it to power.
NOTE: Check your router to see what the iP address of the RPi is. If your router supports it, reserve a fixed IP for the RPi so that the RPi will always be accessible via this IP address.


STEP B. INSTALL TOOLS
1. Transmission
Connect to the Pi using your terminal software and enter the following commands one by one:
sudo apt-get install transmission
sudo apt-get install transmission-daemon
sudo apt-get install python-pip 
sudo pip install flexget
sudo pip install transmissionrpc

Then run this, it should return a version, if not, something went wrong, install again:
flexget -V

STEP C. CREATE THE FOLDER STRUCTURE ON USB DRIVE
You need to configure the file structure on your external USB drive.

Note that if your hard drive is formatted as NTFS, the chmod commands will not do anything. See Step I to get round this issue.    
STEP D. CONFIGURE TRANSMISSION
login via putty or terminal. 
Transmission should be configured after you stopped it from running, otherwise the changed settings will not be saved. Follow the steps below:


STEP E. USE CYBERDUCK TO ADD FLEXGET SETTINGS
Start Cyberduck on your laptop and login to your RPi by entering IP address, username (pi) and password. Go to Media/usb. This is your usb harddrive. Here you'll see all important folders (simply type ls and hit enter) you created in the previous steps like Downloads, TV Shows, Movies. Episodes that are downloading will be in media/External/Downloads/incomplete. When done they should appear in the appropriate subfolder of TV Shows. Now perform these steps:


STEP F. TEST FLEXGET AND SCHEDULE IT
1. test Flexget
Now go back to Putty (windows) or Terminal). I assume you exited Xbian-Config. Run this command to test Flexget. Nothing will actually be saved or downloaded.

flexget -c /media/External/Downloads/flexget/config.yml --test

If your config.yml is correct, it will show its progress and take a few minutes to finish. If your config.yml is incorrect you will get to see an explanation what went wrong. Use --check if you simply want to check if your config.yml contains typos.

[*]2. Schedule Flexget
If nothing went wrong, you can now go ahead and schedule Flexget. I choose to schedule it every 3 hours starting at 3 AM since I live Europe and between 2-6 AM most US tv shows from the previous evening become available.
Run this command:

crontab -e

Now scroll all the way down and copy paste this line, then hit CTRL+O to save it and CTRL+X to close it.
0 3,6,9,12,15 * * * nice -n 4 /usr/local/bin/flexget -c /media/External/Downloads/flexget/config.yml --cron

Now, Cron jobs are disabled by default in RaspBMC so you will have to enable them by going to Programs?RaspBMC Settings>Server Configuration and enabling "Cronjob Scheduler"

This will run Flexget every three hours starting at 3AM and last one at 3PM. Sometimes, a newer version of an episode is released later because the first release had errors (like audio not in sync with video etc).

STEP G. MANAGE PRIORITY
Still to figure ths one out.

STEP H. XBMC ESSENTIALS

STEP I (Optional). TRANSMISSION AND NTFS DRIVES
You may find when you check your Transmission web interface, that you are getting access denied errors on the torrents. This is because NTFS formatted drives don;t handle permissions the same way as EXT3 or 4 partitions do. On the NTFS partition you will find that only the Pi user has access to the drive. Since Transmission runs under the user 'debian-transmission' it won't be allowed to write to the drive. What we need to do is change the transmission script to run as user Pi instead.     sudo chown -R $USER /var/lib/transmission-daemon/info/
    sudo chown -R $USER /etc/transmission-daemon/
    sudo service transmission-daemon start

Add your sources! Go to Videos and choose Add Source. Go to ROOT, then media>External>TV Shows and select this folder. Then select This folder contains TV Shows and save it. Do the same for Movies but select it contains Movies.

Enjoy! Any questions. Ask.

EXTRA: want to be able to access your files when you are not at home? And be able to add torrents to Transmission when you are at work? check out Zilexa's pastebin how to easily make your RPi always accessible. Note: you do need to setup portforwarding in your router for port 22 (to access files and also to do SSH) and port 9091 (for Transmission).

ADDITION:
Here is a copy of my config.yml scrit. Replace anything in <BOLD> with your own credentials:

presets:
  tvshows:
    exists_series:
      - /media/External/TV Shows/
      - /media/External/Downloads/
    regexp:
      reject:
        - FASTSUB
        - VOSTFR
        - Subtitulado
    content_filter:
      reject:
        - '*.rar'
        - '*.zip'
        - '*.avi'
                 - '*.wmv"
    transmission:
      host: localhost
      port: 9091
      username: transmission
      password: <TRANSMISSION_PASSWORD>
      path: /media/External/TV Shows/{{series_name}}/S{{"%02d"|format(series_season)}}
    inputs:
      - rss: http://showrss.karmorra.info/rss.php?user_id=<MY_ID>&hd=2&proper=1&namespaces=true&magnets=true
      - rss: http://kat.torrenticity.com//tv/?rss=1
      - rss: http://rss.bt-chat.com/?group=3
      - rss: http://extratorrent.com/rss.xml?cid=8
  movies:
    transmission:
      host: localhost
      port: 9091
      username: transmission
      password: <TRANSMISSION_PASSWORD>
      path: /media/External/Movies

tasks:

  Get tvshows hdtv <720p:
    priority: 2
    preset: tvshows
    import_series:
      from:
        trakt_list:
          username: <USERNAME>
          password: <PASSWORD>
          api_key: <API KEY>
          custom: TV Shows
      settings:
        quality: hdtv <720p

  Fill movie queue:
    priority: 3
    interval: 1 day
    trakt_list:
          username: <USERNAME>
          password: <PASSWORD>
          api_key: <API KEY>
      movies: watchlist
    seen: local                    # We don't want accepted movies on this feed to affect actual download feed
 queue_movies:
      quality: 480p 720p+ dvdrip dvdscr webrip
      force: no
    imdb_lookup: yes
    accept_all: yes

  Get movies:
    preset: movies
    priority: 4
    content_size:
      max: 20000
      min: 500
    torrent_alive: yes
    discover:
      what:
        - emit_movie_queue: yes
      from:
        - piratebay: yes
        - search_rss:
            url: http://rss.thepiratebay.sx/201
            link: magneturi
        - search_rss:
            url:  http://katmirror.com/highres-movies/?rss=1
        - kat:
            verified: yes
        - torrentz: verified
    movie_queue: yes



Index
<- I/O Board