|
@@ -1,5 +1,7 @@
|
|
|
#!/bin/bash
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
+SCAN_CMD="/Applications/Zach/Media/Plex Media Server.app/Contents/MacOS/Plex Media Scanner"
|
|
|
|
|
+
|
|
|
# Bail if the media share isn't mounted
|
|
# Bail if the media share isn't mounted
|
|
|
if ! ~/bin/video/isMediaMounted; then
|
|
if ! ~/bin/video/isMediaMounted; then
|
|
|
exit 0
|
|
exit 0
|
|
@@ -10,18 +12,24 @@ if ~/bin/video/pms/isScanning.sh; then
|
|
|
exit 0
|
|
exit 0
|
|
|
fi
|
|
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
|
|
# Check the return; kill the PMS if things did not go well
|
|
|
if [ $? -ne 0 ]; then
|
|
if [ $? -ne 0 ]; then
|
|
|
~/bin/video/pms/killPMS.sh
|
|
~/bin/video/pms/killPMS.sh
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
|
|
+# Clean the trash, if conditions are safe
|
|
|
|
|
+~/bin/video/pms/emptyTrash.sh
|
|
|
|
|
+
|
|
|
# Force an optimization after deep scans
|
|
# Force an optimization after deep scans
|
|
|
if echo "${@}" | grep -q -- '--deep'; then
|
|
if echo "${@}" | grep -q -- '--deep'; then
|
|
|
~/bin/video/pms/optimize.sh
|
|
~/bin/video/pms/optimize.sh
|
|
|
fi
|
|
fi
|
|
|
-
|
|
|
|
|
-# Clean the trash, if conditions are safe
|
|
|
|
|
-~/bin/video/pms/emptyTrash.sh
|
|
|