Last.fm Loved Tracks RSS Feed

June 30th, 2008

last.fm loved tracks

Ever wondered why last.fm don’t provide an RSS feed of your loved tracks? Me too. So using the freely available audioscrobbler web services i’ve created a very basic last.fm loved tracks feed which. The main reason for doing so was to update twitter with my loved tracks via twitterfeed. The feed can be called with the following syntax:

http://jamazon.co.uk/last.love/user/[last.fm username]/feeds/[feed type (rss|atom|opml)]

It’ll work with any valid last.fm username.

Here’s mine:

http://jamazon.co.uk/last.love/user/jamiethompson/feeds/rss

I might furnish the service with a shiny little user interface at some point, but I don’t think it really needs one.

Posted in Web | 1 Comment »

Publish / Subscribe With jQuery

June 17th, 2008

With a view to writing a jQuery UI integrated with the offline functionality of Google Gears i’ve been toying with some code to poll for network connection status using jQuery.

The Network Detection Object

The basic premise is very simple. We create an instance of a network detection object which will poll a URL at regular intervals. Should these HTTP requests fail we can assume that network connectivity has been lost, or the server is simply unreachable at the current time.

$.networkDetection = function(url,interval){
var url = url;
var interval = interval;
online = false;
this.StartPolling = function(){
this.StopPolling();
this.timer = setInterval(poll, interval);
};
this.StopPolling = function(){
clearInterval(this.timer);
};
this.setPollInterval= function(i) {
interval = i;
};
this.getOnlineStatus = function(){
return online;
};
function poll() {
$.ajax({
type: "POST",
url: url,
dataType: "text",
error: function(){
online = false;
$(document).trigger('status.networkDetection',[false]);
},
success: function(){
online = true;
$(document).trigger('status.networkDetection',[true]);
}
});
};
};

You can view the demo here. Set your browser to work offline and see what happens…. no, it’s not very exciting.

Trigger and Bind

What is exciting though (or at least what is exciting me) is the method by which the status gets relayed through the application. I’ve stumbled upon a largely un-discussed method of implementing a pub/sub system using jQuery’s trigger and bind methods.

The demo code is more obtuse than it need to be. The network detection object publishes ’status ‘events to the document which actively listens for them and in turn publishes ‘notify’ events to all subscribers (more on those later). The reasoning behind this is that in a real world application there would probably be some more logic controlling when and how the ‘notify’ events are published.

$(document).bind("status.networkDetection", function(e, status){
// subscribers can be namespaced with multiple classes
subscribers = $('.subscriber.networkDetection');
// publish notify.networkDetection even to subscribers
subscribers.trigger("notify.networkDetection", [status])
/*
other logic based on network connectivity could go here
use google gears offline storage etc
maybe trigger some other events
*/
});

Because of jQuery’s DOM centric approach events are published to (triggered on) DOM elements. This can be the window or document object for general events or you can generate a jQuery object using a selector. The approach i’ve taken with the demo is to create an almost namespaced approach to defining subscribers.

DOM elements which are to be subscribers are classed simply with “subscriber” and “networkDetection”. We can then publish events only to these elements (of which there is only one in the demo) by triggering a notify event on $(”.subscriber.networkDetection”)

The #notifier div which is part of the .subscriber.networkDetection group of subscribers then has an anonymous function bound to it, effectively acting as a listener.

$('#notifier').bind("notify.networkDetection",function(e, online){
// the following simply demonstrates
notifier = $(this);
if(online){
if (!notifier.hasClass("online")){
$(this)
.addClass("online")
.removeClass("offline")
.text("ONLINE");
}
}else{
if (!notifier.hasClass("offline")){
$(this)
.addClass("offline")
.removeClass("online")
.text("OFFLINE");
}
};
});

So, there you go. It’s all pretty verbose and my example isn’t at all exciting. It also doesn’t showcase anything interesting you could do with these methods, but if anyone’s at all interested to dig through the source feel free. All the code is inline in the head of the demo page

Posted in Web | No Comments »

All Change at Citynoise.org

June 13th, 2008

