Kaynağa Gözat

Copy metadata files, if present. Preserve them until the folder is otherwise empty

Zachary Kotlarek 11 yıl önce
ebeveyn
işleme
e58527cb50
2 değiştirilmiş dosya ile 32 ekleme ve 1 silme
  1. 16 1
      sync/sync.sh
  2. 16 0
      sync/syncUnwatched.sh

+ 16 - 1
sync/sync.sh

@@ -89,7 +89,22 @@ for infile in $FILES; do
 	# Don't get hung up on file extensions
 	nobase="`echo "${infile}" | sed 's%\....$%%'`"
 
-	# Skip files that exist
+	# Copy NFO and other metadata, if present
+	OLD_IFS="${IFS}"
+	IFS=" "
+	for meta in "${nobase}.nfo" tvshow.nfo poster.jpg poster.png; do
+		if [ -e "${IN_DIR}/${meta}" ]; then
+			if [ ! -e "${OUT_DIR}/${meta}" ]; then
+				if [ $DEBUG -gt 0 ]; then
+					echo "Copying: ${IN_DIR}/${meta}" 1>&2
+				fi
+				cp "${IN_DIR}/${meta}" "${OUT_DIR}/"
+			fi
+		fi
+	done
+	IFS="${OLD_IFS}"
+
+	# Skip video files that exist
 	if ls "${OUT_DIR}/${nobase}".* >/dev/null 2>&1; then
 		if [ $DEBUG -gt 0 ]; then
 			echo "Exists: ${SUB_DIR}/${infile}" 1>&2

+ 16 - 0
sync/syncUnwatched.sh

@@ -127,6 +127,22 @@ for i in $OLD_FILES; do
 		continue
 	fi
 
+	# Skip tvshow.nfo and poster.* if other files exist in the directory
+	NOEXT="`basename "${FILE}" | sed 's%\....$%%'`"
+	if [ "${NOEXT}" == "tvshow" ] || [ "${NOEXT}" == "poster" ]; then
+		DIRNAME="`dirname "${FILE}"`"
+		if ls "${DIRNAME}" | grep -v 'tvshow\.nfo$' | grep -qv 'poster\....$'; then
+			if [ $DEBUG -gt 0 ]; then
+				echo "Skipping active metadata file: ${FILE}" 1>&2
+			fi
+			continue
+		else
+			if [ $DEBUG -gt 0 ]; then
+				echo "Inactive metadata file: ${FILE}" 1>&2
+			fi
+		fi
+	fi
+
 	# Skip files under 1H old to avoid churn and provide a no-delete signal for other conditions (e.g. filename encoding)
 	STAT="`stat -f '%m' "${FILE}" 2>/dev/null`"
 	if [ -z "${STAT}" ]; then