-
Notifications
You must be signed in to change notification settings - Fork 37
Useful Recipes
FilipBB edited this page Nov 17, 2016
·
3 revisions
This custom download handler uses wget to download the enclosure and then add it to a playlist.
downloadhandler = greg-wget "{link}" "{fullpath}"
#!/bin/bash
LINK="$1"
FILENAME="$2"
#download the enclosure
/usr/bin/wget --no-verbose --show-progress "$LINK" -O "$FILENAME"
#add the downloaded file to a playlist
echo -e "$FILENAME" \\n >>~/podcasts-$(date +%F).m3u
This custom download handler uses wget to download the enclosure and then convert the file to an mp3 audio file using an appropriate decoder/encoder.
downloadhandler = greg-wget "{link}" "{directory}" {date}-"{filename_title}"
#!/bin/bash
LINK="$1"
DIR="$2"
FILENAME="$3"
TMPFILE="~/enclosure.tmp"
#download the enclosure to a temporary location
/usr/bin/wget --no-verbose --show-progress "$LINK" -O $TMPFILE
#determine the mime type of the enclosure
TYPE=$(file --mime-type -b $TMPFILE |cut -d '/' -f 2)
#use "mediainfo" to determine the type if "file" fails
if [ "$TYPE" = "" ]; then
TYPE=$(mediainfo --Output="Audio;%Format%" $TMPFILE)
fi
case $TYPE in
*mp3*|*mpeg*)
mv -vf "$TMPFILE" "$DIR"/"$FILENAME".mp3
;;
*m4a*)
faad -o - "$TMPFILE"| lame - "$DIR/$FILENAME".mp3
;;
*mp4*)
ffmpeg -i "$TMPFILE" -f mp3 -ab 192000 -vn "$DIR/$FILENAME".mp3
;;
*)
echo -e "\nNot a media file! Detected as: $TYPE\n"
;;
esac
#cleanup
rm -f $TMPFILE