Playdar as an OpenURL resolver?


While talking and (minimally) hacking with Playdar people at the Hackspace event last night, I was thinking about using OpenURL/COinS in HTML as an alternative to hAudio or RDFa for describing an audio object that could be resolved.

At its heart, OpenURL is a set of key/value pairs that describe a resource. When strung together, these make the "query string" part of a URL, differing from a full URL in that there's no protocol or domain prefix - so no defined method of resolution - and also no requirement for an identifier - which means resolvers can do fuzzy matching.

I never registered the set of OpenURL attributes that I put together for minimally describing an audio recording, but this seems like a good time to experiment with it...

Starting with an audio object with metadata that can be represented in JSON like this:

  type: "track",
  artist: "...And You Will Know Us By The Trail Of Dead",
  atitle: "Century of Self", // album title
  ttitle: "Bells of Creation", // track title

Join all the key/value pairs (and a couple of boilerplate values) together into a query string (ContextObject):

ctx_ver=Z39.88-2004&rft_val_fmt=info:ofi/fmt:kev:mtx:audio&rft.type=track&rft.artist=...And You Will Know Us By The Trail Of Dead&rft.atitle=Century of Self&rft.ttitle=Bells of Creation

(the actual values should be percent-encoded, but are left unencoded here for clarity)

Then add to an appropriately classed span element as the title attribute, creating a COinS (ContextObject in Span):

<span class="Z3988" title="ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Aaudio&amp;rft.type=track&amp;rft.artist=...And%20You%20Will%20Know%20Us%20By%20The%20Trail%20Of%20Dead&amp;rft.atitle=Century%20of%20Self&amp;rft.ttitle=Bells%20of%20Creation"></span>

A Greasemonkey script looking for COinS will then be able to rewrite that into a link that you can use to fetch an appropriate copy of the file through your resolver of choice (i.e. Playdar running locally).

Resolve with Playdar

One downside to this is that (like microformats) the key/value pairs are all defined in one place, so it's not extensible - unlike RDFa, where you can add new values in your own namespace.