For those who are interested I’m going to start documenting the upgrades and improvements I’m making to citynoise.org over the coming months. The site has been struggling under some pretty heavy traffic and several internal optimisations including query caching for some of the more complex database operations has gone a long way towards making the site feel usable again.

Syndication Feeds

Since the beginning of time citynoise.org has had an RSS 0.91 feed, and a broken one at that, but the most recent upgrade has provided solid and stable feeds in a variety of formats including RRS 1.0, RSS 2.0 and ATOM. On top of this Peter has implemented a nice Twitter feed using… um twitterfeed

The old RSS URL points at the new RSS 0.91 feed so there’s no need to update your bookmarks/aggregator/whatever. Unless you want to.

Namespaces and hackable URLS

An important part of any social site IMO is the URL scheme. Hackable urls, that is URLS which the user can inuitively modify to navigate the site in a way which suits them, are integral to this. To this end the “articles by location” pages which were previously in the format

http://citynoise.org/hood/london@uk

are now in the format

http://citynoise.org/place/uk/london
This makes it much more obvious that the URLs are ‘hackable’ in that you can remove the ‘london’ segment and use http://citynoise.org/place/uk to view all articles in the UK.

All pages are still available at their old “hood” addresses for backwards compatibility.

Climbing The Technorati Tree

Every new post is now automatically submitted to Technorati and a handful of other aggregators. This should ensure maximum exposure for new posts especially if they’re tagged correctly. The next step here would be ensuring posters tag their posts adequately. It makes all the difference.

[[wiki:topic here]] style Wikipedia links also now configured to work as tags within the ‘blogosphere’, though this isn’t yet detailed anywhere on the site.

More to come soon…

Posted in Projects | No Comments »

BBC IPlayer XOR Decryption

June 11th, 2008

As has been widely reported, it is still possible to successfully download the x264 MPEG streams of BBC programmes from the BBC IPlayer service but that they are now XOR “encrypted” in such a way that they will only play on Apple mobile devices.

BBC IPlayer XOR Decryption

It’s not really encryption, is it

Long story short, the streams are XOR’d with a two-byte repeating pattern. It’s not yet clear how the iPhone picks up the two-byte key for this XOR scheme, or what kind of inside knowledge was needed to discover the capability (collusion?), but it’s rumoured that the XOR scheme has actually broken the iPod Touch functionality. If this is true it’s a massive WTF and probably rules out any idea of the BBC colluding with Apple over this.

Putting the moral arguments for the BBC’s latest move aside for a second. It’s fairly simple to deXOR the files and there are already a handful of pre-written scripts for doing just that.

So, What Are The Options?

Paul Battley has patched his iplayer-dl script so that it will continue to function in light of the XOR encryption. He’s also planning on patching the Windows GUI version for n00bs.

There’s a nice little perl script which should prove pretty useful for those of use already using one of the perl based solutions to access the TV shows we’re forced to pay for.

Most interestingly i’ve found some C++ code for decrypting the streams which is available at beebhack along with simple instructions for how to compile it for use.

The cat and mouse game continues. Yawn.

Update: June 12th 2008 Paul Battley has released updated versions of both his ruby command line tool and the Windows GUI download client. Not only that but this morning, new releases of both have appeared which utilise faster XOR decryption. His blog post details the changes.

The new project page for iPlayer Downloader is at http://po-ru.com/projects/iplayer-downloader/

Posted in Rants | 3 Comments »

Tips for Using JQuery with ASP.NET Ajax

June 9th, 2008

Dave Ward has put together an excellent and extensive post on his experiences integrating jQuery with ASP.NET

There are the usual number of pitfalls you’d expect when integrating [insert widely-used microsoft technology here] with [insert useful open source technology here]

Want to consume a JSON Web Service with jQuery? Sounds simple. That’s kinda the point of JSON right? Well yeah, but no. Everything’s workaroundable and to be fair it isn’t all Microsoft’s fault… ok so most of it is.

I’m gonna be starting a large scale ASP.NET / jQuery / ExtJS project in the very near future and Dave’s short guide has probably just saved me several hours if not a whole day of figuring out all the lumps and bumps myself.

Posted in Web | No Comments »

« Older Entries Newer Entries »