WD My Book Live - Transmission + Unrar

Discussion of Transmission that doesn't fit in the other categories
Post Reply
transflava
Posts: 12
Joined: Thu Jun 21, 2012 11:19 am

WD My Book Live - Transmission + Unrar

Post by transflava »

I thought i post this here as many people may need to automate things for their DLNA devices. This is debian tutorial but should work on other linux boxes. I hope it helps someone.

-----

Problem: Some torrents come archived and if you use DLNA device you can't stream them after download.
Solution: Add unrar script to execute after torrent is downloaded.
Requirements:
1.Transmission torrent client (Linux) - http://www.transmissionbt.com/
2.UnrarAll script - https://raw.github.com/arfoll/unrarall/master/unrarall

3. Simple bash script to wrap the two together - post.sh


-----------

First configure UnrarAll:

Download file and copy to /opt/bin/unrarall (or anywhere you like)

chmod +x the script so it will be executable

1. I have used simple configuration which runs the script to check for RAR files in the default torrent download folder - /home/Downloads
2. I have decided not to cleanup the rar files after download because you can't continue seeding the torrent if the RAR files are deleted.

The script will run in stand alone mode, without the need to tie it to Transmission, can be added to cronjob but i prefer to execute it after torrents are downloaded.

# /opt/bin/unrarall --dir /home/Downloads

3. The above line is executed everytime a torrent is completed. If no RAR is found it does nothing.

Usage: unrarall [ --dir DIRECTORY ] [ --clean | --force ] [ --full-path ] [ --verbose ]

DESCRIPTON
unrarall is a utility to unrar and cleanup (delete) all rar files within a directory DIRECTORY.
Sub-directories are automatically recursed and if a rar file exists in a sub-directory then the rar file is extracted into that subdirectory.

Use --clean if you want to cleanup. Otherwise no cleaning is done.
It can also be used to delete rar files that have already been used for extraction with --force. Use with caution!

OPTIONS

-c, --clean Clean after unrar. If the extraction fails then the directory will NOT be cleaned. Use --force to override this.
-d, --dir Use directory DIRECTORY. If this argument is not supplied the current working directory is used.
-f, --force Force clean even if unrar fails. Implies --clean. Use this if you've already used unrarall on the directory before
and now you want to remove the rar files. This should be pretty fast as unrar is set to not overwrite already extracted files.
--full-path Extract full path inside rar files instead of just extracting the files in the rar file which is the default behaviour.

Creating the script to be executed within Transmission

1. In your console type: nano post.sh - this will open a text editor
2. Insert the line from UnrarAll configuration - /opt/bin/unrarall --dir /home/Downloads
3. Save to /usr/bin or any other folder you store binaries - i stored it in /opt/bin/post.sh
4. chmod +x /opt/bin/post.sh

Adding the script to Transmission.

1. Stop transmission-daemon from running
Commands:
# ps x |grep transmisson

13717 ? Ssl 162:17 transmission-daemon

# kill 13717

2. Edit the configuration file settings.json

# cd /root/.config/transmission-daemon

ls

root 4096 Feb 20 20:33 blocklists
root 1055 Jun 14 18:58 dht.dat
root 20480 Jun 21 13:52 resume
root 4096 Mar 7 10:02 scripts
root 2178 Jun 16 11:16 settings.json
root 165 Jun 21 13:52 stats.json
root 16384 Jun 21 13:15 torrents

# nano settings.json

1.Find strings

"script-torrent-done-enabled": false,
"script-torrent-done-filename": "",

2. Change lines to :

"script-torrent-done-enabled": true,
"script-torrent-done-filename": "/opt/bin/post.sh",

3. Save
4. Start transmission-daemon
killemov
Posts: 573
Joined: Sat Jul 31, 2010 5:04 pm

Re: Transmission + Unrar

Post by killemov »

So you have written a bash script that wraps unrar and leaves integration with transmission up to the user. And you post this on the transmission forum?
It will not remove the torrent from transmission and will lead to error messages about missing files.
Have you even looked at this? Unrar and cleanup script
Last edited by killemov on Fri Jun 22, 2012 11:36 pm, edited 1 time in total.
transflava
Posts: 12
Joined: Thu Jun 21, 2012 11:19 am

