[GUIDE] Install Transmission 2.77

Try changing the current rar extract line to

NM: Doesn’t work

LMAO Dan_Aykroyd

Hopefully you get an answer :slight_smile:

1 Like

Guide updated

Fixed unrar script :slight_smile:

The unrar script will now extract the archive to /TR-Downloads/extracted/ folder named after the archive :wink:

#!/bin/bash
formats=(zip rar)
commands=([zip]="unzip -u" [rar]="unrar -o- e -ad")
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
1 Like

LOL :smiley: Thanks nfo for the script!

What was modified? I noticed the -ad switch when unrar is used… was that it? If so, then unzip wouldn’t extract to a subfolder then?

Thanks!!!

Yeah that was it… Do we need to modify for zip too? I just googled Debian unrar switches and messed with it until it worked… I wasn’t sure if there were alot of zip stuff on torrents so I didn’t mess with it.

I was blind then, before posting the first time I did an “unrar --help” to take a look of the switches but didn’t read -ad. I even tried with the “x” switch and it didn’t work, so I thought we had to modify the actual script, not just the switches.

Now I’ve read again the “unzip --help” too and there seem to be nothing there like de unrar ad switch. As you say, the majority of torrents are in .rar, but there are still several zipped files around. If we could get a mod (maybe a reply from transmission forums?), it would be great, as both types of files would behave in the same way when extracting.

Oh, and about this -ad switch, does it need some testing to see if it works or have you already tried with a file to check it? Let me know if you need me to test.

Thanks

I tested it with a single rar file so more testing might be needed :slight_smile:

I wonder if unrar can also handle zips archives in debian?

Any luck Timmy, I’ve been tied up all day and now I’m half cocked

Hmmm no… I’ve searched and found no mention of unrar working with other than .rar, and there’s no switch that would make it work as unrar…

Maybe another “unzip” client? I don’t know which one was the one we installed in the guide (or if there are any others!), but that’s the only thing that came to mind. Maybe by modifying the script to write the subfolder by itself instead of the commands, but it hasn’t worked for me. I’ve tried mkdir with the $TR_TORRENTNAME (or something, I’m calling out from memory) variable and I got two results: one creating a folder with a garbage name and the other creating a folder named “$TR_TORRENTNAME” instead of the variable content! In any case, the folders were empty, so everything was broken.

Let hope we get an answer on the Transmission forum.

Timmy, I tried a couple of torrents to small zip files and they didn’t extract. Are zips extracting for you at all?

I didn’t try any zip files actually… :S Maybe it doesn’t work? That would be weird, probably something messed up in the unzip command line and switches, because the rest of the logic of the script should be the same

I have torrenexpander working with a BASIC setup. It extracts both zip and rar archives and extracts them to the root of your Public folder in a folder named after the archive…This script is HIGHLY CONFIGURABLE

I have now moved this to the front page

Tweak this baby to your hearts content and upload your file for download!

Here is a list of the user variables that you can tweak

THIS IS NOT THE WHOLE SCRIPT

IT IS JUST THE VARIABLES PORTION OF THE SCRIPT

#!/bin/bash

## Set up the running environment
# Making sure spaces are not interpreted as newline
SAVEIFS=$IFS
IFS=$(echo -e "\n\b")
# Making sure PATH variable contains all necessary binary paths
path_backup="$PATH";
initial_path=":$PATH:";
new_path="$PATH";
for test_path in $(echo -e "/usr/local/sbin\n/usr/local/bin\n/usr/sbin\n/usr/bin\n/sbin\n/bin\n/usr/games\n/usr/bin\n/bin\n/usr/sbin\n/sbin\n/usr/local/bin\n/usr/X11/bin\n/Applications\n/opt/syb/sigma/bdj/jvm/bin\n/usr/bin/X11\n/opt/syb/app/bin\n/opt/syb/app/sbin\n/opt/syb/sigma/bin\n/nmt/apps"); do
	if [[-d "$test_path" && "$initial_path" != *:$test_path:*]]; then
		new_path="$new_path:$test_path";
	fi
done
export PATH="$new_path"

for bin in $(echo -e "basename\ncat\nchmod\nchown\ndate\ndirname\ndu\necho\negrep\nexpr\nfind\ngrep\nid\nls\nmkdir\nmv\nrm\nsed\ntouch\nwc"); do
	if [! -x "$(which "$bin")"]; then missing_bin="$missing_bin\n$bin"; fi
