scan.sh 826 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/bash
  2. SCAN_CMD="/Applications/Zach/Media/Plex Media Server.app/Contents/MacOS/Plex Media Scanner"
  3. # Bail if the media share isn't mounted
  4. if ! ~/bin/video/isMediaMounted; then
  5. exit 0
  6. fi
  7. # Bail if we are already scanning
  8. if ~/bin/video/pms/isScanning.sh; then
  9. exit 0
  10. fi
  11. # Scan each section individually if no section number is provided
  12. if echo "${@}" | grep -q -- '--section'; then
  13. "${SCAN_CMD}" --scan ${@}
  14. else
  15. for i in `~/bin/video/pms/sections.sh`; do
  16. "${SCAN_CMD}" --section "${i}" --scan ${@}
  17. done
  18. fi
  19. # Check the return; kill the PMS if things did not go well
  20. if [ $? -ne 0 ]; then
  21. ~/bin/video/pms/killPMS.sh
  22. fi
  23. # Clean the trash, if conditions are safe
  24. ~/bin/video/pms/emptyTrash.sh
  25. # Force an optimization after deep scans
  26. if echo "${@}" | grep -q -- '--deep'; then
  27. ~/bin/video/pms/optimize.sh
  28. fi