Package Exports
- bandcamp-scraper
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (bandcamp-scraper) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
bandcamp-scraper
A scraper for https://bandcamp.com
The scraper allow you to:
- search
artist,album,track,fan - get album urls from an artist url
- get album info from an album url
- get album products from an album url
Why ?
Because Bandcamp has shut down there public API and don't plan to-reopen it.
https://bandcamp.com/developer
Installation
npm i --save bandcamp-scraperUsage
search(params, callback)
Search any resources that matches the given params.query for the current params.page.
- params Object
- query String
- page Integer (default
1)
- callback Function(error, searchResults)
Search Results
An array of resources that have different properties depending on the type. Every resource matches the search-result JSON schema.
artist
- type: String
- name: String
- url: String
- imageUrl: String
- tags: Array
- genre: String
- location: String
album
- type: String
- name: String
- url: String
- imageUrl: String
- tags: Array
- releaseDate: String
- artist: String
- numTracks: Integer
- numMinutes: Integer
track
- type: String
- name: String
- url: String
- imageUrl: String
- tags: Array
- releaseDate: String
- album: String
- artist: String
fan
- type: String
- name: String
- url: String
- imageUrl: String
- tags: Array
- genre: String
Example
var bandcamp = require('bandcamp-scraper');
var params = {
query: 'Coeur de pirate',
page: 1
};
bandcamp.search(params, function(error, searchResults) {
if (error) {
console.log(error);
} else {
console.log(searchResults);
}
});getAlbumUrls(artistUrl, callback)
Retrieve the album URLs from an artist URL.
- artistUrl String
- callback Function(error, albumUrls)
Example
var bandcamp = require('bandcamp-scraper');
var artistUrl = 'http://musique.coeurdepirate.com/';
bandcamp.getAlbumUrls(artistUrl, function(error, albumUrls) {
if (error) {
console.log(error);
} else {
console.log(albumUrls);
}
});getAlbumProducts(albumUrl, callback)
Retrieves all the album's products of from its URL.
- albumUrl String
- callback Function(error, albumProducts)
Album Products
An array album products that matches the album-product JSON schema.
- name: String
- format: String
- url: String
- imageUrls Array
- priceInCents Integer
- description String
- soldOut Boolean
- nameYourPrice Boolean (voluntary contribution)
- offerMore Boolean (accepts more than the
priceInCents) - currency Boolean (3 letters)
Example
var bandcamp = require('bandcamp-scraper');
var albumUrl = 'http://musique.coeurdepirate.com/album/blonde';
bandcamp.getAlbumProducts(albumUrl, function(error, albumProducts) {
if (error) {
console.log(error);
} else {
console.log(albumProducts);
}
});getAlbumInfo(albumUrl, callback)
Retrieves the album's info of from its URL.
- albumUrl String
- callback Function(error, albumInfo)
Album Info
An Object that represents the album's info. It matches the album-info JSON schema.
- artist: String
- title: String
- url: String
- imageUrl String
- tracks Array (See below)
- raw Object (js variable
TralbumDatahidden in the html)
Track
- name String
- url String
- duration String
Example
var bandcamp = require('bandcamp-scraper');
var albumUrl = 'http://musique.coeurdepirate.com/album/blonde';
bandcamp.getAlbumInfo(albumUrl, function(error, albumInfo) {
if (error) {
console.log(error);
} else {
console.log(albumInfo);
}
});Change Log
1.0.0 (2016-07-25)
- rename resource property
image->imageUrl - rename resource property
images->imageUrls - rename resource property
link->url - rename resource property
from->location - rename resource property
orMore->offerMore - remove resource property
numRemaining
Test
npm testContributing
Contribution is welcome! Open an issue first.
License
MIT.