Xana/ xana2/ 2007/ 10/ 25
Should I short JAVA or NTAP?

Dear Lazyweb (and Andres):

Why are Ian Murdock, Eben Moglen, and Pamela Jones supporting a company that tries to extort another company? Is it because actually filing suit is more evil than threats? Why shouldn't they both burn in hell? kthx.

Posted Thu 25 Oct 2007 09:42:01 PM EDT Tags: 25
zrockboxing out

Someone gave me an MP3 player. He did so for somewhat devious reasons, but that's outside the scope of this post. It is a SanDisk Sansa—stop thinking of pulp fantasy—and it has roughly 500 gigs too little storage space. The FAQ says such cute things as “The original firmware is recommended for charging at this time,” and “Rockbox does not currently provide either functionality so you will need to continue using the original firmware (for now) in MSC (UMS) mode to add music to the Sansa.”

Please don't tell my Sansa about this FAQ because it thinks that both of those claims are false.

I want my newfangled device to participate in the spyware fiesta known as last.fm, and Rockbox has an option for supporting that; if you turn it on, it fills a /.scrobbler.log file with tab-delimited lines for your parsing pleasure.

Rather than download additional software to cope with my new lifestyle, I whipped up the following script (released under the gnocchi-ng license) which “converts” the log to something you can just stuff into your \~/.zomg/cache file and send up to the submission server at your next appropriate invocation of zomg. I'm afraid you'll have to handle any timestamp sorting by hand, but if you script it, be a dear and implement some kind of cache file locking.

#!/bin/zsh
# Copyright (C) 2007  Clint Adams.  All rights reserved.
# This program has no name and is released under the terms of
# the gnocchi-ng license.

audioscrobbler_urlencode() {
  if (( $+options[multibyte] )); then
    setopt localoptions extendedglob nomultibyte
  else
    setopt localoptions extendedglob
  fi

  input=( ${(s::)1} )
  print -- ${(j::)input/(#b)([^A-Za-z0-9_.!~*\'\(\)-])/%$(([##16]#match))}
}

audioscrobbler_constructquery() {
  local sid="$1"
  local artist=$(audioscrobbler_urlencode "$2")
  local track=$(audioscrobbler_urlencode "$3")
  local album=$(audioscrobbler_urlencode "$4")
  local mbid=$(audioscrobbler_urlencode "$5")
  local length=$(audioscrobbler_urlencode "$6")
  local ttime=$(audioscrobbler_urlencode "$7")
  local source="$8"
  local tracknum="$9"

  reply=("&s=${sid}" "&a[0]=${artist}&t[0]=${track}&i[0]=${ttime}&o[0]=${source}&r[0]=&l[0]=${length}&b[0]=${album}&n[0]=${tracknum}&m[0]=${mbid}"$'\0')
}

while read -r line
do
  local -a field

  field=("${(@ps:\t:)${line}}")

  if [[ $field[6] == L ]]; then
    audioscrobbler_constructquery "" "$field[1]" "$field[3]" "$field[2]" "" "$field[5]" "$field[7]" P "$field[4]"
    print "$reply[2]"
  fi
done <<(grep -v '^#' .scrobbler.log)
Posted Thu 25 Oct 2007 11:11:25 PM EDT Tags: 25 rockbox