done
if ["$missing_bin"]; then
	if [-t 1]; then echo -e "Sorry but this script cannot be run. Those binaries are missing :\n$missing_bin\n\n"; fi;
	exit;
fi


##################################################################################
## TORRENTEXPANDER 
## v0.20
##
## You can use and modify this script to your convenience
## Any suggestion on how to improve this script will be welcome
##
##
## There are various ways to run this script as a daemon :
## - It can be invoked with the command torrentexpander.sh "/Path/to/your/torrent"
## - It can be triggered by the Transmission torrent client
## - You can export torrent="/Path/to/your/torrent" and start torrentexpander.sh
## - If you want Flexget to trigger torrentexpander.sh, have it echo the torrent path
## to a file and start torrentexpander.sh. The third_party_log file will be used 
## as a source file for torrentexpander.sh and the resulting files will then be
## listed in this third_party_log file.
## - You can edit your settings in the torrentexpander_settings.ini file that will
## be created the first time this script is launched. You can also access your 
## settings by starting this script with the command /path/to/torrentexpander.sh -c
##
## If youre running this script manually you ll get a basic GUI that will enable you to
## choose a torrent file or folder and the destination where it should be expanded
## 
##################################################################################

##################################################################################
############################# REQUIRED SOFTWARE ##################################
# unrar
# unrar-nonfree
# unzip
################## SOFTWARE USED BY OPTIONAL FUNCTIONALITIES #####################
## Convert DTS track from MKV files to AC3
# https://github.com/JakeWharton/mkvdts2ac3/blob/master/mkvdts2ac3.sh
# http://www.bunkus.org/videotools/mkvtoolnix/downloads.html
# http://www.videolan.org/developers/libdca.html
# http://aften.sourceforge.net/
## Convert IMG to ISO 
# http://sourceforge.net/projects/ccd2iso/
##################################################################################
############################### END SOFTWARE #####################################

