A Pipe for New Episodes in a BBC series

I like this Pipe. It takes an iPlayer series PID, calls YQL (which fetches the RDF/XML for that series, parses it using E4X/YQL Execute and returns an RSS feed) then outputs the items in RSS/JSON/email/etc.

It's for getting an RSS feed of new episodes in a series.

There's also an easier way to get the data in plain XML, if you know the URL format.

Independent UK Record Labels on Spotify

Wikipedia has a list of independent UK record labels; the table below is the result of looking up how many albums released in 2009 each label currently has available on Spotify:
Albums Record label
68 Domino Records
43 City Records
39 Southern Fried Records
33 Ninja Tune
29 Moshi Moshi
27 Magnatune
26 Fueled By Ramen
22 Just Music
21 Craze Productions
20 Xtra Mile Recordings
19 Wichita Recordings
16 Visible Noise
14 Fat Cat Records
14 Snapper Music
14 Southern Records
14 Tru Thoughts
14 Static Caravan
12 Angular Recording Corporation
11 B-Unique Records
11 Real World Records
10 Chemikal Underground
9 Kscope
9 Lex Records
8 Cooking Vinyl
8 Dance to the Radio
7 Fierce Panda Records
7 One Little Indian Records
7 Peacefrog Records
6 Marrakesh Records
6 Transgressive Records
5 Factory Records
5 Freshly Squeezed Music
5 Gut Records
5 Rebel Alliance Recordings
5 Stolen Recordings
5 Smalltown America
4 Audiobulb Records
4 Field Records
4 People In The Sky
3 Blast First
3 Criminal Records
3 Heron Recordings
3 Kitchenware Records
3 Lojinx
3 Heavenly Recordings
3 O Rosa Records
2 Deltasonic
2 How Does It Feel To Be Loved?
2 LO-MAX Records
2 Resurrection Records
2 Robot Needs Home
2 Sonic vista music
2 Trash Aesthetics
2 Heaven Records
1 Beatroute Records
1 Eye Industries
1 Falling A Records
1 Hyperdub
1 Imaginary Records
1 Junior Aspirin Records
1 My Kung Fu
1 No Masters
1 Rise Above Records
1 Skint Records
1 TRL Music
1 Tigertrap Records
1 Too Pure

Adding Spotify links to BBC Radio playlists, via RDFa, using Greasemonkey and rdfQuery

This is a Greasemonkey script that

  1. Uses rdfQuery to read the RDFa from radio tracklist pages on bbc.co.uk/programmes:
    $('#segments')
      .rdf()
        .prefix('mo', 'http://purl.org/ontology/mo/')
        .prefix('foaf', 'http://xmlns.com/foaf/0.1/')
        .prefix('dc', 'http://purl.org/dc/terms/')
        .where('?track a mo:Track')
        .where('?track foaf:maker ?artist')
        .where('?track dc:title ?trackTitle')
        .where('?artist a mo:MusicArtist')
        .where('?artist foaf:name ?artistName') // not quite working yet (rdfQuery bug)
        .each(function(i, bindings, triples) {
           doSomething();
        });
  2. Looks up that track using the Spotify metadata API:
    http://ws.spotify.com/search/1/track.xml?q=artist:"' + encodeURIComponent(artistName) + '"+track:"' + encodeURIComponent(trackTitle) + '"'

    (when MusicBrainz ID searches are working better in Spotify, could use those instead)

  3. Replaces the artist name and track title of found tracks with Spotify links, and adds a Spotify link for the album on which the track was found.

Try it on one of these pages:

Indexing JSON data in MongoDB using PHP

  1. Install MongoDB (on OS X, can use Homebrew: brew install mongodb)
  2. Install the PHP module for communicating with MongoDB: pecl install mongo
  3. Setup and start MongoDB:
    #!/bin/bash
    MONGO=/opt/homebrew/var/mongodb
    mkdir -p ${MONGO}/data
    mongod --dbpath=${MONGO}/data --logpath=${MONGO}/mongo.log
    tail -f ${MONGO}/mongo.log
  4. Index some data (in this example, a bunch of JSON files from TfL):
    <?php
    $mongo = new Mongo;
    $collection = $mongo->{'tfl'}->{'stops'};
    
    foreach (glob('stops/*.js') as $file){
      $json = json_decode(file_get_contents($file), TRUE); // TRUE = associative array
      foreach ($json['Stops'] as $item){
        $item['_id'] = $item['StopId']; // _id field = primary key
        $item['StopCode'] = (int) $item['StopCode']; // make sure these are integers
        $collection->insert($item, TRUE); // TRUE = throw an error if not successful
      }
    }
    
    $collection->ensureIndex(array('StopCode' => 1)); // create an index on the StopCode field
    $mongo->close();
  5. Run a query using the HTTP interface:
    curl 'http://127.0.0.1:28017/tfl/stops/?filter_StopCode=1234'
  6. Run a query using PHP:
    <?php
    $mongo = new Mongo;
    $collection = $mongo->tfl->stops;
    $items = $collection->find(array('StopCode' => 1234));
    foreach ($items as $item)
      print_r($item);
    

Showing Delicious bookmarks of pages within a domain

Via a comment on Matt Haughey's "personal feedback loops" post:

Delicious bookmarks

Url fragments work, too: url:nature.com/nature/journal

Aparently it's been there for a while; I hadn't noticed before.