plex-checkTV 743 B

1234567891011121314151617181920212223
  1. #!/bin/bash
  2. # Path must be the default /Volumes and not /mnt -- Plex stores the former in its DB
  3. TV_PATH="/Volumes/media/TV"
  4. # Get the list of TV files in the library
  5. LIB_TEMP="`mktemp -t 'checkTV.XXXXXXXX'`"
  6. ~/bin/video/plex-files | ~/bin/video/plex-filter | grep "^${TV_PATH}/" | sort -f > "${LIB_TEMP}"
  7. # Bail if we did not find anything
  8. if [ `cat "${LIB_TEMP}" | wc -l` -lt 1 ]; then
  9. exit 1
  10. fi
  11. # Get the list of all files on the disk
  12. DISK_TEMP="`mktemp -t 'checkTV.XXXXXXXX'`"
  13. find "${TV_PATH}" -type f -name '*.m[op4k][4v]' | grep -v '\/\._' | sort -f > "${DISK_TEMP}"
  14. # Compare
  15. diff -i -U 0 "${DISK_TEMP}" "${LIB_TEMP}" | grep -v '^---' | grep -v '^+++' | grep -v '@@' | grep -v '^+'
  16. # Cleanup
  17. rm -rf "${LIB_TEMP}" "${DISK_TEMP}"