Kaynağa Gözat

Merge branch 'master' of github.com:profplump/UberZach-Video

Zachary Kotlarek 12 yıl önce
ebeveyn
işleme
cbece14a67
5 değiştirilmiş dosya ile 65 ekleme ve 29 silme
  1. 6 0
      Fetch.pm
  2. 14 23
      README
  3. 1 1
      encode.pl
  4. 43 4
      folderFixup.sh
  5. 1 1
      transmission.pl

+ 6 - 0
Fetch.pm

@@ -605,7 +605,13 @@ sub content() {
 		print STDERR "Fetch::content()\n";
 		print STDERR "Fetch::content()\n";
 	}
 	}
 
 
+	# Extract content (if any)
 	my $data = $self->{'content'};
 	my $data = $self->{'content'};
+	if (!defined($data)) {
+		$data = '';
+	}
+
+	# Standardize line endings
 	$data =~ s/\r\n/\n/;
 	$data =~ s/\r\n/\n/;
 
 
 	# Return an array when requested
 	# Return an array when requested

+ 14 - 23
README

@@ -1,26 +1,24 @@
 UberZach Video Tools
 UberZach Video Tools
-Copyright 2009-2012, Zach Kotlarek <zach@kotlarek.com>
+Copyright 2009-2014, Zach Kotlarek <zach@kotlarek.com>
 ======================================================
 ======================================================
 
 
-The following readme applies primarily to the encode.pl script, formerly released as the Handbrake CLI Helper project. 
-Additional documentation may follow as I have time/interest.
+The following readme applies primarily to the encode.pl script, formerly released as the Handbrake CLI Helper project. Additional documentation may follow as I have time/interest.
 
 
 ======================================================
 ======================================================
 
 
-HandBrake CLI Helper is a fairly simple script intended to assist in automation of HandBrake-based encoding workflows. It is 
-designed to automatically select appropriate HandBrake settings to produce output that:
+Encode.pl is a fairly simple script intended to assist in automation of HandBrake-based encoding workflows. It is designed to automatically select appropriate HandBrake settings to produce output that:
 	Copies all English (or unspecified) audio tracks unmodified
 	Copies all English (or unspecified) audio tracks unmodified
-	Downmixes the first audio track to AAC-2.0 w/Dolby Pro Logic II encoding
-	Copies all subtitle tracks
+	Downmixes the "best" audio track to AAC-2.0 w/Dolby Pro Logic II encoding
+	Copies all subtitle tracks, except languages that are explicitly excluded
 	Includes external SRT files in the same folder and with the same name
 	Includes external SRT files in the same folder and with the same name
 	Autocrops video, but overrides autocrop when it makes obviously wrong choices
 	Autocrops video, but overrides autocrop when it makes obviously wrong choices
 	Invokes the detelecine and decomb filters in the default mode (i.e. auto-detect)
 	Invokes the detelecine and decomb filters in the default mode (i.e. auto-detect)
 
 
-The script can handle both single-title and multi-title video sources, and for multi-title sources can encode all titles or 
-a specific, selected title.
+The script can handle both single-title and multi-title video sources, and for multi-title sources can encode all titles or  a specific, selected title.
 
 
-Both MKV and M4V wrapper formats are supported. M4V is prefered unless DTS audio is selected, in which case only MKV can be 
-used. Use of MKV can be forced by invoking the script with an output file name ending in .mkv
+Both MKV and M4V wrapper formats are supported. M4V is prefered unless DTS audio is selected, in which case only MKV can be used. Use of MKV can be forced by invoking the script with an output file name ending in .mkv
+
+Many of the options above can be selected at runtime via enviromental variables. Read the source for usage -- they are all defined at the top of the script.
 
 
 
 
 #==========================
 #==========================
@@ -32,27 +30,20 @@ Usage is simple:
 
 
 The input file path is obviously required.
 The input file path is obviously required.
 
 
-The output file path can be provided, but a default based on the input file path will be automatically selected if 
-necessary.
+The output file path can be provided, but a default based on the input file path will be automatically selected if necessary.
 
 
-The title number is only useful for multi-title sources, like TS_VIDEO folders or DVD ISOs. If provided the title number 
-should match whatever number HandBrake shows for the title you want to encode. You can also use the title number "main" to 
-select the longest title in the source.
+The title number is only useful for multi-title sources, like TS_VIDEO folders or DVD ISOs. If provided the title number should match whatever number HandBrake shows for the title you want to encode. You can also use the title number "main" to select the longest title in the source.
 
 
 If you want to see what's actually happening, set the DEBUG enviornmental variable to something non-zero, like this:
 If you want to see what's actually happening, set the DEBUG enviornmental variable to something non-zero, like this:
 	DEBUG=1 encode.pl <input_file>
 	DEBUG=1 encode.pl <input_file>
-The script will then provide details about its decisions, and will also copy all output from HandBrake so you can see what 
-it is doing. By default the script suppresses most HandBrake output to support use in automation systems.
+The script will then provide details about its decisions, and will also copy all output from HandBrake so you can see what it is doing. By default the script suppresses most HandBrake output to support use in automation systems.
 
 
 
 
 #==========================
 #==========================
 # Configuration
 # Configuration
 #==========================
 #==========================
 
 
-You will need to tell the script where the HandBrakeCLI binary lives. Do that by adjusting the HB_EXEC parameter at the top 
-of the script. The default is:
+You will need to tell the script where the HandBrakeCLI binary lives. Do that by adjusting the HB_EXEC parameter at the top of the script. The default is:
 	~/bin/video/HandBrakeCLI
 	~/bin/video/HandBrakeCLI
 
 
