search bandcamp using nodejs (last verified test 2020-11-09)
npm install bc-search
The interesting bits of this module are the path
and User-Agent
.
They were found by using Bandcamp's Android app with a proxied Wi-Fi connection.
see example...
var search = require('bc-search')
https.request(search("hello i am keywords"), callback).end()
example
/**
* hip nodejs style (with request)
*/
const request = require('request')
const search = require('bc-search')
let { hostname, path, headers } = search('funky music')
request({
url: `https://${hostname}${path}`,
headers: headers
}).then(handle_results)
// data = { results: [<hit>], time_ms: int }
function handle_results(data) {
console.log(data)
}
/**
* old nodejs style
*/
var http = require('http')
var search = require('bc-search')
function suggest(keywords, callback) {
http.request(search(keywords), function(res) {
var data = ''
res.on('data', function(chunk) {
data += chunk
})
res.on('end', function() {
callback(JSON.parse(data))
})
}).end()
}
suggest('funky music', handle_results)
The following keys are (somewhat) identified:
score
: search scoreurl
: link to resourceid
: resource idtype
:t
for track,a
for albumimg
: link to thumbnailart_id
: image base id?name
: name of the resource (depends on type)album_name
: only present iftype=t
album_id
: only present iftype=t
band_name
: hmm, what in the world can this be?band_id
: id of band, yes it it true
{ score: -4004,
img: 'https://f4.bcbits.com/img/a3844406641_3.jpg',
weight: 0,
band_name: 'The Dongles',
img_id: null,
band_id: 642255529,
id: 2233893224,
stat_params: 'search_item_id=2233893224&search_item_type=a&search_match_part=%3F&search_page_id=280863357&search_page_no=0&search_rank=100&search_sig=fe01036350c746db0f725b5a06d2f38d',
type: 'a',
bias: 1.02,
url: 'https://thedongles.bandcamp.com/album/junky-music',
part: 't',
art_id: 3844406641,
name: 'Junky Music'
}