Page 1 of 1

[New Feature] Custom unrar parameters

Posted: 12 Dec 2014, 18:52
by hugbug
To unpack files NZBGet uses external unrar. The executed command looks like this:

Code: Select all

unrar x -y -p- -o+ *.rar /full/path/to/dest/_unpack/
Parameter "-p-" is replaced with "-ppassword" if a password is set for nzb-file.

Option UnrarCmd is used to specify the path to unrar. Now (r1180) the extra switches can be added directly into the option UnrarCmd. NZBGet then add other required parameters (destination path, etc.).

Examples:
  1. Ignore file attributes (permissions) using switch "-ai" (requested in Feature Request: File Extraction to Ignore File Permissions):

    Code: Select all

    /usr/bin/unrar x -ai
    If unrar is in search path it's not necessary to specify the full path. The following will work too:

    Code: Select all

    unrar -ai
  2. Unpack without subdirectories (flatten):

    Code: Select all

    unrar e
  3. Decrease priority of unrar-process:

    Code: Select all

    nice -n 19 unrar
  4. If the path to unrar contain spaces put the path into apostrophes:

    Code: Select all

    'C:\Program Files\WinRar\unrar' -ai
  5. On Windows and Mac OS X the unrar is supplied with NZBGet. Since the path may contain spaces you should use apostrophes as well:

    Code: Select all

    '${AppDir}/unrar' -ai

Re: [New Feature] Custom unrar parameters

Posted: 12 Dec 2014, 19:02
by hugbug
Scripts which use option UnrarCmd to determine path to unrar should be more careful now since the option UnrarCmd cannot be used directly anymore. The following python function parses option UnrarCmd to extract the path to unrar and can be used in your scripts:

Code: Select all

import shlex

# Extract path to unrar from NZBGet's global option "UnrarCmd";
# Since v15 "UnrarCmd" may contain extra parameters passed to unrar;
# We have to strip these parameters because we need only the path to unrar.
# Returns path to unrar executable.
def unrar():
	exe_name = 'unrar.exe' if os.name == 'nt' else 'unrar'
	UnrarCmd = os.environ['NZBOP_UNRARCMD']
	if os.path.isfile(UnrarCmd) and UnrarCmd.lower().endswith(exe_name):
		return UnrarCmd
	args = shlex.split(UnrarCmd)
	for arg in args:
		if arg.lower().endswith(exe_name):
			return arg
	# We were unable to determine the path to unrar;
	# Let's use the exe name with a hope it's in the search path
	return exe_name
Script FakeDetector has been update to correctly work with the custom unrar parameters.

Re: [New Feature] Custom unrar parameters

Posted: 13 Dec 2014, 15:22
by neilt0
This is working nice(ly)! Thanks.

Re: [New Feature] Custom unrar parameters

Posted: 17 Oct 2020, 09:58
by a3gill
In Windows, to decrease priority, I've tried setting UnrarCmd to:

Code: Select all

Start.exe '' /BelowNormal /b 'C:\Program Files\NZBGet\UnRAR.exe' x -y -p- -o+ *.rar .\_unpack\
trying mimic the Linux suggestion

Code: Select all

nice -n 19 unrar
I am getting this error
Unrar: Could not find file Start.exe
Is there some other way I should do this?

Re: [New Feature] Custom unrar parameters

Posted: 18 Oct 2020, 20:13
by hugbug
If it can't find the file you need to specify the full path.
I doubt the unpack started through start.exe will work properly. Form the description of start.exe it creates a separate console meaning nzbget will probably not be able to see the unrar output.