Эх сурвалжийг харах

Extract the sections parser.
Use the new sections parser in emptyTrash.sh

Update scan.sh to scan each section individually. Apparently options like --refresh are not applied to correctly to all sections when no section is specified.

Zachary Kotlarek 13 жил өмнө
parent
commit
0eb82f5ca1
2 өөрчлөгдсөн 14 нэмэгдсэн , 10 устгасан
  1. 1 5
      pms/emptyTrash.sh
  2. 13 5
      pms/scan.sh

+ 1 - 5
pms/emptyTrash.sh

@@ -10,11 +10,7 @@ if ~/bin/video/pms/isScanning.sh; then
 	exit 0
 fi
 
-# Read the list of section numbers
-SECTIONS="`curl --silent 'http://localhost:32400/library/sections' | \
-	grep '<Directory ' | sed 's%^.* key="\([0-9]*\)".*$%\1%'`"
-
 # Empty the trash for each section
-for i in $SECTIONS; do
+for i in `~/bin/video/pms/sections.sh`; do
 	curl --silent --upload-file /dev/null "http://localhost:32400/library/sections/${i}/emptyTrash"
 done

+ 13 - 5
pms/scan.sh

@@ -1,5 +1,7 @@
 #!/bin/bash
 
+SCAN_CMD="/Applications/Zach/Media/Plex Media Server.app/Contents/MacOS/Plex Media Scanner"
+
 # Bail if the media share isn't mounted
 if ! ~/bin/video/isMediaMounted; then
 	exit 0
@@ -10,18 +12,24 @@ if ~/bin/video/pms/isScanning.sh; then
 	exit 0
 fi
 
-# Scan, appending any parameters passed to us
-'/Applications/Zach/Media/Plex Media Server.app/Contents/MacOS/Plex Media Scanner' --scan ${@}
+# Scan each section individually if no section number is provided
+if echo "${@}" | grep -q -- '--section'; then
+	"${SCAN_CMD}" --scan ${@}
+else
+	for i in `~/bin/video/pms/sections.sh`; do
+		"${SCAN_CMD}" --section "${i}" --scan ${@}
+	done
+fi
 
 # Check the return; kill the PMS if things did not go well
 if [ $? -ne 0 ]; then
 	~/bin/video/pms/killPMS.sh
 fi
 
+# Clean the trash, if conditions are safe
+~/bin/video/pms/emptyTrash.sh
+
 # Force an optimization after deep scans
 if echo "${@}" | grep -q -- '--deep'; then
 	~/bin/video/pms/optimize.sh
 fi
-
-# Clean the trash, if conditions are safe
-~/bin/video/pms/emptyTrash.sh