I’m using Python to make my queries to the MusicBrainz API (using musicbrainzngs), I need my query to return a random recording between certain years by a random artist that is from a specific country.
I’ve been able to get a random artist using:
musicbrainzngs.search_artists(area="france", limit=1, offset=0
I can offset to be a random number between 0 and the number of artists found in the query
Within this I can loop through the artists’ recordings and pick one at random, and I can specify it to randomly pick a recording that was recorded in a specific year.
This all works fine, but I wanted to find out if it was possible to combine all of this, or more of it, into a single query, so I didn’t have to loop through as much data. As it is right now I have to download all of the data about an artist, loop through all of their recordings and find one from a certain year, it might be that the random artist never released recordings in the year I need so then it would need to pick another artist. This is quite inefficient as you can imagine!