Ah, yeah, I see the issue now. They haven't really understood JSON as a format, have they? Well done getting it working.
It's really odd because they format the XML pretty intelligently. I would have parsed that, but I was told it takes 10x as long to generate the XML compared to JSON and so they don't want it used if it can be avoided.
Just as a tip, since you say you were considering contributing code to AAD, that suggests to me that you have a development environment and the know-how to be able to build from source. If you build AAD under the Debug configuration, it also compiles the scripts with debug info turned on, and when running AAD under the debugger Visual Studio will quite happily let you set a breakpoint within the .boo script file. It's not quite as nicely integrated as C# debugging, but you can certainly set watches on variable values, which makes script debugging a lot more pleasant than having to write out test log files all the time.
I should have thought to try that on my own. I think it would have cut down on the time this took by half at least.
I'm actually pretty happy with how it works, since the musicbrainz search is pretty good. I can't get 100% targeted results like I wanted, but I think I'm okay with that. The only drawback is that the musicbrainz search is a little slow. For some reason it takes 3-5 seconds for the GetPage to return with the JSON, whereas in a browser it's essentially instantaneous. Only thing I can think of is they might delay results based off the user agent string, or lack thereof.
Edit: And a quick check with spoofed request Headers reveals that's exactly the case. So fast! This would probably be a good addition to the existing musicbrainz.org script:
At the top of the script I added a fanartConstants class:
static class fanartConstants:
public UserAgentString as string = "AlbumArtDownloader"
public AcceptString as string = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
public AcceptCharset as string = "ISO-8859-1,utf-8;q=0.7,*;q=0.3"
public AcceptLanguage as string = "en-US,en;q=0.8"
public AcceptEncoding as string = "gzip,deflate,sdch"
and then I overloaded the Get function like so:
static def Get(url as String, cookies as CookieContainer, referer as String):
request as System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(url)
request.Method="GET"
request.ContentType = "application/x-www-form-urlencoded"
request.UserAgent = fanartConstants.UserAgentString
request.Accept = fanartConstants.AcceptString
request.Headers.Add("Accept-Charset",fanartConstants.AcceptCharset)
request.Headers.Add("Accept-Encoding",fanartConstants.AcceptEncoding)
request.Headers.Add("Accept-Language",fanartConstants.AcceptLanguage)
if not string.IsNullOrEmpty(referer):
request.Referer = referer;
if not cookies == null:
request.CookieContainer = cookies
response = request.GetResponse().GetResponseStream()
return System.IO.StreamReader(response).ReadToEnd()
And just replaced all calls to GetPage with Get(url, null, null).
Second Edit: Appears I was wrong. Guess as soon as I tried to test it musicbrainz' load dropped incredibly. Musicbrainz is back to taking 3-5 seconds for a response.