summaryrefslogtreecommitdiff
path: root/software/scripts/fetchdnow.sh
diff options
context:
space:
mode:
Diffstat (limited to 'software/scripts/fetchdnow.sh')
-rw-r--r--software/scripts/fetchdnow.sh93
1 files changed, 93 insertions, 0 deletions
diff --git a/software/scripts/fetchdnow.sh b/software/scripts/fetchdnow.sh
new file mode 100644
index 0000000..990a2dc
--- /dev/null
+++ b/software/scripts/fetchdnow.sh
@@ -0,0 +1,93 @@
+#!/bin/bash
+# Copyright 2008 Nick White
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# See <http://www.gnu.org/licenses/> for a copy of the GNU General
+# Public License.
+
+function usage
+{
+ echo "Usage: dnow [-c codec] [-f outfile]"
+ echo " codec may be ogg, flac or mp3"
+}
+
+# Get Dates #
+year=$(date +%Y)
+month=$(date +%m)
+monthname=$(date +%B)
+day=$(date +%d)
+dayunpadded=$(date +%-e)
+
+# Set Defaults #
+title="Democracy Now!"
+titleshort="Democracy_Now"
+codec="ogg"
+podcastdir=~/feeds
+
+while [ "$1" != "" ]; do
+ case $1 in
+ -c | --codec ) shift
+ codec=$1
+ ;;
+ -f | --file ) shift
+ outfile=$1
+ ;;
+ -h | --help ) usage
+ exit
+ ;;
+ * ) usage
+ exit
+ ;;
+ esac
+ shift
+done
+
+downfile=dn$year-$month$day-1.$codec
+
+url=http://www.archive.org/download/dn$year-$month$day/$downfile
+
+downdir=$podcastdir/$year-$month-$dayunpadded
+
+# if the file already exists, exit
+if [ -f "$downdir/$downfile" ]; then
+ echo "download file already exists"
+ exit 1
+fi
+
+echo "url is $url"
+
+mkdir -p "$downdir"
+wget --quiet --directory-prefix="$downdir" $url
+
+# check that it's audio data, not a 404, & if necessary delete
+if [ -f "$downdir/404.php" ]; then
+ find "$downdir" -iname "404.php*" -type f -exec rm -f {} \;
+ echo "404, sorry"
+ exit 1
+elif [ -z "$(file $downdir/$downfile|grep audio)" ]; then
+ rm "$downdir/$downfile"
+ echo "download wasn't audio"
+ exit 1
+fi
+
+# tag the newly downloaded file
+vorbiscomment -w "$downdir/$downfile" -t "ARTIST=$title" -t "TITLE=$day $monthname $year" -t "GENRE=News" -t "DATE=$year"
+
+# create directories and links to integrate with GoldenPod's directory structure
+catdir=$podcastdir/catalogue/$titleshort
+
+mkdir -p "$catdir"
+
+ln -s "$downdir/$downfile" "$podcastdir/catalogue/All/"
+ln -s $downdir/$downfile "$catdir/"
+ln -sf $downdir/$downfile "$catdir/latest.$codec"
+ln -sfn $downdir "$podcastdir/latest"