set -l artist_id $argv[1] set -l total 999 set -l offset 0 set -l out "" set query '.["release-groups"][] | [(.["artist-credit"] | (map(.name) | join(";") )), .title, .["first-release-date"], .["primary-type"], (.["secondary-types"] | join(";")), "https://musicbrainz.org/release-group/" + .id] | @csv' while test $offset -lt $total; echo "fetching offset $offset of $total" set -l json (curl -SsL -H "Accept: application/json" "http://musicbrainz.org/ws/2/release-group?inc=artist-credits+aliases&release-group-status=website-default&artist=$artist_id&offset=$offset" | tee /tmp/foo.json) set total (echo $json | jq -r '.["release-group-count"]') set offset (math $offset + 25) set -l csv (echo $json | jq -r $query | string collect -N) set out (string collect -N $out $csv) end echo $out | wl-copy -n echo $out