Another piece of code to contribute here
I have a few artists whom I tagged as say "Beyonce", however last.fm aliases "Beyonce" to "Beyoncé".
The current script calls the API to look for "Beyonce" and last.fm does not take into account this alias on the API's side; hence via the API, the script does not detect any playcounts properly.
The API at this point of time does not provide any form indication what artist it's aliased to.
I threw up a fix that detects if the "+noredirect" string is in the URL, then look for similar artists and assumes that the first result is the "correct" artist. This works most of the time - of course there are exceptional cases, but I think this is the furthest we can go, can't possibly be searching through every single result there
Code modification done is as follows:
In the process() function:
Add right at the top of the function
try {
var re = new RegExp("\\+noredirect");
if ( re.test(xmlDoc) ) {
similar();
return;
}
} catch(e) { }
Add a new function called similar()
function similar() {
fb.trace("Playcount sync: Finding similiar artists...");
lastfm("&method=artist.getsimilar&limit=1&artist=" + encodeURIComponent(artist), "foo_playcount_sync", function() {
xmlDoc = xmlhttp.responseText;
var re = new RegExp("<name>(.*)</name>");
var m = re.exec(xmlDoc);
artist = m[1];
sync();
});
}
Cheers