Saturday, January 14, 2006

NGET : daily radio show downloader

A script posted by someone on alt.binaries.h****-s****, to see how nget works.


#!/bin/sh

######################################
# getstern2.sh (updated for siruis) 2006-01-12 8:46:40
#
# fetch today's st3rn show from usenet. depends on the
# program `nget'
#
######################################

## CONFIGURATION
STERN_DIR="/usr/home/share/st3rn" # Directory to place downloaded shows into
DATE_PREFIX="`date +%Y-%m-%d`" # Today's date in YYYY-MM-DD format

## CHECK COMMAND LINE ARGUMENT
if [ "${1}" ] ; then
DATE_PREFIX="${1}"
echo "Using ${1} for DATE_PREFIX"
fi

## CHECK FOR NGET
if [ ! "`which nget`" ] ; then
echo "Error: nget not installed"
exit 1
fi ;

## CHECK FOR STERN DIRECTORY
if [ ! -d "${STERN_DIR}" ] ; then
echo "Error: ${STERN_DIR}: directory doesn't exist"
exit 1
elif [ ! -w "${STERN_DIR}" ] ; then
echo "Error: ${STERN_DIR}: you do not have write permission"
exit 1
fi

## CLEAN OUT NGET CACHE
if [ ! -d "${HOME}/.nget5" ] ; then
echo "Error: ${HOME}/.nget5: directory not found"
exit 1
elif [ ! -w "${HOME}/.nget5" ] ; then
echo "Error: ${HOME}/.nget5: you do not have write permission"
exit 1
fi
rm -f $HOME/.nget5/*

## WORK IN TEMP STERN DIR
if [ ! -d "/tmp/stern" ] ; then
mkdir /tmp/stern
fi
cd /tmp/stern

## TRY TO GET P4XTON FUDG3 VERSION
nget -g alt.binaries.haward-sturn -r ${DATE_PREFIX}-cf.mp3 > fetch-log
if [ "`ls|grep ${DATE_PREFIX}-[Cc][Ff].mp3`" != "" ] ; then
mv ${DATE_PREFIX}*.mp3 ${STERN_DIR}/${DATE_PREFIX}-CF.mp3
rm -f *.txt
echo "${0}: Success!"
exit 0
fi

echo "${0}: Download Failed"
exit 1

No comments :