So I created this script that retrieves the number of followers a playlist has on Spotify, and returns it to a cell in Google sheets. However, after working for over a year it is now broken and I can’t put my finger on why.
Here’s the script:
function SAMPLE(url) {
const res = UrlFetchApp.fetch(url).getContentText();
const v = res.match(/followers":({[sSw]+?})/);
return v && v.length == 2 ? JSON.parse(v[1].trim()).total : "Value cannot be
retrieved.";
}
Then I have the URL in a cell and next a simple formula of =SAMPLE(A1)
Here’s the error I’m getting: SyntaxError: Unexpected end of JSON input (line 4).
Any help or guidance would be highly appreciated.
Thank you!