Advertisement
Guest User

Modified Bashpodder

a guest
Jan 15th, 2012
711
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.70 KB | None | 0 0
  1. #!/bin/bash
  2. # By Linc 10/1/2004
  3. # Find the latest script at http://lincgeek.org/bashpodder
  4. # Revision 1.21 12/04/2008 - Many Contributers!
  5. # If you use this and have made improvements or have comments
  6. # drop me an email at linc dot fessenden at gmail dot com
  7. # and post your changes to the forum at http://lincgeek.org/lincware
  8. # I'd appreciate it!
  9. #
  10. # Last modified 10/08/2010
  11. #
  12. # This a modified version of Bashpodder by Mattias Hermansson.
  13. #
  14. # List of changes:
  15. #  * No playlist is created after download
  16. #  * If no podcasts are downloaded, the datadir is removed
  17. #  * Podcasts prefixed with # in bp.conf are ignored.
  18.  
  19. # Make script crontab friendly:
  20. cd $(dirname $0)
  21.  
  22. # datadir is the directory you want podcasts saved to:
  23. datadir=$(date +%Y-%m-%d)
  24.  
  25. # create datadir if necessary:
  26. mkdir -p $datadir
  27.  
  28. # Delete any temp file:
  29. rm -f temp.log
  30.  
  31. # Read the bp.conf file and wget any url not already in the podcast.log file:
  32. while read podcast
  33. do
  34.     if [ `expr match "$podcast" '[#]*'` = 0 ] # Only check podcasts that don't begin with a #.
  35.     then
  36.         file=$(xsltproc parse_enclosure.xsl $podcast 2> /dev/null || wget -q $podcast -O - | tr '\r' '\n' | tr \' \" | sed -n 's/.*url="\([^"]*\)".*/\1/p')
  37.         for url in $file
  38.         do
  39.             echo $url >> temp.log
  40.             if ! grep "$url" podcast.log > /dev/null
  41.             then
  42.                 wget -t 10 -U BashPodder -c -O $datadir/$(echo "$url" | awk -F'/' {'print $NF'} | awk -F'=' {'print $NF'} | awk -F'?' {'print $1'}) "$url"
  43.             fi
  44.         done
  45.     fi
  46. done < bp.conf
  47.  
  48. # Move dynamically created log file to permanent log file:
  49. cat podcast.log >> temp.log
  50. sort temp.log | uniq > podcast.log
  51. rm temp.log
  52.  
  53. #Remove datadir if it's empty.
  54. if [ ! "$(ls -A $datadir)" ]; then
  55.     rmdir $datadir
  56. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement