(* NPR morning news loader Applescript For Safari and RealOne Player 1 January 2007 Designed for my Airport-enabled Powerbook which reposes in the kitchen. The Mac starts up at a set time in the morning and runs this script at startup. The script loads the morning news program (Morning Edition or Weekend Edition) as well as the All Things Considered page, then proceeds to load the morning program in RealOne Player, and pause it. With a KeySpan USB remote control on the kitchen counter, one hit of the play button starts up the morning's news, regardless of the actual time of day! (Which is kind of odd if it's 5pm.) Script by A. Andrade with code borrowed from dasboy at http://www.macosxhints.com/article.php?story=2003032814375831 and jspivack at http://www.macosxhints.com/article.php?story=20050623164705143 Compile it in Script Editor and set it as a startup item; have the news waiting for you as you sip your coffee. *) -- these are the 'rundown' pages, where the Listen button resides. Script will load the one corresponding to day of week, along with All Things Considered, which occurs every evening. But no need to hit that button anymore, except for ATC. set weekedsat to "http://www.npr.org/templates/rundowns/rundown.php?prgId=7" set weekedsun to "http://www.npr.org/templates/rundowns/rundown.php?prgId=10" set morninged to "http://www.npr.org/templates/rundowns/rundown.php?prgId=3" set allthings to "http://www.npr.org/templates/rundowns/rundown.php?prgId=2" -- Below is an an example of a direct URL that RealOne Player will open. This is the URL for an NPR '.smil' file. Of course, we will customize ours later, taking into account the current date. -- Note that 'getUnderwriting=0' gets rid of the obnoxious sponsor message at show start! -- "http://www.npr.org/templates/dmg/dmg.php?prgCode=WESAT&showDate=30-Dec-2006&segNum=&mediaPref=RM&getUnderwriting=0" -- Prepare date data which will be put into the custom URL. For some reason we need to put current date into a variable to access its components such as day and month. set thedate to current date -- month needs to abbreviated to 3 letters ala 'Dec' set monthfull to month of thedate as string set monthabbrev to (characters 1 thru 3) of monthfull -- set the defaults for today's show -- will be overridden next if not a weekday set todaysshow to morninged set URLprogtitle to "ME" --FYI, All Things Considered would be "ATC" -- override previous if weekend if weekday of thedate as string is "Saturday" then set todaysshow to weekedsat set URLprogtitle to "WESAT" end if if weekday of thedate as string is "Sunday" then set todaysshow to weekedsun set URLprogtitle to "WESUN" -- i think end if --here's our custom URL which RealOne Player will load! set thefinalURL to "http://www.npr.org/templates/dmg/dmg.php?prgCode=" & URLprogtitle & "&showDate=" & day of thedate & "-" & monthabbrev & "-" & year of thedate & "&segNum=&mediaPref=RM&getUnderwriting=0" tell application "Safari" activate --first load All Things Considered page for evening access. if not (exists document 1) then make new document set the URL of document 1 to allthings make new document -- weirdly, 'document 1' consistently refers to the topmost window, so we refer to it twice, the second not overwriting the first. set the URL of document 1 to todaysshow end tell tell application "RealPlayer" activate run open location thefinalURL play delay 6 -- wait 6 secs [customize for your needs and internet speed] pause end tell