Pārlūkot izejas kodu

Helper script for manual use

Zachary Kotlarek 14 gadi atpakaļ
vecāks
revīzija
331485a645
1 mainītis faili ar 36 papildinājumiem un 0 dzēšanām
  1. 36 0
      findTorrent.sh

+ 36 - 0
findTorrent.sh

@@ -0,0 +1,36 @@
+#!/bin/bash
+
+BASE_DIR="/mnt/media/TV"
+
+SERIES="${1}"
+SEASON="${2}"
+
+usage() {
+	echo "Usage: `basename "${0}"` series_name [season]" 1>&2
+	exit 1
+}
+
+# Find the series directory
+if echo "${SERIES}" | grep -q "/"; then
+	SERIES_DIR="${SERIES}"
+else
+	SERIES_DIR="${BASE_DIR}/${SERIES}"
+fi
+if [ ! -d "${SERIES_DIR}" ]; then
+	echo "No such series directory: ${SERIES_DIR}" 1>&2
+	usage
+fi
+
+# Find the season directory -- if no season is provided, use the last season in the series directory
+if [ -z "${SEASON}" ]; then
+	SEASON="`ls "${SERIES_DIR}" | awk '$1 == "Season" && $2 ~ "[0-9]*" {print $2}' | sort -n -r | head -n 1`"
+	SEASON=$(( $SEASON + 0 ))
+fi
+SEASON_DIR="${SERIES_DIR}/Season ${SEASON}"
+if [ ! -d "${SEASON_DIR}" ]; then
+	echo "No such season directory: ${SEASON_DIR}" 1>&2
+	usage
+fi
+
+# Run the standard command, in debug mode
+DEBUG=1 ~/bin/video/findTorrent.pl "${SEASON_DIR}" | download