commit 94590694e3e634ce005ef07b897795c0c029b815
parent 2eb19a39ff306b2092b5f144b4267edc1f5223fb
Author: Christoph Lohmann <20h@r-36.net>
Date: Thu, 2 Feb 2012 17:20:56 +0100
Add podcast download support.
Diffstat:
2 files changed, 54 insertions(+), 9 deletions(-)
diff --git a/bin/rpdownload b/bin/rpdownload
@@ -1,7 +1,16 @@
#!/bin/sh
-downloader="wget -c"
-downloaddir="$HOME/Downloads"
+if [ -z "$DOWNLOADER" ];
+then
+ echo "\$DOWNLOADER should be set for downloading content."
+ exit 1
+fi
+
+if [ -z "$DOWNLOADDIR" ];
+then
+ echo "\$DOWNLOADDIR should be set for downloading content."
+ exit 1
+fi
if [ $# -lt 2 ];
then
@@ -12,10 +21,10 @@ fi
msgid="$*"
url=`rpview $msgid | awk '/URL:/ {print $2}' | tr -d '\r'`
-cd $downloaddir
+cd $DOWNLOADDIR
for i in $url
do
echo $i
- $downloader "$i"
+ $DOWNLOADER "$i"
done
diff --git a/bin/rppodplay b/bin/rppodplay
@@ -1,9 +1,34 @@
#!/bin/sh
-if [ $# -lt 1 ];
-then
- echo "usage: `basename $0` msgid"
+usage() {
+ echo "usage: `basename $1` [-d] msgid"
exit 1
+}
+
+dodownload=0
+
+while getopts "dh" opt;
+do
+ case $opt in
+ d)
+ dodownload=1
+ ;;
+ *)
+ usage $0
+ exit 1
+ ;;
+ esac
+done
+shift `expr $OPTIND - 1`
+
+if [ $dodownload -gt 0 ];
+then
+ if [ -z "$DOWNLOADER" ] || [ -z "$DOWNLOADDIR" ];
+ then
+ echo "You need to set \$DOWNLOADER and \$DOWNLOADDIR" \
+ " for downloading the podcast."
+ exit 1
+ fi
fi
if [ -z "$AUDIOPLAYER" ];
@@ -11,7 +36,7 @@ then
if [ -z "$MEDIAPLAYER" ];
then
echo "\$MEDIAPLAYER or \$AUDIOPLAYER should be set for" \
- "playing the media."
+ " playing the media."
exit 1
fi
player="$MEDIAPLAYER"
@@ -25,6 +50,17 @@ url=`rpview $msgid | awk '/Enclosure:/ {print $2}' | tr -d '\r'`
for i in $url
do
echo $i
- $player "$i"
+ if [ $dodownload -gt 0 ];
+ then
+ cd $DOWNLOADDIR
+ $DOWNLOADER "$i"
+ else
+ $player "$i"
+ fi
done
+if [ $dodownload -gt 0 ];
+then
+ echo "The files have been downloaded to $DOWNLOADDIR."
+fi
+