generate.sh 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/bash
  2. # Build URL and cURL opts
  3. source ~/bin/video/pms/curl.sh
  4. SECTION="${1}"
  5. if [ -z "${SECTION}" ] || [ $SECTION -lt 1 ] || [ $SECTION -gt 100 ]; then
  6. echo "Usage: `basename "${0}"` section_number" 1>&2
  7. exit 1
  8. fi
  9. SERIES="`curl ${CURL_OPTS[@]} "${PMS_URL}/library/sections/${SECTION}/all" | \
  10. grep 'key="/library/metadata/[0-9]*/children"' | \
  11. sed 's%^.*key="\(/library/metadata/[0-9]*/children\)".*$%\1%'`"
  12. IFS=$'\n'
  13. for i in $SERIES; do
  14. SEASONS="`curl ${CURL_OPTS[@]} "${PMS_URL}${i}" | \
  15. grep 'key="/library/metadata/[0-9]*/children"' | \
  16. sed 's%^.*key="\(/library/metadata/[0-9]*/children\)".*$%\1%'`"
  17. IFS=$'\n'
  18. for j in $SEASONS; do
  19. IFS=''
  20. EPISODES="`curl ${CURL_OPTS[@]} "${PMS_URL}${j}" | \
  21. grep '<Video ' | \
  22. sed 's%^.*ratingKey="\([0-9]*\)".*$%\1%'`"
  23. for k in $EPISODES; do
  24. if [ -z "${k}" ] || [ $k -lt 100 ]; then
  25. echo "Bad episode ID: ${k}" 1>&2
  26. continue
  27. fi
  28. '/Applications/Zach/Media/Plex Media Server.app/Contents/MacOS/Plex Media Scanner' \
  29. --generate --item "${k}"
  30. done
  31. done
  32. done
  33. exit 0