##################################################################################
################################ USER VARIABLES ##################################
########################### These variables are required #########################
################# On 1st run they will be stored in an ini file###################
## The destination folder is where files will be extracted
## I recommend using a different folder from the one where your torrents are located
## A sub directory of your torrents directory is fine though.
## If you really want to extract your torrents in-place and delete the
## original torrent, switch destructive_mode to yes
destination_folder="/shares/Public"
destructive_mode="no"
################################ Software paths ##################################
################# Please check if these variables are correct ####################
unrar_bin="/opt/bin/unrar"
unzip_bin="/opt/bin/unzip"
wget_curl="/opt/bin/wget"
ccd2iso_bin="/usr/bin/ccd2iso"
mkvdts2ac3_bin="/path/to/mkvdts2ac3.sh"
##################### Supported file extensions - Comma separated ################
########### You must have at least one extension enabled in each field ###########
############### DON T ADD RAR OR ZIP EXTENSIONS IN THESE FIELDS ##################
supported_extensions="avi,mkv,divx,mp4,ts,iso,img,mp3,m4a,wav,srt,idx,sub,dvd"
tv_show_extensions="avi,mkv,divx,mp4,srt,idx,sub"
movies_extensions="avi,mkv,divx,mp4,ts,iso,img,srt,idx,sub"
music_extensions="mp3,m4a,wav"
##################### Movies detection patterns - Comma separated ################
############# You must have at least one pattern enabled in each field ###########
# movies_detect_patterns and movies_detect_patterns_pt_2 are the same - only splitted
# scene patterns is used for scenes that add their name at the beginning of the file name
movies_detect_patterns="HDTV,DVDRip,BDRip,BRRip,DVDR,576p,720p,1080p,HD1080p"
movies_detect_patterns_pt_2="TS,PPVrip,TVRip,DVDSCR,R5,Workprint,SCR,Screener,HDRip,DVDScreener"
other_movies_patterns="pdtv,hdtv,xvid,webrip,web-dl,readnfo,ntsc,pal,ws,uncut,unrated,internal,480p,festival,bluray,extended,italian,dubbed,collection,season,nlsubs,spanish,divx,x264,hdtvrip,xxx,custom[. _-].*[. _-]subs,[^].*[. _-]subs,plsub,subtit,tsxvid,plsubbed,subbed,multisubs,multi-subs,retail,telesync,telecine,dvb,swesub,vostfr,3d,sbs"
scene_patterns="\[[. _-]*www[. _-].*[. _-].*[. _-]*\],aaf,dvdriptorrents,skidrow,klaxxon,axxo,vomit,dita,omifast,extratorrent,2lions,fxm,duqa,newartriot,nhanc3,ddc,keltz,fqm,eztv,limited,real[. _-]proper,proper,repack,resync,syncfix,rerip,theatrical.cut,remastered"
audio_quality_patterns="AC3,DTS,LiNE,CAM AUDIO,MD,LD,Studio Audio"
####################### Optional functionalities variables #######################
#################### Set these variables to "no" to disable ######################
## Fix numbering for TV Shows - Switch variable to "yes" to enable
tv_shows_fix_numbering="yes"
## Cleanup Filenames - Switch variable to "yes" to enable
## 3 different schemas - type_1 = Movie (year).ext - type_2 = Movie Year (video_quality).ext - type_3 = Movie Year (audio_quality-video_quality).ext
clean_up_filenames="yes"
movies_rename_schema="type_1"
## Keep a dummy video file with the original filename for subtitles retrieval
## A torrentexpander_subtitles_dir directory will be created in the same directory as the script
## Fetch subtitles for files in this directory and on next run, torrentexpander will try to move them
## In the same directory as your movies
subtitles_handling="no"
## Repack handling - Switch variable to "yes" to enable
## Only useful if you want to be able to recognize repacks
repack_handling="no"
## Create Wii Cuesheet - Switch variable to "yes" to enable
## Will generate a CloneCD cuesheet for Wii backups
wii_post="no"
## Convert img to iso - Switch variable to "yes" to enable
## Will use CCD2ISO to convert .img disk images to .iso
img_post="no"
## Copy or move TV Shows to a specific folder - choose action (copy / move)
## and add path to enable.
## Using tv_shows_post_path_mode, series files can also be sorted by /Series/Episode (s)
## or /Series/Season X/Episode (ss) or /Series/Season XX/Episode (sss)
tv_shows_post="no"
tv_shows_post_path="no"
tv_shows_post_path_mode="no"
## Copy or move movies to a specific folder - choose action (copy / move)
## and add path to enable.
## You can also force folder creation for single file movies by setting force_single_file_movies_folder to yes
movies_post="no"
movies_post_path="no"
force_single_file_movies_folder="no"
## Copy or move music to a specific folder - choose action (copy / move)
## and add path to enable
music_post="no"
music_post_path="no"
## IMDB Integration - Mainly for NetworkedMediaTank
## Torrentexpander can generate a .nfo with imdb URL, dowonload a poster and download a fanart
## Id like to thank Loginbug for suggesting these imdb features and providing huge chunks of code
imdb_poster="no"
# Poster format could be: normal, large, small or full
imdb_poster_format="normal"
imdb_nfo="no"
imdb_fanart="no"
# Fanart format could be: thumb, poster, w1280, original
imdb_fanart_format="w1280"
# Disable NMJ scan it IMDB lookup fails
disable_nmj_scan="no"
## Convert DTS track from MKV files to AC3 - Check mkvdts2ac3.sh path and switch variable to "yes" to enable
## The DTS track will be kept and the AC3 track will be added
dts_post="no"
## Edit files and folders permissions - If you dont know what that means set it all to "no"
## If you don t want or can t use sudo, these features will be deprecated
user_perm_post="no"
group_perm_post="no"
files_perm_post="no"
folder_perm_post="no"
edit_perm_as_sudo="no"
## Use a source / resulting files log shared with a third party app - Add path to enable
## Take a look at the wiki to learn more about it
third_party_log="no"
## Reset timestamp (mtime)
reset_timestamp="no"
## Debug mode (only used in a few routines) - If enabled, it will be named torrentexpander_debug.log
## and stored in the same directory as the script
debug_mode="no"
## Auto Update script with latest svn release
## values can be "no", "daily" or "weekly"
auto_update_script="no"
## In destructive_mode, torrentexpander can pause then remove torrent and data from your transmission torrent client
remove_torrent_from_client="no"
torrent_daemon_bin="/opt/bin/transmission-remote"
torrent_daemon_login=""
torrent_daemon_password=""
torrent_daemon_port="9091"
## Run Script - Will be run once torrentexpander is done
## You can input the path to a script of your choice or just type the name of a binary available in your PATH
## 3 types of script can be run by torrentexpander :
## - all_files_script sends every processed file to the script
## -> set any variable to file_path to send path to your script as $1, $2, $3, $4 or $5
## -> set any variable to name_without_extension to send filename without extension to your script as $1, $2, $3, $4 or $5
## -> set any variable to name_with_extension to send filename with extension to your script as $1, $2, $3, $4 or $5
## -> set any variable to imdb_title to send IMDB title to your script as $1, $2, $3, $4 or $5
## -> set any variable to imdb_id to send IMDB ID to your script as $1, $2, $3, $4 or $5
## -> set any variable to imdb_url to send IMDB URL to your script as $1, $2, $3, $4 or $5
## -> set any variable to imdb_poster_url to send IMDB Poster URL to your script as $1, $2, $3, $4 or $5
## -> set any variable to tmdb_fanart_url to send TMDB Fanart URL to your script as $1, $2, $3, $4 or $5
## - processed_torrent_script sends only the resulting file or directory to the script
## -> post tasks will then switch from copy to move mode
## -> set any variable to file_path to send path to your script as $1, $2, $3, $4 or $5
## -> set any variable to name_without_extension to send filename without extension to your script as $1, $2, $3, $4 or $5
## -> set any variable to name_with_extension to send filename with extension to your script as $1, $2, $3, $4 or $5
## -> set any variable to imdb_title to send IMDB title to your script as $1, $2, $3, $4 or $5
## -> set any variable to imdb_id to send IMDB ID to your script as $1, $2, $3, $4 or $5
## -> set any variable to imdb_url to send IMDB URL to your script as $1, $2, $3, $4 or $5
## -> set any variable to imdb_poster_url to send IMDB Poster URL to your script as $1, $2, $3, $4 or $5
## -> set any variable to tmdb_fanart_url to send TMDB Fanart URL to your script as $1, $2, $3, $4 or $5
## - post_run_script only triggers a script without sending any variable
###
all_files_script_enabled="no"
all_files_script=""
all_files_script_variable_1=""
all_files_script_variable_2=""
all_files_script_variable_3=""
all_files_script_variable_4=""
all_files_script_variable_5=""
###
processed_torrent_script_enabled="no"
processed_torrent_script=""
processed_torrent_script_variable_1=""
processed_torrent_script_variable_2=""
processed_torrent_script_variable_3=""
processed_torrent_script_variable_4=""
processed_torrent_script_variable_5=""
###
post_run_script_enabled="no"
post_run_script=""
###
############################ END USER VARIABLES ##################################
##################################################################################

