Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Easier is relative' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Easier is relative
Authored by: WAW401 on Jul 26, '02 12:41:17PM

I loved this hint because I don't catch NPR's Morning Edition anymore. But going to npr.org I realized that the equivalent ".smil" file was for Monday's program (this was Thurdsay!). The most current ME file has the date as part of it, so any automation would require the current date to be substituted. I decided this would be a good time to write my first shell script, so be kind :-). This might be applicable for other NPR files or other items that are date sensitive. Here is my double-clickable "PlayMorningEdition.command" script:

#!/bin/sh

######################
#
# This will calculate and format todays date in the format YYYYMMDD,
# download the NPR Morning Edition file to the desktop,
# then open it (presumably in RealOne Player)
#
######################

theDate=`date`
theYear=`echo $theDate | awk '{ print $6 }'`
theMonth=`echo $theDate | awk '{ print $2 }'`
theDay=`echo $theDate | awk '{ print $3 }'`

case $theMonth in
"Jan" ) theMonth="01";;
"Feb" ) theMonth="02";;
"Mar" ) theMonth="03";;
"Apr" ) theMonth="04";;
"May" ) theMonth="05";;
"Jun" ) theMonth="06";;
"Jul" ) theMonth="07";;
"Aug" ) theMonth="08";;
"Sep" ) theMonth="09";;
"Oct" ) theMonth="10";;
"Nov" ) theMonth="11";;
"Dec" ) theMonth="12";;
esac
theDate=$theYear$theMonth$theDay

curl http://www.npr.org/ramfiles/me/$theDate.me.ram > ~/Desktop/$theDate.me.ram
open ~/Desktop/$theDate.me.ram



[ Reply to This | # ]
Easier is relative
Authored by: WAW401 on Aug 01, '02 12:07:16PM

Update to script - it doesn't handle a single digit day (i.e. august 1st). So you'll have to add an evaluation if the day variable is 1 character, add a zero before it. Just noticed this, but haven't fixed yet myself.



[ Reply to This | # ]
Easier is relative
Authored by: meneermoot on Aug 04, '04 07:35:34AM

Actually you can simplify a little and get the 0 before the day and month by using and inlining the date command.

<code>
curl http://www.npr.org/ramfiles/me/`date +%Y%m%d`.me.ram > ~/Desktop/`date +%Y%m%d`.me.ram
open ~/Desktop/`date +%Y%m%d`.me.ram
</code>

Note that those are backticks and not apostrophes.

Cheers
Mark



[ Reply to This | # ]