Tuesday, November 27, 2012

auto-download all media from RSS - DefCon20 Talk Videos

a shell utility code for download all media present as enclosures in any RSS

eg. usage to download all slides video of DefCon20
$ ddl-rss-media https://www.defcon.org/podcast/defcon-20-slides.rss

to install it
$ sudo curl -L -o /etc/profile.d/ddl-rss-media.sh https://gist.github.com/4156364#file_gistfile1.sh

#####
## $ ddl-rss-media https://www.defcon.org/podcast/defcon-20-slides.rss
#####
ddl-rss-media(){
# ddl-rss-media RSS_LINK {would download all media enclosed at current dir}
enclosures=`curl -k -s -L $@ | cat | grep enclosure | sed 's/.*enclosure\s*url="//' | sed 's/".*//'`
for url in `echo $enclosures | xargs -L1`;
do
if [ ! -z $url ];
then
filename=`echo $url | sed 's/?.*//' | sed 's/.*\///'`
echo "Downloading $filename..."
wget -c -O $filename $url
fi
done
}
view raw gistfile1.sh hosted with ❤ by GitHub

No comments:

Post a Comment