Unrar and cleanup script - UPDATE 2013.05.24
Re: Unrar and cleanup script - UPDATE 2013.01.10
Hello,
Script looks really good, but since I'm such a newbie at this I'm a little afraid to implement it before I know a few things.
Can you toggle it, so it doesnt actually delete the rarfiles after the extracting is done? I use a FTP ratio community, so they would get really angry if someone just downloaded the files and delete it right after.
Also, will it extract it in the same folder as the rars are in?
Lastly, I'm using ReadyNAS Ultra 2, I assume it works with it?
Script looks really good, but since I'm such a newbie at this I'm a little afraid to implement it before I know a few things.
Can you toggle it, so it doesnt actually delete the rarfiles after the extracting is done? I use a FTP ratio community, so they would get really angry if someone just downloaded the files and delete it right after.
Also, will it extract it in the same folder as the rars are in?
Lastly, I'm using ReadyNAS Ultra 2, I assume it works with it?
Re: Unrar and cleanup script - UPDATE 2013.01.10
Yeah, I just finished slapping some lipstick on her.GAPP wrote:Hello,
Script looks really good, but since I'm such a newbie at this I'm a little afraid to implement it before I know a few things.

Sure, just give me your account data and I will edit it for you. (Or put a file named "keep" in the top folder of your torrent. Or find "--remove-and-delete" in the script and replace it with "--remove".)Can you toggle it, so it doesn't actually delete the rarfiles after the extracting is done? I use a FTP ratio community, so they would get really angry if someone just downloaded the files and delete it right after.
No, but DEST_DIR="$SRC_DIR" might do the trick.Also, will it extract it in the same folder as the rars are in?
You haven't read the first post or you you have a hard time understanding it, right? But wouldn't that make your initial compliment just a bit ... insincere?Lastly, I'm using ReadyNAS Ultra 2, I assume it works with it?
In short: @alln00bs: You need to find some things out for yourselves!
Re: Unrar and cleanup script - UPDATE 2013.01.10
You're right. It did come off a little insincere. What I meant was, that I read throughout that people was really pleased with your work, so I assumed it was really good. In reality I'm not the best at this, but I'm trying. I guess I could figure it out with time, but feel like it's better ask instead of doing something stupid.
So its important that the torrents doesnt get removed and the rars get deleted by themselves. I need to do that manually, because some things I download is from there.
So its important that the torrents doesnt get removed and the rars get deleted by themselves. I need to do that manually, because some things I download is from there.
Code: Select all
{
"alt-speed-down": 50,
"alt-speed-enabled": false,
"alt-speed-time-begin": 540,
"alt-speed-time-day": 127,
"alt-speed-time-enabled": false,
"alt-speed-time-end": 1020,
"alt-speed-up": 50,
"bind-address-ipv4": "0.0.0.0",
"bind-address-ipv6": "::",
"blocklist-enabled": true,
"blocklist-url": "http://list.iblocklist.com/?list=bt_level1",
"cache-size-mb": 200,
"dht-enabled": false,
"download-dir": "/c/media/BitTorrent",
"download-queue-enabled": true,
"download-queue-size": 5,
"encryption": 1,
"idle-seeding-limit": 30,
"idle-seeding-limit-enabled": false,
"incomplete-dir": "/c/media/BitTorrent/Incomplete",
"incomplete-dir-enabled": true,
"lazy-bitfield-enabled": true,
"lpd-enabled": false,
"max-peers-global": 200,
"message-level": 1,
"open-file-limit": 32,
"peer-congestion-algorithm": "",
"peer-limit-global": 240,
"peer-limit-per-torrent": 60,
"peer-port": 51413,
"peer-port-random-enabled": 0,
"peer-port-random-high": 65535,
"peer-port-random-low": 1024,
"peer-port-random-on-start": false,
"peer-socket-tos": "default",
"pex-enabled": true,
"pidfile": "/var/run/transmission-daemon.pid",
"port-forwarding-enabled": true,
"preallocation": 2,
"prefetch-enabled": 0,
"proxy": "",
"proxy-auth-enabled": false,
"proxy-auth-password": "",
"proxy-auth-username": "",
"proxy-enabled": false,
"proxy-port": 80,
"proxy-type": 0,
"queue-stalled-enabled": true,
"queue-stalled-minutes": 30,
"ratio-limit": 2,
"ratio-limit-enabled": true,
"rename-partial-files": true,
"rpc-authentication-required": false,
"rpc-bind-address": "0.0.0.0",
"rpc-enabled": true,
"rpc-password": "xxxxxxxxxxxxxxxxxx",
"rpc-port": 8181,
"rpc-url": "/transmission/",
"rpc-username": "admin",
"rpc-whitelist": "*",
"rpc-whitelist-enabled": true,
"scrape-paused-torrents-enabled": true,
"script-torrent-done-enabled": true,
"script-torrent-done-filename": "/c/addons-config/Transmission/email_alert",
"seed-queue-enabled": false,
"seed-queue-size": 10,
"speed-limit-down": 100,
"speed-limit-down-enabled": false,
"speed-limit-up": 5,
"speed-limit-up-enabled": true,
"start-added-torrents": true,
"trash-original-torrent-files": false,
"umask": 0,
"upload-limit": 100,
"upload-limit-enabled": 0,
"upload-slots-per-torrent": 14,
"utp-enabled": false,
"watch-dir": "/c/media/BitTorrent/sources/",
"watch-dir-enabled": 1
}
Re: Unrar and cleanup script - UPDATE 2013.01.10
I saw mention a manual somewhere on the last 8 pages, for use of the Keep/Exit files and so on. Where does that live?
All I wish to do is unrar when a download finishes (to a new directory), preserve the files for seeding indefinitely (in the complete directory), well until I remove them manually.
I'm sure this can't be hard, I just can't seem to get the required behaviour.
Thanks for your time.
All I wish to do is unrar when a download finishes (to a new directory), preserve the files for seeding indefinitely (in the complete directory), well until I remove them manually.
I'm sure this can't be hard, I just can't seem to get the required behaviour.
Thanks for your time.
Re: Unrar and cleanup script - UPDATE 2013.01.10
If the torrent doesn't need unraring what do I need to add so the file is copied to a different location instead?
Re: Unrar and cleanup script - UPDATE 2013.01.10
Start post updated. Use a "keep" control file.lewsut wrote:I saw mention a manual somewhere on the last 8 pages, for use of the Keep/Exit files and so on. Where does that live?
Khabel wrote:If the torrent doesn't need unraring what do I need to add so the file is copied to a different location instead?

