Look here

Heya!

My name is Uno. I play jazz, latin or rock guitar when I can, I work as an IT sysadmin when I must, but mostly I just goof around with things that I like. On rare occasion I write or link to things.

I’m on Twitter too.

Aaah yeah.

Using Automator and scripting to open a URL in QuickTime Player X on Snow Leopard

So my favourite TV channel has this web TV solution that doesn’t quite work like I want it to on my Mac. I figured I’d make an Automator action to compensate for that. Here is, with Norwegian OS text as an added bonus, the whole shebang (click to enlarge):

Automator screenshot of the action that opens NRK web TV in QuickTime Player

As it is a service in Safari you can assign a keyboard shortcut to speed up the task even further.

The complete Automator action does these things:

  • Gets the source for the current document in Safari with this bit of AppleScript:
on run {input}
  tell application "Safari" to set input to source of document 1
  return input
end run
  • Strips out the actual URL for the video stream through some nifty regexp work in a bash shell:
cat "$@" | grep -o 'http://\w\+\.nrk\.no\/nett\-tv\/asx\.aspx?param=\w\+'
  • Opens the stripped URL in QuickTime Player with a bit of AppleScript again:
on run {input}
    tell application "QuickTime Player"
        activate
        open URL input
    end tell
end run

It’s a bit of a quick and dirty fix, but it works.

(Sorry for the lack of syntax highlighting, and for the fact that the code snippets are wider than the effing Tumblr template I’m currently using but I promise to fix it eventually!)

Feel free to comment if you like it, or if you think you can improve on it. You’re of course free to use the basic idea of it if you wish to, say, open the current YouTube movie in VLC or something. In that case, let me know how it turns out!

The following deserve praise:

  • postlogic on EFNet/#mac1 for help with perl regexp

  • ubajas on EFNet/#linuxhelp for help on converting the perl regexp to something grep would understand without -P and jaargon from the same channel for the -o trick with grep.

  • John Gruber who wrote an article six years ago about getting the source from Safari with AppleScript.

Finally, if you don’t want to do the work yourself AND LEARN SOMETHING, you can download the zipped Automator action here. :-)

UPDATED: If you download the Automator action from the above link, remember to put it in ~/Library/Services and perhaps restart Safari for the changes to take effect.

Comments · Tags: os x automator script

On why you should consider OS X

marco:

You can put visual effect layers on top of Windows or Linux, but it’s just painting a turd. Instead of ordinary frustration and time-wasting, you get pretty frustration and time-wasting. (And that’s subjective — personally, I find Vista’s Aero and the Linux “eye candy” add-ons to be garish, ugly, tacky, and completely missing the point.)

(…)

Use a Mac for 6 months, and you’ll wonder why you ever used anything else.

As a happy Mac user for the last five years, I couldn’t agree more. I’ve used Windows for the last fifteen years. Ten at home, and the last five through my job as an IT advisor. It is good for one thing and one thing only: Testing my patience. I have become a very, very patient man.

Comments · Tags: mac os x reblogged