#musicbrainz

/

      • FauxFaux
      • All of my php is just pushing stuff onto the end of associative arrays of associative arrays of.. etc. :)
      • nikki just uses xterm -u8 for a unicode xterm...
      • Generic solution is generic.
      • brianfreud
        yeah, I guess the problem is I’m trying to do a multi-dimensional associative array, and it’s confusing me :P
      • ruaok
        er, a nested assoc array ?
      • brianfreud doesn’t really know
      • you can't really make a mutli-dim array -- wrong terminology. :)
      • think of it more as a tree.
      • brianfreud
        how would you turn these two halves of data chunks into something useful? http://musicbrainz.pastebin.com/d124189ba
      • FauxFaux thinks.
      • I’m still at the “scraping the data into foo stage”, so as long as I end up with some ordered way to store that, right now, I’m not locked into any particular method
      • ruaok
        an array of assoc arrays?
      • FauxFaux
        Ohhh, I see the problem now. Smell of pizza really helps.
      • brianfreud ‘s trying to picture a pseduo-implementation of that...
      • ruaok drools
      • ruaok
        vd dinner is still over 1:30 out.
      • brianfreud: what is the end goal?
      • brianfreud
        I don’t have it in that snippet, but not only do tracks have the 1, 2, 3, thing, but they also store roles that way
      • FauxFaux
        I'd have an array of trakcs (or, a map of albums -> an array of tracks, by number), each track being an object with a name, and a map of which artist did what.
      • brianfreud
        ruoak: to be able to present the user with a list of people, to map each to an existing MB artist, and a list of roles, to be able to have the user map each role to an AR
      • FauxFaux
        Go through the data you have, add any new information you have to that beastly structure.
      • brianfreud
        and to do it in some way that doesn’t take 10 min to process :P
      • FauxFaux
        (you can normalize out artist names if you want, but it's probably pointless at this stage)
      • FauxFaux -> remove food from oven and wave it infront of ruaok.
      • brianfreud
        so [track][artist, role]?
      • ruaok goes to the kitchen to fetch a knife for FauxFaux
      • FauxFaux
        track containing a set of [artist => role] pairs, yeah.
      • brianfreud
        hmm, ok, I can see how I’d put it in there...
      • on the other end, then, how would I pull out each unique artist and each unique role? Sounds cpu expensive...
      • essentially --> for tracks.length( for artists.length( for roles.split(“,”).length( for(interpreted Track list).length ( store arrayFoo[Track][artist][role] )))) ?
      • hmmm, ok, I think I see how maybe to do it. :)
      • FauxFaux
        arrayFoo[Track][artist] = role; yeah. Unique artist/roles can be kept track of while you're building the tree, or you could just scan it (only have to look at everything once, shouldn't be too slow) at the end.
      • arrayBar[Artist] = true; ;)
      • brianfreud
        was thinking just, at the same time, store two other simple arrays, one of artists, one of roles, and use those values to store in the big array...
      • xlotlu has quit
      • xlotlu joined the channel
      • xlotlu has quit
      • xlotlu joined the channel
      • Infinito_ joined the channel
      • baijiutong joined the channel
      • `duckman has quit
      • nikki has quit
      • nikki joined the channel
      • Infinito_ has quit
      • nikki has quit
      • stochasticism joined the channel
      • nikki joined the channel
      • Amblin joined the channel
      • Amblin- has quit
      • brianfreud_ joined the channel
      • brianfreud has quit
      • stochasticism has quit
      • nikki has quit
      • brianfreud_ finally manages to get all Discogs release-level ARs split out to single ARs, assigned to the correct track numbers, and stored in a sensible array! O/
      • brianfreud_
        http://musicbrainz.pastebin.com/d7db99c82 if anyone has ideas on how to optimize it :)
      • HairMetalAddict has quit
      • HairMetalAddict joined the channel
      • nikki joined the channel
      • Tykling joined the channel
      • cooperaa has quit
      • brianfreud_ has an array of all Discogs ARS! :D:D:D:D
      • brianfreud_ is now known as BrianFreud
      • rpedro joined the channel
      • rpedro__ has quit
      • outsidecontext joined the channel
      • srotta joined the channel
      • BrianFreud
        srotta, you have any experience with JSON?
      • petros joined the channel
      • outsidecontex1 joined the channel
      • outsidecontext has quit
      • mellum_ has quit
      • l8nite joined the channel
      • luks joined the channel
      • l8nite has quit
      • dsp has quit
      • soccos joined the channel
      • soccos
        json
      • BrianFreud
        hey
      • I just emailed you back the queries I’m dealing with... just have no idea how to do anything with them
      • tciddAlateMriaH joined the channel
      • soccos
        afaiui you can just eval json in your javascript and it will make some kind of object for u
      • BrianFreud
        it’ll automatically send the request and wait for the response?
      • soccos
        have you read anything at all about it?
      • BrianFreud
        yeah, I was trying to dig out at least some idea of how to handle it, but everything just goes on about how it’s almost javascript already. Didn’t see anything about how to actually request it, or how actually parse out the data
      • there’s a pretty nice interface to wikipedia data, though, and I’d love to snag just a few crumbs using it... but it’s only JSON
      • luks
        you request it the same way you request xml
      • soccos
        the thingy i was working on makes a javascript call to (a php script) which returns a json object
      • luks
        but instead of parsing it as it, you parse it as json
      • soccos checks syntax ...
      • er, parsing it as xml
      • BrianFreud
        GM_xmlhttpRequest({ method: 'GET', url: 'http://www.freebase.com/api/service/mqlread?queries={"albums":{"query":{"type":"/people/person","date_of_birth":null,"name":"tori amos"}}}', ....
      • l8nite joined the channel
      • l8nite
        hurrah
      • osx 10.5.2 updated without too much pain :)
      • and picard still works hehe
      • soccos
        BrianFreud: r u able to see what your json producer is returning by sending it some kind of query?
      • luks
        BrianFreud: do you have an example how would you do it for xml?
      • dsp joined the channel
      • l8nite
        doh, another restart required :(
      • l8nite has quit
      • BrianFreud
        soccos: yes - I just put the request in as url in Firefox, it renders the response back as text
      • outsidecontex1
        brianfreud: you normally get json as the response from the server, it've never seen a case where the server expects json as query parameter
      • soccos
        BrianFreud: the producer I wrote returns the json in a var assignment i.e. var foo = {$json_string}
      • BrianFreud
      • HairMetalAddict has quit
      • luks
        oDiv.innerHTML = responseDetails.responseText;
      • BrianFreud
        outsidecontex1: yeah, freebase uses JSON both on the request and the response side (and luckily has a query builder :D)
      • luks
        start with: var obj = eval('(' + responseDetails.responseText + ')');
      • soccos
        BrianFreud: i've only ever used it as a response
      • luks
        you want to use an actual json parser
      • but this is good enough for testing
      • then obj will have the response as an javascript object, and you can do obj.foo.bar[2].etc
      • BrianFreud
        and that then turns each element from the JSON response into oDiv.elements?
      • luks
        no, it's not a dom tree
      • it's plain old javascript object
      • BrianFreud
        ok, so given this as part of the JSON response, "date_of_birth": "1963-08-22", I then can access that as obj.date_of_birth[0] ?
      • luks
        obj.albums.result.date_of_birth
      • l8nite joined the channel
      • BrianFreud
        ah, ok, so I can still think of it as turning into “nodes”, cool :)
      • luks
        no, you think of it as objects
      • you can't use getElementsById or anything DOM-related, because there are no DOM elements
      • BrianFreud
        not a problem
      • Can I still test for the existance of obj.albums.result.date_of_birth ?
      • luks
        the usual JS way
      • BrianFreud
        ie, I make the request for date_of_death, obviously, not everyone actually has a date_of_death response
      • luks
      • etc.
      • BrianFreud
        ok, sounds easy enough, thanks :)
      • soccos
        can mb return json now then?
      • luks
        but you definitely want to replace eval with something else later
      • soccos: no
      • BrianFreud
        luks: why’s that?
      • l8nite
        you can use object.hasOwnProperty("blah") to test for existence (sorry if I'm joining late and not being helpful)
      • luks
        because you don't want to execute arbitrary code from some random server in your script
      • BrianFreud
        oh, and eval’s actually executing it, gotcha
      • not that freebase likely will attempt it, but I definitely see your point
      • BrianFreud just needs to finish up then parsing the data from freebase, snag the purevolume url, snag the myspace url, and snag some data at last.fm, and he’ll be ready to actually start to do something with all the data :)
      • oh yeah, and amazon, but that’s mostly written already
      • outsidecontex1
        that's the thing i never understodd with json: it is actually JS code, which would make it easy to inlcude it with eval. but that's exactly what you don't want so you need a proper parser. why should you then use json in the first place and not something else?
      • luks
        outsidecontex1: because it's simple enough and widely used
      • and less verbose than xml
      • l8nite
        it's human-parseable as well
      • BrianFreud
        well, just looking at it from not knowing much of JSON, it would seem to make more sense to use JSON when you control the source (intranets) and XML when you don’t (internet)... I can see outsidecontex1’s point
      • l8nite
        It's also pretty reliable for places where you control the source... er
      • Brian X_X
      • outsidecontex1
        but there are prettier data representations than a programming language
      • l8nite
        outsidecontex1: As usual, tmtowtdi and uww :)
      • BrianFreud
        yeah, and maybe I’m wierd, but XML seems almost more readable to me than JSON
      • luks
        there is no reason to waste bandwidth with <date_of_birth>1963-08-22</date_of_birth> if "date_of_birth":"1963-08-22" will do just fine