[Hpr] Next HPR_AudioBookClub

Dave Morriss perloid at autistici.org
Mon Mar 23 09:33:40 PDT 2015


On 23/03/15 14:40, Ken Fallon wrote:
> On 2015-03-11 04:07, Patrick Dailey wrote:
>> The next HPR_AudioBookClub will be April 14 8:00PM
>
> I put this one liner together, with the hope that it help you download.
> You will need xmlstarlet installed.
> 
> wget -O - http://startrekcontinuingmission.com/sttcm.xml | xmlstarlet
> sel -T -t -m '/rss/channel/item' -v 'concat(pubDate, "_HPR_",
> enclosure/@url)' -n - | while read episode;do EP_URL=$(echo ${episode} |
> awk -F '_HPR_' '{print $2}'); EP_NAME="sttcm_$(\date --date="$(echo
> ${episode} | awk -F '_HPR_' '{print $1}' )" -u
> +%Y-%m-%d_%H-%M-%SZ)_$(basename ${EP_URL})";  wget -O "${EP_NAME}"
> "${EP_URL}";done
> 
> I deliberately made it so ugly so that the real coders out there would
> get so annoyed that they would contribute a show describing what I did
> wrong and how it could be improved.

That's one impressive collection of commands.

I'm not a real coder, but I turned it into a script and trimmed it down
a bit. It's attached.

I didn't like the ugly file names so I used awk to turn the concatenated
date and URL into a wget command followed by a touch to set the date on
the file and fed the commands to the shell in the loop. Then the files
are ordered by publication date in the directory.

There's no right way.

Back in my first university job in the late 70's we produced a small
quarterly magazine in which we put little quizzes like this. It was fun
to compile and the readers seemed to like them. Stuff like "write the
shortest list of editor commands to turn any file upside down and the
lines back to front".

An idea for a show?

Dave
-------------- next part --------------
#!/usr/bin/env bash

wget -O - http://startrekcontinuingmission.com/sttcm.xml |\
    xmlstarlet sel -T -t -m '/rss/channel/item' -v 'concat(pubDate, "|", enclosure/@url)' -n - |\
    while read episode
    do
	echo "$episode" |\
	    awk -F'|' '{bs = $2; gsub(".*/","",bs); printf "wget %s\ntouch --date=\"%s\" %s\n",$2,$1,bs}' | sh
    done


More information about the Hpr mailing list