-You can adjust a number of other parameters, including the default parameter string for HandBrake, the video encoding 
-quality for both HD and SD sources, the cutoff point for what is considered an HD source, the prefered output format, and a 
-of other more technical parameters. If you don't know what they mean you probably don't need to change them.
+You can adjust a number of other parameters, including the default parameter string for HandBrake, the video encoding  quality for both HD and SD sources, the cutoff point for what is considered an HD source, the prefered output format, and a  of other more technical parameters. If you don't know what they mean you probably don't need to change them.

+ 1 - 1
encode.pl

@@ -456,7 +456,7 @@ sub audioOptions($) {
 				$codec = $code;
 				$codec = $code;
 				last;
 				last;
 			} elsif ($code eq 'OTHER') {
 			} elsif ($code eq 'OTHER') {
-				if ($codec =~ /MP3/i || $codec =~ /MPEG/i) {
+				if ($codec =~ /MP3/i || $codec =~ /MPEG/i || $codec =~ /MP2/i) {
 					$codec = $code;
 					$codec = $code;
 				} elsif ($codec eq 'dca') {
 				} elsif ($codec eq 'dca') {
 					print STDERR 'Found incompatible audio (' . $track->{'description'} . ')  in track ' . $track->{'index'} . "\n";
 					print STDERR 'Found incompatible audio (' . $track->{'description'} . ')  in track ' . $track->{'index'} . "\n";

+ 43 - 4
folderFixup.sh

@@ -3,6 +3,12 @@
 # Parameters
 # Parameters
 inFolder="`~/bin/video/mediaPath`/TV"
 inFolder="`~/bin/video/mediaPath`/TV"
 
 
+# Debug
+if [ -n "${DEBUG}" ] && [ $DEBUG -gt 0 ]; then
+	echo -n "Starting `basename "${0}"`: "
+	date
+fi
+
 # Command line
 # Command line
 if [ -n "${1}" ]; then
 if [ -n "${1}" ]; then
 	inFolder="${1}"
 	inFolder="${1}"
@@ -12,20 +18,43 @@ if [ ! -e "${inFolder}" ]; then
 	exit 1
 	exit 1
 fi
 fi
 
 
+# Ensure we have a valid TMPDIR
+if [ ! -d "${TMPDIR}" ]; then
+        TMPDIR="`getconf DARWIN_USER_TEMP_DIR 2>/dev/null`"
+        if [ ! -d "${TMPDIR}" ]; then
+                TMPDIR="/var/tmp"
+        fi
+        if [ ! -d "${TMPDIR}" ]; then
+                TMPDIR="/tmp"
+        fi
+fi
+
 # Bail if we're already running
 # Bail if we're already running
-me="`basename "${0}"`"
-if [ `ps auwx | grep -v grep | grep "${me}" | wc -l` -gt 2 ]; then
-	exit 0
+LOCK="${TMPDIR}/folderFixup.run"
+touch "${LOCK}"
+read MOUNT_PID < "${LOCK}"
+if [ -n "${MOUNT_PID}" ]; then
+	if ps -A -o pid | grep -q "${MOUNT_PID}"; then
+		if [ -n "${DEBUG}" ] && [ $DEBUG -gt 0 ]; then
+			echo 'Already running' 1>&2
+		fi
+		exit 0
+	fi
 fi
 fi
+echo $$ > "${LOCK}"
 
 
 # Bail if the load is high
 # Bail if the load is high
 if ! ~/bin/video/checkLoad.sh; then
 if ! ~/bin/video/checkLoad.sh; then
+	if [ -n "${DEBUG}" ] && [ $DEBUG -gt 0 ]; then
+		echo 'Load too high' 1>&2
+	fi
 	exit 0
 	exit 0
 fi
 fi
 
 
 # Bail if the media share isn't available
 # Bail if the media share isn't available
 if ! ~/bin/video/isMediaMounted; then
 if ! ~/bin/video/isMediaMounted; then
-	exit 0
+	echo 'Media not mounted' 1>&2
+	exit 1
 fi
 fi
 
 
 # Cache output
 # Cache output
@@ -41,3 +70,13 @@ cat "${tmp}" | \
 	grep -v "ERROR: Unexpected Error. (-1401)  on file: " | \
 	grep -v "ERROR: Unexpected Error. (-1401)  on file: " | \
 	grep -v "ERROR: Unexpected Error. (-5000)  on file: " | \
 	grep -v "ERROR: Unexpected Error. (-5000)  on file: " | \
 	grep -v "^ *$"
 	grep -v "^ *$"
+
+# Cleanup
+rm -f "${LOCK}"
+rm -rf "${tmp}"
+
+# Debug
+if [ -n "${DEBUG}" ] && [ $DEBUG -gt 0 ]; then
+	echo -n 'Complete: '
+	date
+fi

+ 1 - 1
transmission.pl

@@ -662,7 +662,7 @@ sub seriesCleanupCore($) {
 
 
 sub seriesCleanup($) {
 sub seriesCleanup($) {
 	my ($name) = @_;
 	my ($name) = @_;
-	$name =~ s/\s*\(?US\)?\s*$//i;
+	$name =~ s/\s*\(?US\)?\s*$//;
 	$name =~ s/\s*\(?20[01][0-9]\)?\s*$//;
 	$name =~ s/\s*\(?20[01][0-9]\)?\s*$//;
 	return seriesCleanupCore($name);
 	return seriesCleanupCore($name);
 }
 }