Audioscrobbler sidebar, fixed?

Posted by Jerry Mon, Mar 19 '07

Tried making changes to the Audioscrobbler (aka sidebar plugin that never seemed to show up. Changed it in the sidebars admin to use the new API 1.0 xml feeds, and then the .rb file so it can parse the feed XPath correctly (As a side note, debugging Typo sidebar plugins is hard, no output text, any exceptions thrown simply makes it not rendered. Blah, the world needs a better plugin architecture. :p). And then it worked! Woot.

Posting code changes for TYPO_HOME/vendor/plugins/audioscrobbler_sidebar/audioscrobbler.rb:

<code class="ruby">
# we're replacing this procedure here
def parse(body)
    xml =
    self.items        = [] = "" # not really used
    self.title = "Recent Music"  # title of sidebar box
    XPath.each(xml, "//track/") do |elem|
      item =
      item.title       = XPath.match(elem, "name/text()").to_s
      item.artist       = XPath.match(elem, "artist/text()").to_s        = XPath.match(elem, "url/text()").to_s        = Time.mktime(*ParseDate.parsedate(XPath.match(elem, "date/text()").to_s))
      items << item
    self.items = items.sort_by { |item| }.reverse

It still doesn’t seem to refresh though. Hmm. :S

# Posted in 11 years ago comments