findTorrent.sh 586 B

1234567891011121314151617181920212223242526272829
  1. #!/bin/bash
  2. # Parameters
  3. if [ -z "${TIMEOUT}" ]; then
  4. TIMEOUT=600
  5. fi
  6. VIDEO_DIR="${HOME}/bin/video"
  7. # Child parameters
  8. export DEBUG=$(( $DEBUG + 1 ))
  9. export EXCLUDES_FILE="${HOME}/.findTorrent.exclude"
  10. # Find with timeout, pass URLs to downloader
  11. "${VIDEO_DIR}/timeout" -t "${TIMEOUT}" \
  12. "${VIDEO_DIR}/findTorrent.pl" "${1}" | \
  13. "${VIDEO_DIR}/download.sh"
  14. # Check for errors
  15. RET=$?
  16. if [ $RET -ne 0 ]; then
  17. if [ $RET -eq 143 ]; then
  18. echo "Timeout (${TIMEOUT}) searching: ${1}" 1>&2
  19. else
  20. echo "Error (${RET}) searching: ${1}" 1>&2
  21. fi
  22. fi
  23. # Pass status up the chain
  24. exit $RET