|
@@ -5,5 +5,43 @@ if ! ~/bin/video/isMediaMounted; then
|
|
|
exit 0
|
|
exit 0
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
|
|
+# Allow easy cancelation
|
|
|
|
|
+control_c() {
|
|
|
|
|
+ echo "Canceled" 1>&2
|
|
|
|
|
+ exit 1
|
|
|
|
|
+}
|
|
|
|
|
+trap control_c SIGINT
|
|
|
|
|
+trap control_c SIGTERM
|
|
|
|
|
+
|
|
|
|
|
+# Provide a method to skip ahead in the alphabetical list of series
|
|
|
|
|
+REGEX=""
|
|
|
|
|
+if [ -n "${1}" ]; then
|
|
|
|
|
+ if ! echo "${1}" | grep -qi '^[a-z]$'; then
|
|
|
|
|
+ echo "Usage: `basename "${0}"` [skip_to_char]" 1>&2
|
|
|
|
|
+ exit 1
|
|
|
|
|
+ fi
|
|
|
|
|
+ REGEX="`echo "${1}" | tr 'A-Z' 'a-z'`"
|
|
|
|
|
+ REGEX='^[0-9a-'"${REGEX}"']'
|
|
|
|
|
+fi
|
|
|
|
|
+
|
|
|
# Run a search for each monitored series
|
|
# Run a search for each monitored series
|
|
|
-~/bin/video/torrentMonitored.pl null | xargs -n 1 -0 ~/bin/video/findTorrent.pl
|
|
|
|
|
|
|
+while read -d $'\0' SERIES ; do
|
|
|
|
|
+
|
|
|
|
|
+ # Skip matching series
|
|
|
|
|
+ if [ -n "${REGEX}" ]; then
|
|
|
|
|
+ TITLE="`dirname "${SERIES}"`"
|
|
|
|
|
+ TITLE="`basename "${TITLE}"`"
|
|
|
|
|
+ if echo "${TITLE}" | grep -qi "${REGEX}"; then
|
|
|
|
|
+ continue
|
|
|
|
|
+ fi
|
|
|
|
|
+ fi
|
|
|
|
|
+
|
|
|
|
|
+ # Actual search, with timeout to ensure we don't get stuck
|
|
|
|
|
+ ~/bin/video/timeout -t 300 | \
|
|
|
|
|
+ ~/bin/video/findTorrent.pl "${SERIES}" | ~/bin/download
|
|
|
|
|
+
|
|
|
|
|
+# Loop on the null-delimited list of monitored series/seasons
|
|
|
|
|
+done < <(~/bin/video/torrentMonitored.pl null)
|
|
|
|
|
+
|
|
|
|
|
+# Cleanup
|
|
|
|
|
+exit 0
|