Wow, that’s a lot of info and great research; awesome as usual nfo!

Have you tried it with zip and rar? And does it unpack them to the subfolders inside "extracted? Also, is there some tweaking needed to be done?

If it replaces the previous method, is it possible to uninstall the unrar & unzip previously installed on the guide?

Thanks!

Yes it works perfect with zip and rar. It unpacks them to /shares/Public/folder named after archive

This can be easily changed by changing this line in the script

destination_folder=“/shares/Public”

You will need to create the folder in the share ahead of time as the script won’t create it for you

so for example if you change the path to

destination_folder="/shares/Public/Extracted

you would need to create a folder called Extracted in your Public folder

To use the new script, simply replace /var/lib/scripts/posttorrent.sh with the script in the download and overwrite it when prompted.

I basically just setup the extract folder and the paths to unzip and unrar.  You can have the script put movies in a movie folder, music in a music folder etc as well by configuring the script to do so. You can also set the script up to remame files such as tv series into a nice neat season episode format etc

1 Like

Thanks! It’s a pretty amazing and complete app from what I’ve read from your posts. I’ll set it up between today and tomorrow and I’ll report back!

Two things left that come to mind:

1) Is it possible to undo (uninstall) the ipkg install unrar unzip of the previous guide, to leave the system as clean as possible?

2) Do you know if this can be used for pyLoad too? If so, then IT WOULD BE AWESOME! , as both download apps would be handled by the same extractor. Also, because with the native pyLoad “Extracter”, I’ve tried and it didn’t work with .zip (only .rar, although it should work with both)

ipkg remove unzip unrar

Then just point the script to the stock unzip and unrar binaries wherever they are located by changing these lines in the new script

unrar_bin=“/opt/bin/unrar”

unzip_bin=“/opt/bin/unzip”

I don’t think this script can be used for pyLoad

Is there any benefit of the stock unzip/unrar vs the one we installed before? And does the remove command cleanly uninstall them or does it leave any dependency/stuff behind? I ask because I’m pretty OCD about everything; it it’s not “clean enough”, I will have to restore the images again! :stuck_out_tongue:

Thanks nfo

Yeah it will remove them cleanly, but are you sure the stock OS has these binaries? I have never looked