Unrar and cleanup script - UPDATE 2013.05.24

Discussion of Transmission that doesn't fit in the other categories
pigr8
Posts: 1
Joined: Tue Jul 09, 2013 4:11 pm

Re: Unrar and cleanup script - UPDATE 2013.05.24

Post by pigr8 » Tue Jul 09, 2013 4:23 pm

hi killermov! i was working on your script in order to get a hardlink function if the torrent are not rar files.

i read few post ago that you wrote this:

Code: Select all

if [[ "$TR_TORRENT_PARAMETER" =~ "EXTRACT" ]]; then
    ...
    if [ ${#RAR_FILES} -gt 0 ]; then
        ...
    else
        cp -val $SRC_DIR $DEST_DIR
        echo $NOW "Copied $TR_TORRENT_NAME" >> $LOG_FILE
    fi
fi
i tried to add those lines and if complete a torrent with rar files it extract correctly to my destination folder, if the torrent is a simpli file (exe, mkv, avi, *) it does nothing :(

my challenge was to add a filter option for file with a particular extension (editable maybe, like all video files or all iso files and so on) and if the torrent is a rar folder extract and copy to $DEST_DIR, if is a direct file just hardlink (with cp -val) to $DEST_DIR

no clue so far

Khabel
Posts: 5
Joined: Wed Jul 04, 2012 10:00 pm

Re: Unrar and cleanup script - UPDATE 2013.01.10

Post by Khabel » Thu Jul 18, 2013 8:47 am

killemov wrote:
Khabel wrote:
killemov wrote:The torrent file itself? The content? Some rar-specific files?
The script contains linux commands. Look for information on cp or mv, for example.
Sorry, should have made myself a bit clearer. If the torrent only contains one file e.g. movie.mkv and no rars where abouts in your script would I place the copy command to copy the mkv file to another location?

For example:

Code: Select all

if [[ "$TR_TORRENT_PARAMETER" =~ "EXTRACT" ]]; then
 [i]do stuff[/i]
else
    cp -R $SRC_DIR $DEST_DIR
    echo $NOW "Copied $TR_TORRENT_NAME" >> $LOG_FILE
fi
That could work. Or you could add another keyword to $TR_TORRENT_PARAMETER. I think it would be simpler if you use the copy command within the extract block, but when no rar files were found.

Code: Select all

if [[ "$TR_TORRENT_PARAMETER" =~ "EXTRACT" ]]; then
    ...
    if [ ${#RAR_FILES} -gt 0 ]; then
        ...
    else
        cp -R $SRC_DIR $DEST_DIR
        echo $NOW "Copied $TR_TORRENT_NAME" >> $LOG_FILE
    fi
fi

I've added the extra part but the copy fails, possibly due the spaces in the folder name, even though the $SRC_DIR and $DEST_DIR are within quotes e.g. DEST_DIR="${TR_TORRENT_DIR}/Movies/${TR_TORRENT_NAME}/"

The error when I run the copy manually is cp: target `AC3.AVCHD.iCandy' is not a directory
It's chopping the end of the torrent name off

Any ideas?

killemov
Posts: 421
Joined: Sat Jul 31, 2010 5:04 pm

Re: Unrar and cleanup script - UPDATE 2013.05.24

Post by killemov » Fri Jul 26, 2013 5:57 pm

Well, you might want to put your file names in quotes.

Code: Select all

cp -R "$SRC_DIR" "$DEST_DIR"

Khabel
Posts: 5
Joined: Wed Jul 04, 2012 10:00 pm

Re: Unrar and cleanup script - UPDATE 2013.05.24

Post by Khabel » Sat Jul 27, 2013 12:44 am

killemov wrote:Well, you might want to put your file names in quotes.

Code: Select all

cp -R "$SRC_DIR" "$DEST_DIR"
Tried that as well, makes no difference. If I use a hard coded variable for the destination with no spaces it works fine

Scouzer
Posts: 7
Joined: Wed Jan 08, 2014 9:32 am

Re: Unrar and cleanup script - UPDATE 2013.05.24

Post by Scouzer » Wed Jan 15, 2014 11:51 am

I have tried the script from the first post on page 1 on my Readynas ultra 2.
But I can't get it to work.
So I have tried to run the script manually by using bash posttorrent.sh, but I get this error:

: command not founde 3: {
: command not founde 18:
'osttorrent.sh: line 38: syntax error near unexpected token `do
posttorrent.sh: line 38: ` for RAR_FILE in $( find "$SRC_DIR" -type f -inam' "*.rar" ); do

All I have done to the script is changing the TR_USERNAME and TR_PASSWORD and also change it to $TR_TORRENT_HASH --remove at the end of the script.

Some one can help me with what I am doing wrong.

killemov
Posts: 421
Joined: Sat Jul 31, 2010 5:04 pm

Re: Unrar and cleanup script - UPDATE 2013.05.24

Post by killemov » Thu Jan 16, 2014 10:35 am

Scouzer wrote:Some one can help me with what I am doing wrong.
As i posted in viewtopic.php?f=3&t=15584:
killemov wrote:I don't know if you can run this script on a vanilla ReadyNAS Ultra 2 anyway. See the prerequisites in the first post of the aforementioned thread.
This script was written for Debian. Sure it will work on many other Linux distributions. But especially for limited operating systems (NAS,router, ...) there is the possibility it will not work.

Scouzer
Posts: 7
Joined: Wed Jan 08, 2014 9:32 am

Re: Unrar and cleanup script - UPDATE 2013.05.24

Post by Scouzer » Thu Jan 23, 2014 2:48 pm

my Readynas ultra 2 is running Debian etch

killemov
Posts: 421
Joined: Sat Jul 31, 2010 5:04 pm

Re: Unrar and cleanup script - UPDATE 2013.05.24

Post by killemov » Sun Jan 26, 2014 2:40 pm

Scouzer wrote:... I get this error:

: command not founde 3: {
: command not founde 18:
'osttorrent.sh: line 38: syntax error near unexpected token `do
posttorrent.sh: line 38: ` for RAR_FILE in $( find "$SRC_DIR" -type f -inam' "*.rar" ); do
...
I guess your version of bash is too old to be able to parse these expressions.

Scouzer
Posts: 7
Joined: Wed Jan 08, 2014 9:32 am

Re: Unrar and cleanup script - UPDATE 2013.05.24

Post by Scouzer » Tue Jan 28, 2014 9:11 am

Anything I can do about that?

killemov
Posts: 421
Joined: Sat Jul 31, 2010 5:04 pm

Re: Unrar and cleanup script - UPDATE 2013.05.24

Post by killemov » Thu Jan 30, 2014 4:21 pm

Scouzer wrote:Anything I can do about that?
Sigh, although this has nothing to do with the unrar script and everything with your OS:
Your safest bet would be to only upgrade the bash package. (apt-get update, apt-get install bash) This may prove impossible as Debian Etch was declared End-Of-Life almost four years ago. If so, then you need to take your quest to the readynas/debian forums. Good luck!

mike.dld
Transmission Developer
Posts: 285
Joined: Wed Dec 25, 2013 10:56 pm

Re: Unrar and cleanup script - UPDATE 2013.05.24

Post by mike.dld » Thu Jan 30, 2014 5:26 pm

Or one could rewrite the script so it supports even that "old" bash (or even other less popular shells). Just saying. Although I could spend some time on this if you wish.

Merwenus
Posts: 12
Joined: Wed Jan 29, 2014 1:01 pm

Re: Unrar and cleanup script - UPDATE 2013.05.24

Post by Merwenus » Sat Feb 01, 2014 9:48 am

Hello,
I have 2 questions, How can I make the new (2013 may) script to extract ZIP archives, and the other when I have only flt-reme.001->flt-reme.066 files but no r01, or rar, how can I force it to extract these too?
Thank you!

vmi
Posts: 2
Joined: Tue Feb 11, 2014 10:25 am

Re: Unrar and cleanup script - UPDATE 2013.05.24

Post by vmi » Wed Feb 19, 2014 7:18 am

dtrx is a great tool for handling extraction from various archives.

Merwenus
Posts: 12
Joined: Wed Jan 29, 2014 1:01 pm

Re: Unrar and cleanup script - UPDATE 2013.05.24

Post by Merwenus » Wed Feb 19, 2014 3:01 pm

vmi wrote:dtrx is a great tool for handling extraction from various archives.
Torrentexpander sorted it out, works better than this, ty btw.

dwardo
Posts: 2
Joined: Sun Mar 09, 2014 8:47 pm

Re: Unrar and cleanup script - UPDATE 2013.05.24

Post by dwardo » Sun Mar 09, 2014 8:49 pm

Hello,

I have added this script to my box and it doesn't extract any rar's. When I run the script manually I get the following error:

host:/addons-config/Transmission# bash posttorrent
posttorrent: line 28: conditional binary operator expected
posttorrent: line 28: syntax error near `=~'
posttorrent: line 28: ` if [[ "$TR_TORRENT_PARAMETER" =~ "EXIT" ]]; then'

Any help would be appreciated.

Post Reply