Skip to content

Instantly share code, notes, and snippets.

@woodwardtw
Created March 27, 2016 17:10
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save woodwardtw/2f5d898442d55e06a17d to your computer and use it in GitHub Desktop.
google script to pull in discography data for a particular user
function getThatData() {
var user = 'USERNAME';
var url = 'https://api.discogs.com/users/' + user + '/collection/folders/0/releases'; //I probably did this right but ran it w the user hardcoded
var sheet = SpreadsheetApp.getActiveSheet();
var response = UrlFetchApp.fetch(url); // get feed
var json = response.getContentText(); //
var data = JSON.parse(response);
var counter = data.pagination.items;
Logger.log(counter);
for (var i = 0; i<= counter; i++) {
var stats = [];
stats.push(data.releases[i].instance_id);//works a
stats.push(data.releases[i].date_added);//works b
stats.push(data.releases[i].basic_information.labels[0].name); //works c
stats.push(data.releases[i].basic_information.labels[0].catno); // work d
stats.push(data.releases[i].basic_information.labels[0].resource_url); // works e
stats.push(data.releases[i].basic_information.labels[0].entity_type_name); //workd f
stats.push(data.releases[i].basic_information.formats[0].descriptions[0]); //stringify array?
stats.push(data.releases[i].basic_information.formats[0].name);//works h
stats.push(data.releases[i].basic_information.title); //works i
stats.push(data.releases[i].basic_information.artists[0].name); //works j
stats.push(data.releases[i].basic_information.resource_url); //k
stats.push(data.releases[i].basic_information.year); //l
stats.push(data.releases[i].basic_information.id); // m
Logger.log(stats);
SpreadsheetApp.getActiveSpreadsheet().appendRow(stats);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment