Browse Source

Consolidate usage

Zachary Kotlarek 11 năm trước cách đây
mục cha
commit
7958f22cd3
2 tập tin đã thay đổi với 30 bổ sung và 18 xóa
  1. 5 17
      findAllTorrents.sh
  2. 25 1
      findTorrent.sh

+ 5 - 17
findAllTorrents.sh

@@ -42,26 +42,14 @@ while read -d $'\0' SERIES ; do
 		fi
 	fi
 
-	# Actual search, with timeout to ensure we don't get stuck
-	URLS="`"${VIDEO_DIR}/timeout" -t "${TIMEOUT}" "${VIDEO_DIR}/findTorrent.pl" "${SERIES}"`"
-	RET=$?
-	if [ $RET -ne 0 ]; then
-		if [ $RET -eq 143 ]; then
-			echo "Timeout (${TIMEOUT}) searching: ${SERIES}" 1>&2
-		else
-			echo "Error (${RET}) searching: ${SERIES}" 1>&2
-		fi
+	# Search and download
+	DEBUG=1
+	"${VIDEO_DIR}/findTorrent.sh" "${SERIES}" 2>/var/tmp/find.err
+	if [ $? -ne 0 ]; then
+		echo "Skipping: ${SERIES}" 1>&2
 		continue
 	fi
 
-	# Download, if we found anything
-	if [ -n "${URLS}" ]; then
-		if ! echo "${URLS}" | "${VIDEO_DIR}/download.sh"; then
-			echo "Error downloading: ${SERIES}" 1>&2
-			continue
-		fi
-	fi
-
 # Loop on the null-delimited list of monitored series/seasons
 done < <("${VIDEO_DIR}/torrentMonitored.pl" null)
 

+ 25 - 1
findTorrent.sh

@@ -1,3 +1,27 @@
 #!/bin/bash
 
-EXCLUDES_FILE="${HOME}/.findTorrent.exclude" DEBUG=1 ~/bin/video/findTorrent.pl "${1}" | download
+# Parameters
+DEBUG=$(( $DEBUG + 1 ))
+if [ -z "${TIMEOUT}" ]; then
+	TIMEOUT=600
+fi
+VIDEO_DIR="${HOME}/bin/video"
+EXCLUDES_FILE="${HOME}/.findTorrent.exclude"
+
+# Find with timeout, pass URLs to downloader
+"${VIDEO_DIR}/timeout" -t "${TIMEOUT}" \
+	"${VIDEO_DIR}/findTorrent.pl" "${1}" | \
+	"${VIDEO_DIR}/download.sh"
+
+# Check for errors
+RET=$?
+if [ $RET -ne 0 ]; then
+	if [ $RET -eq 143 ]; then
+		echo "Timeout (${TIMEOUT}) searching: ${1}" 1>&2
+	else
+		echo "Error (${RET}) searching: ${1}" 1>&2
+	fi
+fi
+
+# Pass status up the chain
+exit $RET