|
//spotify_songkick_api_opester_fork.js |
|
|
|
import fs from 'fs' |
|
import fetch from 'node-fetch'; |
|
|
|
let fetch_response_output_filename = "direct-events-charley-crockett.json" |
|
//TODO: add artistId extraction to sha extraction below |
|
|
|
// adjust song artist to get concerts for different artists |
|
let artistId = "3BJX1nYizKvWpZTY5HOAr4" |
|
|
|
let variables = encodeURIComponent(JSON.stringify({ |
|
"artistId": `spotify:artist:${artistId}` |
|
})) |
|
|
|
// you dont really need to adjust this. that still works even with the same sha key and different artists |
|
// to get your sha256Hash value, copy in fetch query URL and extract code from there |
|
|
|
//let fetch_str = "https://api-partner.spotify.com/pathfinder/v1/query?operationName=artistConcerts&variables=%7B%22artistId%22%3A%22spotify%3Aartist%3A3BJX1nYizKvWpZTY5HOAr4%22%7D&extensions=%7B%22persistedQuery%22%3A%7B%22version%22%3A1%2C%22sha256Hash%22%3A%22ce78fdb28c5036de6d81bbc45571b62e2201a0c08eb068ab17dd3428396026f5%22%7D%7D"; |
|
let fetch_str = "Your_Request_URL_Value" |
|
|
|
// Remove all text before "sha" |
|
let sha256Hash = fetch_str.substring(fetch_str.indexOf("sha")); |
|
|
|
// Remove specific substrings |
|
sha256Hash = sha256Hash.replace("%22%3A%22", "").replace("%22%7D%7D", "").replace("sha256Hash", ""); |
|
|
|
let extension = encodeURIComponent(JSON.stringify({ "persistedQuery": { "version": 1, "sha256Hash": `${sha256Hash}`}})) |
|
let operation = "artistConcerts" |
|
|
|
let authorization = "<Your_Authorization_Value>" |
|
let client_token = "<Your_Client-Token_Value>" |
|
|
|
fetch(`https://api-partner.spotify.com/pathfinder/v1/query?operationName=${operation}&variables=${variables}&extensions=${extension}`, { |
|
"headers": { |
|
"accept": "application/json", |
|
"accept-language": "en", |
|
"app-platform": "WebPlayer", |
|
"cache-control": "no-cache", |
|
"authorization": `${authorization}`, |
|
"client-token": `${client_token}`, |
|
"content-type": "application/json;charset=UTF-8", |
|
"pragma": "no-cache", |
|
"priority": "u=1, i", |
|
"sec-ch-ua": "\"Not/A)Brand\";v=\"8\", \"Chromium\";v=\"126\", \"Google Chrome\";v=\"126\"", |
|
"sec-ch-ua-mobile": "?0", |
|
"sec-ch-ua-platform": "\"Windows\"", |
|
"sec-fetch-dest": "empty", |
|
"sec-fetch-mode": "cors", |
|
"sec-fetch-site": "same-site", |
|
"spotify-app-version": "1.2.41.282.g67f2a22e", |
|
"Referer": "https://open.spotify.com/", |
|
"Referrer-Policy": "strict-origin-when-cross-origin" |
|
}, |
|
"body": null, |
|
"method": "GET" |
|
}) |
|
.then(response => response.json()) |
|
.then(data => { |
|
console.log(data) |
|
fs.writeFileSync(`${fetch_response_output_filename}`, JSON.stringify( |
|
data |
|
, null, 2)) |
|
}) |