[linux-elitists] Planet and podcasts

Don Marti dmarti@zgp.org
Mon Aug 1 16:41:41 PDT 2005


So, in support of the theory that any IT project in
the world can be done really half-assed in one page of
shell or Perl, here's a quick-and-dirty shell script
to snag all the audio enclosures from a Planet cache.


#!/bin/bash

# snarf-podcasts: grab enclosures for the RSS feeds you get with
# Planet (planetplanet.org)

# By: Don Marti <dmarti@zgp.org>

# where your Planet keeps its cache
RSS_DIR=$HOME/Planet/cache

# where to put the enclosures
ENCLOSURE_DIR=$HOME/Podcasts

cd $ENCLOSURE_DIR || exit 1

for r in $(find $RSS_DIR) ; do
    if $(file -b $r | grep -q XML) ; then
        for e in $(xml2 < $r 2>/dev/null | \
                   grep '/rss/channel/item/enclosure/@url=' | \
                   cut -d = -f 2 ) ; do
            type=$(w3m -dump_head $e | \
                    grep ^Content-Type | cut -d ' ' -f 2)
            # TODO: support torrents
            if [ $type = 'application/ogg' ] || \
               $(echo $type | grep -q audio) ; then
                wget --mirror $e
            fi
        done
    fi
done

# end script


-- 
Don Marti
http://zgp.org/~dmarti/
dmarti@zgp.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://allium.zgp.org/pipermail/linux-elitists/attachments/20050801/295fdc31/attachment.pgp 


More information about the linux-elitists mailing list