SHARE
TWEET

osu quals query

a guest Aug 24th, 2019 99 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var scriptProperties = PropertiesService.getScriptProperties();
  2. var token = "redacted"
  3. var ss = SpreadsheetApp.getActiveSpreadsheet();
  4. var qualsheet = ss.getSheetByName("result")
  5. var linksheet = ss.getSheetByName("link")
  6.  
  7. function getMatchData(matchID) {
  8.     var url = "https://osu.ppy.sh/api/get_match?k=" + token + "&mp=" + matchID;
  9.     var response = UrlFetchApp.fetch(url);
  10.     var json = response.getContentText();
  11.     return JSON.parse(json);
  12. }
  13.  
  14. function updateSheet() {
  15.     var row = 1;
  16.     var mplinks = linksheet.getRange("A1:A").getValues().filter(String);
  17.     mplinks.forEach(function(link){
  18.         var matchID = link.toString().slice(37);
  19.         var results = getMatchData(matchID);
  20.         results["games"].forEach(function(game){
  21.             game["scores"].forEach(function(score){
  22.                 if(score["score"]){
  23.                     qualsheet.getRange(row, 1, 1, 3).setValues(
  24.                         [[
  25.                             game["beatmap_id"],
  26.                             score["user_id"],
  27.                             score["score"]
  28.                         ]]);
  29.                     row++;
  30.                 }
  31.             });
  32.         });
  33.     });
  34. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top