Re: WD My Book Live - Transmission + Unrar

Post by transflava »

Your script is too complicated and not straight forward.

This script is transmission independent, but it integrates easier and is not affected by issues related to transmission.

Integration with transmission is only to make it run and do it's job - extract rars to be viewed on the DLNA box.

It will not break the torrent if you don't clean up the rars.

Also there is no need to remove torrents after download and extraction. I am happy with stop @ ratio function.
Some people are not leeches they actually participate in private trackers which reward you for seeding.

I have a setup Transmission + Flexget + Unrar - and it works flawlessly. I shared it here because there is a need for a simpler solution than yours.
killemov
Posts: 573
Joined: Sat Jul 31, 2010 5:04 pm

Re: Transmission + Unrar

Post by killemov »

If you remove rar files but keep the torrent running in transmission that will lead to errors right?
But if you don't clean up the rar files then your script adds very little to plain unrar. Get it?

So where would YOU tell your script to start unrarring and clean up? To the shared downloads folder? (I figured you might find using environment variables passed from transmission complicated.)
transflava
Posts: 12
Joined: Thu Jun 21, 2012 11:19 am

Re: WD My Book Live - Transmission + Unrar

Post by transflava »

As it says in the description by adding the "-c, --clean Clean after unrar." - this will delete the rars.
killemov
Posts: 573
Joined: Sat Jul 31, 2010 5:04 pm

Re: Transmission + Unrar

Post by killemov »

Not how, but where! I mean the actual parameter for the path. (For example /downloads ) I am suggesting you have to use the environment variables transmission passes to the script to do this properly or bad things will happen.
transflava
Posts: 12
Joined: Thu Jun 21, 2012 11:19 am

Re: WD My Book Live - Transmission + Unrar

Post by transflava »

The script does not work per-torrent setting, but per default download folder. Which means that it runs every time a torrent completes. Nothing will go wrong as it only unrars files in that folder.If you download torrent in a different folder, the script does not do anything there.

/opt/bin/unrarall --dir /home/Downloads (default download directory) - scans recursively all folders for rars, and if already un-rared then it doesn't do anything.

If your script is better people will use it, but if they have to keep asking you how to make it work then i don't think it's really very useful.
mr_sparks
Posts: 3
Joined: Sun Feb 10, 2013 5:20 am

Re: WD My Book Live - Transmission + Unrar

Post by mr_sparks »

This is GREAT, I like how it doesn't necessarily delete the input rar files (whoever thought that was a good idea?) and that it runs independent from transmission so that I can run it on my server with deluge. One very important thing though, is there anyway to make it extract the files to another location?

I have it set up where flexget loads my torrents into deluge from a rss feed on a private tracker. I want to keep my ratio up so I have that running until it is auto removed at a ratio of 3 or if I remove it first. This helps me since I don't have to extract each file but I still have to move the file to my tv folder. I found the github page but I couldn't figure out how to add in the move command.
mr_sparks
Posts: 3
Joined: Sun Feb 10, 2013 5:20 am

Re: WD My Book Live - Transmission + Unrar

Post by mr_sparks »

Never mind I found it. Since I'm using unrar I just looked up the input for that and change the script so that the input was:

unrar ${UNRAR_METHOD} $( getUnrarFlags ${UNRARALL_BIN}) "$filename" /home/downloads/tv/

I'll probably modify it further so that it doesn't look for an unrar bin or other stuff since I know i'll only be doing it one way, but a good script, it's going to be very useful
mr_sparks
Posts: 3
Joined: Sun Feb 10, 2013 5:20 am

Re: WD My Book Live - Transmission + Unrar

Post by mr_sparks »

On second thought, I just left it the way it was and added on the lines:

find /home/downloads/incomplete/done -iname "*.mp4" -type f | xargs -I '{}' cp {} /home/downloads/done
find /home/downloads/incomplete/done -iname "*.mkv" -type f | xargs -I '{}' cp {} /home/downloads/done
find /home/downloads/incomplete/done -iname "*.avi" -type f | xargs -I '{}' cp {} /home/downloads/done

for the torrents that don't come in parts
Post Reply