I made a workflow with Apple’s Automator to download each day’s puzzle from the Times’ website and print it out. If you’re in a similar position as I (you have the subscription, Across Lite, and Mac OS X 10.4) then give it a try: Print Crossword.workflow.
The overall workflow is pretty straightforward:
- Start with the New York Times crossword page URL
- Download the page, with proper authentication
- Find the URL to today’s puzzle
- Download today’s puzzle
- Open today’s puzzle
- Print today’s puzzle
While Safari scripting does a fair amount (I was happy it took care of using my NYTimes.com cookie for the authentication), it doesn’t handle #3, which actually surprised me. The task I needed is to get the URL linked to with the words “Today’s Puzzle.” Here’s the script I used:
grep -o "<a href=\"[^\"]*\">Today's Puzzle" $1 | sed -n -e "s|<a href=\"\\([^\"]*\\)\".*|http://select.nytimes.com/premium/xword/\\1|p"Yeah, it’s a bit of a hack but it works. (If anyone has a better line, please leave it in the comments.) The
rm -rf $1
grep
is there to cut down on the data going in to sed
, since sed
will print out the unmatched start of the line (and matching the start with a regexp is too slow).I was impressed with how simple it was to include a shell script in the workflow, given the typing going on. But “Files/Folders” became a path, and the stdout text became “URLs” for the next step. Neat!
Getting Across Lite to print the puzzle was the second tough bit. Across Lite is a reasonable program, but, as is often the case with ported software has no AppleScript support, so I had to fall back on GUI Scripting instead of the standard “print” command. Here’s the code:
Not too much to say here. Three returns to get through the print choices, Page Setup, and Print dialog boxes, and a ten second delay to prevent a crash.
on run {input, parameters}
set xfile to item 1 of input
tell application "Finder"
open xfile
end tell
tell application "Across Lite v2.0"
activate
end tell
tell application "System Events"
tell process "Across Lite v2.0"
click menu item "Print" of menu "File" of menu bar 1
keystroke return
keystroke return
keystroke return
end tell
end tell
tell application "Across Lite v2.0"
delay 10
quit
end tell
tell application "Finder"
delete xfile
end tell
return input
end run
And there you go! I saved this as an iCal plug-in and scheduled it to go off every day at 7AM. Though, to be truthful, I could probably turn it off for Fridays and Saturdays… But now every day when I wake up I have a crossword puzzle to take with me to do on the shuttle.