Playing with Ext.js, YQL and BBC radio1 Essential Mix

I’m a big fan of the radio1 essential mix and list to almost every week. I’m also getting more and more stuck into Ext.js at work. I also saw a great talk by Christian Heilmann of Yahoo at Full Frontal last and he demo’ed YQL. So I thought I’d give it a go and make a quick Ext app which uses YQL and pulls in the data of the tracklists for the Radio 1 Essential Mixes…
And here it is: http://www.mattgoldspink.co.uk/bbcradiolastfm.html
To give a brief summary of how I did it

  1. Getting the tracklisting from the BBC
    This basically involved me picking out a rough top level element from an essential mix page of tracks (firebug is lord). This resulted in the below YQL query:
    select * from html where url="http"+"://ww"+"w.bbc.co.uk/programmes/b00sdb2z" and xpath='//div[@class="title" or @class="title with-image"]'
    
  2. Now getting this into a simple Ext.js ListView
    It was obvious to me I needed a Ext.data.ScriptTagProxy to achieve this in order to get the JSON-P cross domain call. Unfortunately the hard bit is getting the JSON from the YQL call into the right format for my JsonStore in Ext. Thankfully Ext has all the necessary hooks to do this it looks something like:
    var dataStore = new Ext.data.JsonStore(
    	{
    		proxy : new Ext.data.ScriptTagProxy(
    			{
    				url : 'http'+'://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22http%3A%2F%2Fw'+'ww.bbc.co.uk%2Fprogrammes%2Fb00sdb2z%22%20and%0A%20%20%20%20%20%20xpath%3D\'%2F%2Fdiv%5B%40class%3D%22title%22%20or%20%40class%3D%22title%20with-image%22%5D\'&format=json',
    				callbackParam: 'callback',
    				restful: true
    			}
    		),
    		root: 'query.results.div',
    		fields: [{
                        name : 'artist',
                        convert : Ext.ux.mattgoldspink.bbcessentialmix.getArtistFromJson
                    },{
                        name : 'track',
                        convert : Ext.ux.mattgoldspink.bbcessentialmix.getTitleFromJson
                    }],
    		allowBlank: false
    	}
    );
    

    Where the convert functions were:

    function js_traverse(o, keyName) {
    	var type = typeof o;
    	if (o.class && o.class === keyName)
    	{
    		return o.content;
    	}
    	if (type == "object") {
    		for (var key in o) {
    			var output = js_traverse(o[key], keyName);
    			if (output) {
    				return output;
    			}
    		 }
    	} else {
    		return undefined;
    	}
    };
    
    Ext.ux.mattgoldspink.bbcessentialmix.getArtistFromJson = function(v, rec) {
    	var artist = js_traverse(rec, 'artist');
    	if (artist) {
    			return artist;
    	} else {
    		return 'Unknown';
    	}
    };
    
    Ext.ux.mattgoldspink.bbcessentialmix.getTitleFromJson = function(v, rec) {
    	var artist = js_traverse(rec, 'track');
    	if (artist) {
    			return artist;
    	} else {
    		return 'Unknown';
    	}
    };
    

    The interesting part here is that the BBC very helpfully markup all their tags so all I had to do was traverse the messy JSON tree until I found a class which marked either the title or artist and then return it (or ‘Unknown’ if it was there).
    Next we plug this into our Ext.ListView:

    var listView = new Ext.list.ListView({
    	id: 'listview',
    	store: dataStore,
    	multiSelect: true,
    	emptyText: 'No tracks found',
    	columnSort: false,
    	loadingText: 'Updating tracklist',
    	tpl: new Ext.XTemplate(
    	'<tpl for="rows">',
    		'</tpl>&lt;tpl exec="values.row = xindex;">',
    			'<dl>',
    				'<tpl for="parent.columns">',
    				'<dt style="width:{[values.width*100]}%;text-align:{align};">',
    				'<em unselectable="on"<tpl if="cls">',
                                    ' class="{cls}</em></dt></tpl>">',
    					'{[values.tpl.apply(parent)]}',
    				'<div class="x-clear"></div>',
    			'</dl>',
    		''
    	),
    	columns: [
    	{
    		header: 'Track #',
    		width: 0.04,
    		align: 'left',
    		dataIndex: 'row'
    	},{
    		header: 'Artist',
    		width: 0.48,
    		align: 'left',
    		dataIndex: 'artist'
    	},{
    		header: 'Track',
    		width: 0.48,
    		align: 'left',
    		dataIndex: 'track'
    	}]
    });
    

    This code is a bit more complicated than I expected because by default Ext.ListView does not with the Ext.grid.RowNumberer, so after a bit of google-fu I discovered a post showing how to achieve this using the tpl property.

  3. Getting all the possible Essential Mixes
    I decided I’d add a TreePanel so you can pick other essential mixes and view their tracks too. To do this I needed to jump back to firebug and YQL to get the available tracklists. In short my YQL query ended up being
    select * from html where url="http://www.bbc.co.uk/programmes/b006wkfp/episodes/2009" and xpath='//a[@class="url"]'
  4. Getting the TreePanel to pull in the data from YQL
    Again this is something I thought was going to be tough, but after looking at a few blog posts and examples I realised it was possible. My final TreeLoader implementation looks like:
    Ext.ux.mattgoldspink.bbcessentialmix.TreeLoader = function(){
    	Ext.ux.mattgoldspink.bbcessentialmix.TreeLoader.superclass.constructor.call(this);
    	this.proxy = new Ext.data.ScriptTagProxy({
    		url : this.dataUrl,
    		callbackParam: 'callback',
    		restful: true
    	});
    };
    Ext.extend(Ext.ux.mattgoldspink.bbcessentialmix.TreeLoader, Ext.tree.TreeLoader, {
    	dataUrl: 'http:'+'//query.yahooapis.com/v1/public/yql?'
    +'q=select%20*%20from%20html%20where%20url%3D'
    +'%22http%3A%2F%2Fwww.bbc.co.uk%2Fprogrammes'
    +'%2Fb006wkfp%2Fepisodes%2F2010%22%20and%0A'
    +'%20%20%20%20%20%20xpath%3D\'%2F%2Fa%5B'
    +'%40class%3D%22url%22%5D\'&format=json',
    	requestData : function(node, cb){
    		this.proxy.setApi(
                         Ext.data.Api.actions.read,
                         'http'+'://query.yahooapis.com/v1/public/yql?'
    +'q=select%20*%20from%20html%20where%20url'
    +'%3D%22http%3A%2F%2Fww'
    +'w.bbc.co.uk%2Fprogrammes%2F'
    +'b006wkfp%2Fepisodes%2F' + node.attributes.nodeid
    + '%22%20and%0A%20%20%20%20%20'
    +'%20xpath%3D\'%2F%2Fa%5B%40class'
    +'%3D%22url%22%5D\'&format=json');
    		this.proxy.request('read', null, {}, {
    			readRecords : function(o){
    				return o.query.results.a;
    			}
    		}, this.addNodes, this, {node:node, cb:cb});
    	},
    	addNodes : function(o, arg){
    		var node = arg.node;
    		for(var i = 0, len = o.length; i < len; i++){
    			var foo = {};
    			foo.text = o[i].span.content,
    			foo.url =  o[i].href.replace("/programmes/", '');
    			foo.leaf = true;
    			var n = this.createNode(foo);
    			if(n){
    				node.appendChild(n);
    			}
    		}
    		arg.cb(this, node);
    	}
    });
    

    The key bits here are that before I request data for a node I change the YQL query to pick up the data for the year node that was clicked. Then once the results come back I pull out the results node from the JSON and in my addNodes function I set up leaf node.

  5. The onclick callback to reload the ListView with new tracklists
    When someone clicks one of these new tracklist nodes in the TreePanel we want to update the ListView. This was done by adding a listener to the TreePanel:
    listeners: {
    	click: function(n) {
    		Ext.getCmp('listview').getStore().proxy.setApi(
                         Ext.data.Api.actions.read,
    'http://query.yahooapis.com/v1/public/yql?'
    +'q=select%20*%20from%20html%20where'
    +'%20url%3D%22http%3A%2F%2Fww'
    +'w.bbc.co.uk%2Fprogrammes%2F' + n.attributes.url
    +'%22%20and%0A%20%20%20%20%20%20'
    +'xpath%3D\'%2F%2Fdiv%5B%40class%3D'
    +'%22title%22%20or%20%40class%3D'
    +'%22title%20with-image%22%5D\'&format=json');
    		Ext.getCmp('listview').getStore().load();
    	}
    }
    

    We simply change the read action url in the ListView store’s proxy, then we reload the store! As simple as that.

