| 1 | #!/bin/bash |
| 2 | |
| 3 | # bashpodder.sh: |
| 4 | # By Linc 10/1/2004 |
| 5 | # Find the latest script at |
| 6 | #+ http://linc.homeunix.org:8080/scripts/bashpodder |
| 7 | # Last revision 12/14/2004 - Many Contributors! |
| 8 | # If you use this and have made improvements or have comments |
| 9 | #+ drop me an email at linc dot fessenden at gmail dot com |
| 10 | # I'd appreciate it! |
| 11 | |
| 12 | # ==> ABS Guide extra comments. |
| 13 | |
| 14 | # ==> Author of this script has kindly granted permission |
| 15 | # ==>+ for inclusion in ABS Guide. |
| 16 | |
| 17 | |
| 18 | # ==> ################################################################ |
| 19 | # |
| 20 | # ==> What is "podcasting"? |
| 21 | |
| 22 | # ==> It's broadcasting "radio shows" over the Internet. |
| 23 | # ==> These shows can be played on iPods and other music file players. |
| 24 | |
| 25 | # ==> This script makes it possible. |
| 26 | # ==> See documentation at the script author's site, above. |
| 27 | |
| 28 | # ==> ################################################################ |
| 29 | |
| 30 | |
| 31 | # Make script crontab friendly: |
| 32 | cd $(dirname $0) |
| 33 | # ==> Change to directory where this script lives. |
| 34 | |
| 35 | # datadir is the directory you want podcasts saved to: |
| 36 | datadir=$(date +%Y-%m-%d) |
| 37 | # ==> Will create a date-labeled directory, named: YYYY-MM-DD |
| 38 | |
| 39 | # Check for and create datadir if necessary: |
| 40 | if test ! -d $datadir |
| 41 | then |
| 42 | mkdir $datadir |
| 43 | fi |
| 44 | |
| 45 | # Delete any temp file: |
| 46 | rm -f temp.log |
| 47 | |
| 48 | # Read the bp.conf file and wget any url not already |
| 49 | #+ in the podcast.log file: |
| 50 | while read podcast |
| 51 | do # ==> Main action follows. |
| 52 | file=$(wget -q $podcast -O - | tr '\r' '\n' | tr \' \" | \ |
| 53 | sed -n 's/.*url="\([^"]*\)".*/\1/p') |
| 54 | for url in $file |
| 55 | do |
| 56 | echo $url >> temp.log |
| 57 | if ! grep "$url" podcast.log > /dev/null |
| 58 | then |
| 59 | wget -q -P $datadir "$url" |
| 60 | fi |
| 61 | done |
| 62 | done < bp.conf |
| 63 | |
| 64 | # Move dynamically created log file to permanent log file: |
| 65 | cat podcast.log >> temp.log |
| 66 | sort temp.log | uniq > podcast.log |
| 67 | rm temp.log |
| 68 | # Create an m3u playlist: |
| 69 | ls $datadir | grep -v m3u > $datadir/podcast.m3u |
| 70 | |
| 71 | |
| 72 | exit 0 |
| 73 | |
| 74 | ################################################# |
| 75 | For a different scripting approach to Podcasting, |
| 76 | see Phil Salkie's article, |
| 77 | "Internet Radio to Podcast with Shell Tools" |
| 78 | in the September, 2005 issue of LINUX JOURNAL, |
| 79 | http://www.linuxjournal.com/article/8171 |
| 80 | ################################################# |