The script contains linux commands. Look for information on cp or mv, for example.
Re: Unrar and cleanup script - UPDATE 2013.01.10
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?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.
For example:
if [[ "$TR_TORRENT_PARAMETER" =~ "EXTRACT" ]]; then
do stuff
else
cp -R $SRC_DIR $DEST_DIR
echo $NOW "Copied $TR_TORRENT_NAME" >> $LOG_FILE
fi
Re: Unrar and cleanup script - UPDATE 2013.01.10
killemov, Does the Keep file have the same effect as commenting out the transmission-remote --remove-and-delete line?
Edit: I guess not as stuff gets removed keep file or not?
Thanks.
Added
else
cp -r "$TR_TORRENT_NAME" "$DEST_DIR"
cp "$TR_TORRENT_NAME" "$DEST_DIR"
Edit: I guess not as stuff gets removed keep file or not?
Thanks.
What I do that seems to work is below, i'm not so good at this kind of thing but like I say works for me and In think it's what you want to do?Khabel wrote: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?
Added
else
cp -r "$TR_TORRENT_NAME" "$DEST_DIR"
cp "$TR_TORRENT_NAME" "$DEST_DIR"
Code: Select all
if [ ${#RAR_FILES} -gt 0 ]; then
for RAR_FILE in "${RAR_FILES[@]}"; do
unrar x -inul "$RAR_FILE" "$DEST_DIR"
if [ $? -gt 0 ]; then
echo $NOW "Error unrarring $TR_TORRENT_NAME" >> $LOG_FILE
transmission-remote -n $TR_USERNAME:$TR_PASSWORD -t $TR_TORRENT_HASH --verify --start
exit 0
fi
done
else
cp -r "$TR_TORRENT_NAME" "$DEST_DIR"
cp "$TR_TORRENT_NAME" "$DEST_DIR"
if [[ ! "$TR_TORRENT_PARAMETER" =~ "KEEP" ]]; then
SLEEP=$(expr match "$TR_TORRENT_PARAMETER" '.*SLEEP\([0-9a-zA-Z]*\)')
if [ ${#SLEEP} -gt 0 ]; then
sleep $SLEEP
fi
#transmission-remote -n $TR_USERNAME:$TR_PASSWORD -t $TR_TORRENT_HASH --remove-and-delete
fi
echo $NOW "Unrarred $TR_TORRENT_NAME" >> $LOG_FILE
fi
fi
fi
} &
Re: Unrar and cleanup script - UPDATE 2013.01.10
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.Khabel wrote: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?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.
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
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
Re: Unrar and cleanup script - UPDATE 2013.01.10
Yes, that should work also. But remember: "keep" != "Keep".lewsut wrote:killemov, Does the Keep file have the same effect as commenting out the transmission-remote --remove-and-delete line?
Edit: I guess not as stuff gets removed keep file or not?
Re: Unrar and cleanup script - UPDATE 2013.01.10
My bad! thanks for that.killemov wrote:Yes, that should work also. But remember: "keep" != "Keep".
-
- Posts: 2
- Joined: Sat Apr 27, 2013 3:31 pm
Re: Unrar and cleanup script - UPDATE 2013.01.10
Hi everybody!
I've been using this script to auto extract torrents after finished:
What I wonder is, what should I modify in the extraction script to allow it to extract each file to a subfolder? Becase as it is, the "extracted" folder gets messy with all kind of assorted files from every downloaded torrent. I mean:
Example:
I download an abc.rar file
It should extract to extracted\abc\<file 1, file 2, etc>
Instead of (how now does it) extracted\<file 1, file 2, etc>
Thanks!
I've been using this script to auto extract torrents after finished:
Code: Select all
#!/bin/bash
formats=(zip rar)
commands=([zip]="unzip -u" [rar]="unrar -o- e")
extraction_subdir='extracted'
torrentid=$TR_TORRENT_ID
torrentname=$TR_TORRENT_NAME
torrentpath=$TR_TORRENT_DIR
log()
{
logger -t transmission-extractarchives "$@"
}
log "Torrent complete: $@"
cd "${torrentpath}"
for format in "${formats[@]}"; do
while read file; do
log "Extracting \"$file\""
cd "$(dirname "$file")"
file=$(basename "$file")
# if extraction_subdir is not empty, extract to subdirectory
if [[ ! -z "$extraction_subdir" ]] ; then
mkdir "$extraction_subdir"
cd "$extraction_subdir"
file="../$file"
fi
${commands[$format]} "$file"
done < <(find "$torrentpath/$torrentname" -iname "*.${format}" )
done
Example:
I download an abc.rar file
It should extract to extracted\abc\<file 1, file 2, etc>
Instead of (how now does it) extracted\<file 1, file 2, etc>
Thanks!
Re: Unrar and cleanup script - UPDATE 2013.01.10
Please refrain from using this topic for anything other than questions about or suggestions for the script in the first post.
@Dan_Aykroyd: I might have helped you out if you posted this in its own topic.
@Dan_Aykroyd: I might have helped you out if you posted this in its own topic.
-
- Posts: 2
- Joined: Sat Apr 27, 2013 3:31 pm
Re: Unrar and cleanup script - UPDATE 2013.01.10
OK, you've been very helpful, sorry to ask a question from a script that was on this thread and not about your awesome OP script.
Nvm, I'm using TorrentExpander, I think you all should do the same

Nvm, I'm using TorrentExpander, I think you all should do the same
Re: Unrar and cleanup script - UPDATE 2013.05.24
Changelog
- Make sure only FILES with .rar suffix are processed, NOT FOLDERS.