To wrap it up I put it all in an Ext.Viewport. Feel free to view the source of the page and enjoy!
http://www.mattgoldspink.co.uk/bbcradiolastfm.html

Posted in Featured | Tagged , , , , , , , | 1 Comment

Tomcat6 issues upgrading to Ubuntu 10.4 Lucid Lynx

I thought I’d post this in case anyone else hits similar issues upgrading to Ubuntu 10.4. So after following all the steps I decided to keep my existing tomcat6 script under /etc/init.d/tomcat6 because I’d customised it for launching Subsonic Music Server. However after restarting my machine after upgrading I noticed subsonic was not running. So I dug a bit deeper and found that I was missing the jsvc package. Running:

sudo apt-get install jsvc

got me sorted and Subsonic is back alive!

Posted in Java, Ubuntu | Tagged , , , | Leave a comment

Broken Home DJ Set

This is a mix which I did in a club back in Macclesfield in 2001 for a club night called Broken Home. The recording is me preparing in my bedroom a day or two beforehand so excuse the bad scratching and FX.

Broken Home Set (demo) 2001  by  mattgoldspink

Posted in Featured, Mix | Leave a comment

All Vinyl Mix – KISS (2004 REMIX) by PRINCE is now in stock

Prince - KissI finally tracked down a copy of the Soul Of Man Remix of Prince’s Kiss a few weeks back after first hearing it on the Cut & Paste essential mix on Radio 1 back in 2000 (I didn’t realise it was a full 9 years ago!!). It took 5 years to figure out it was a remix by Soul of Man (the tracklist for the essential mix lists it simply as “Kiss” – http://www.mixesdb.com/db/index.php/2000-06-11_-_Cut_And_Paste_-_Essential_Mix). Then after trawling few forums years ago I narrowed it down to being this record on HTFR:

http://www.htfr.com/more-info/?catno=MR227279

Unfortunately it was not in stock and was noted as being DELETED. Given the track was a white label I expected it to never re-surface but since htfr have the option to add something to your wishlist I do so anyway. 4 and half years later an email pops into my inbox saying

KISS (2004 REMIX) by PRINCE is now in stock

Buy buy buy!!!! So I did and i got it!

Anyway, since I can only get it on vinyl I figured I should have a play on the wheels of steel and made a quick mix and upload it as usual. So here is a mix with the Kiss track about 1/2 way through. Enjoy!

Download link: KISS (2004 REMIX) by PRINCE is now in stock.mp3 (mp3, 38Mb, 40min)

Tracklist:

  1. Hypocrites (Naked Funk Remix) – Junior Delgado
  2. To The Beat (The Light Mix) – PFN
  3. My House Is Your House – Phil Keiron
  4. Disciples of the watch – The Insiders
  5. Let The Good Times Rol – Layo And Bushwacka!
  6. Under Control – Freeland
  7. Widemouth (Dub Pistols Muthafuckin’ mix) – Supercharger
  8. KISS (2004 REMIX) – PRINCE (Remix is actually by Soul Of Man)
  9. Scram – Plump DJs
  10. Lethal Cut – Propellerheads
  11. Because of You – Scanty Sandwich
  12. Mayhem – Agent Sumo
Posted in Featured, Mix | Tagged , , , , , , , , , , | Leave a comment

New Summer Mix

It’s not very summery. After seeing 2manydj’s a few weeks back I realised I needed to do some DJing. It’s only 30mins, but it packs in about 20 tunes (including the obligatory Michael Jackson tribute):

Download: 11-july-2009.mp3

Tracklist:

  1. Hot Chip – Ready For The Floor
  2. Cities In Dust (Glimmers Remix). – Junkie XL
  3. Hey Boy Hey Girl – The Chemical Brothers
  4. Scale – The Chemical Brothers
  5. Louder Than A Bomb – Tiga
  6. Gimme What You Got (Alex Metric Remix) – Black Daniel
  7. Jump N’ Shout – Basement Jaxx
  8. Don’t Go – Yazoo
  9. Hummer (Surkin Remix) – Foals
  10. Engine (Erol Alkans Transonic ReEdit) – LA Priest
  11. It Doesn’t Matter – The Chemical Brothers
  12. Kids (Soulwax Nite Remix) – MGMT
  13. D.A.N.C.E. (MSTRKRFT Remix) – Justice
  14. Lovefool – The Cardigans
  15. Cross The Dancefloor (Chromeo Remix) – Treasure Fingers
  16. OK Annie (Breaks Mix) – Robb G, The Phat Conductor
  17. The Salmon Dance – The Chemical Brothers
  18. Tour de france (kervorkian remix) – Kraftwerk
  19. Under Control – Freeland
  20. General Midi – 4 Million Ways (Album Version)
Posted in Featured, Mix | Tagged , , , , , , , , , , , , , , , | Leave a comment

How good are 2 many djs?

Saw them at Brixton Academy for Meg’s bday. They’re this awesome:

2manydjs: o2 academy bristol, 9th june 2009

2manydjs: o2 academy leeds, 10th june 2009

Posted in Random | Leave a comment

New mix with my DJ IO

djioIt’s my birthday this week so I bought myself a Numark DJ IO sound card for my laptop so I can properly DJ on it (I have a dual soundcard on PC but laptop). This is my first live mix with it. I went back through afterwards just to correct some of the levels but essentially all you hear is live.

20-march-2009.mp3

  1. Intro – Milk advert
  2. Milkshake – Kelis
  3. Funky Cold Milkshake – Kelis vs Tone Loc
  4. Enjoy The Silence (Soundhog’s Float Mix) – Depeche Mode
  5. Nine Lives – Midnight Juggernauts
  6. Mindfields – The Prodigy
  7. That Number (Yuksek Remix) – Plugs
  8. Over and Over – Hot Chip
  9. Let’s Make Love And Listen To Death From Above (Spank Rock Remix) – CSS
  10. Blind (Frankie Knuckles remix) – Hercules & Love Affair
  11. Needy Girl (Dolby Anol’s French Mistake) – Chromeo
  12. Galaxy 2000 (Plump DJs Remix) – War
  13. I.O.U. (Dyce Freestyle’s Death Remix) – Freeez
  14. Love to Push It (Ursula 1000 Edit) – Crookers Vs. Salt N Pepa
  15. Heather, I’m Dry (Anol Edit) – Dolby Anol
  16. Bass Phenomenon – Kraftykuts & Tim Deluxe
  17. Bass Phenomenon (DJ Friction Remix) – Krafty Kuts & Tim Deluxe
  18. Attack Ships On Fire – London Elektricity
Posted in Mix | Tagged , , , , , , , , , , , | Leave a comment

A load of dodgy off the cuff live mixes for you (dis)pleasure

So this last week or so I’ve set up my laptop, Kaos Pad and BCF2000 on my decks and been practicing live mixes. I’ve spawned a few now and I thought I’d upload them. They’re not all that great, they’re mostly me trying to use Mixmeister live. Have a listen and see what you think.

Mix 1: 16-March-2009
16-march-2009.mp3
A lot of hip-hop, Pigeon John, DJ Shadow, Naughty By Nature, Fatboy Slim, Adam Freeland, Marlena Shaw, Diplo, Amerie, Ohmega Watts, Mr Scruff, Grandmaster Flash, Billy Preston, Pharell, EMF, RJD2, …

Mix 2 : 14-March-2009
14-March-2009.mp3
Featuring Adam Freeland, Prodigy, Snoop Dog, Stanton Warriors, Plump DJs, General MIDI, Dizzee Rascal, Dave Spoon, Wham, Kissy Sell-Out, Reel2Reel, …

There’s more to come, but I need to find time to upload the others.

Posted in Mix | Tagged , , , , , , , , , , , , , , , , | Leave a comment