Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/masterT/bandcamp-scraper
A scraper for https://bandcamp.com
https://github.com/masterT/bandcamp-scraper
album api artist bandcamp hacktoberfest product scraper
Last synced: 17 days ago
JSON representation
A scraper for https://bandcamp.com
- Host: GitHub
- URL: https://github.com/masterT/bandcamp-scraper
- Owner: masterT
- License: mit
- Created: 2015-08-30T21:59:03.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2024-06-24T21:05:30.000Z (5 months ago)
- Last Synced: 2024-08-11T10:12:47.072Z (3 months ago)
- Topics: album, api, artist, bandcamp, hacktoberfest, product, scraper
- Language: JavaScript
- Homepage:
- Size: 284 KB
- Stars: 191
- Watchers: 11
- Forks: 34
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# bandcamp-scraper
[![npm version](https://badge.fury.io/js/bandcamp-scraper.svg)](https://badge.fury.io/js/bandcamp-scraper)
![Test](https://github.com/masterT/bandcamp-scraper/workflows/Test/badge.svg?event=push)
![Test daily](https://github.com/masterT/bandcamp-scraper/workflows/Test/badge.svg?event=schedule)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)[![Bandcamp Logo](assets/bandcamp.png)](https://bandcamp.com)
> A scraper for https://bandcamp.com
The scraper allows you to:
- search `artist`, `album`, `track`, `fan`, `label`
- get album urls from an artist url
- get album info from an album url
- get album products from an album url
- get artist info from an artist url#### Why ?
Because Bandcamp has shut down their public API and don't plan to reopen it.
[https://bandcamp.com/developer](https://bandcamp.com/developer)
## Installation
```bash
npm i --save bandcamp-scraper
```## Usage
### `search(params, callback)`
Search any resources that match 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 their _type_ property: **artist**, **album**, **track**, **fan**, or **label**.
Every resource matches the [search-result JSON schema](/schemas/search-result.json).
#### Example
```js
const bandcamp = require('bandcamp-scraper')const params = {
query: 'Coeur de pirate',
page: 1
}bandcamp.search(params, function (error, searchResults) {
if (error) {
console.log(error)
} else {
console.log(searchResults)
}
})
```[View example with output](examples/search.js).
### `getAlbumsWithTag(params, callback)`
Search for albums with the tag `params.tag` for the current `params.page`.
- params _Object_ - tag _String_ - page _Integer_ (default `1`)
- callback _Function(error, tagResults)_#### Tag Results
An array of album information. Matches the [tag-result JSON schema](/schemas/tag-result.json).
#### Example
```js
const bandcamp = require('bandcamp-scraper')const params = {
tag: 'nuwrld',
page: 1
}bandcamp.getAlbumsWithTag(params, function (error, tagResults) {
if (error) {
console.log(error)
} else {
console.log(tagResults)
}
})
```[View example with output](examples/tag.js).
### `getAlbumUrls(artistUrl, callback)`
Retrieve the album URLs from an artist URL.
Please note: for Bandcamp labels you may want to use the `getArtistsUrls` function to retrieve the list of signed artists first.- artistUrl _String_
- callback _Function(error, albumUrls)_#### Example
```js
const bandcamp = require('bandcamp-scraper')const artistUrl = 'http://musique.coeurdepirate.com/'
bandcamp.getAlbumUrls(artistUrl, function (error, albumUrls) {
if (error) {
console.log(error)
} else {
console.log(albumUrls)
}
})
```[View example with output](examples/getAlbumUrls.js).
### `getAlbumProducts(albumUrl, callback)`
Retrieves all the album's products from its URL.
- albumUrl _String_
- callback _Function(error, albumProducts)_#### Album Products
An array of album products that matches the [album-product JSON schema](/schemas/album-product.json).
#### Example
```js
const bandcamp = require('bandcamp-scraper')const albumUrl = 'http://musique.coeurdepirate.com/album/blonde'
bandcamp.getAlbumProducts(albumUrl, function (error, albumProducts) {
if (error) {
console.log(error)
} else {
console.log(albumProducts)
}
})
```[View example with output](examples/getAlbumProducts.js).
### `getAlbumInfo(albumUrl, callback)`
Retrieves the album's info 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](/schemas/album-info.json).
#### Example
```js
const bandcamp = require('bandcamp-scraper')const albumUrl = 'http://musique.coeurdepirate.com/album/blonde'
bandcamp.getAlbumInfo(albumUrl, function (error, albumInfo) {
if (error) {
console.log(error)
} else {
console.log(albumInfo)
}
})
```[View example with output](examples/getAlbumInfo.js).
### `getArtistUrls(labelUrl, callback)`
Retrieves an array of artist URLs from a label's URL for further scraping.
- labelUrl _String_
- callback _Function(error, albumInfo)_#### Example
```js
const bandcamp = require('bandcamp-scraper')const labelUrl = 'https://randsrecords.bandcamp.com'
bandcamp.getArtistUrls(labelUrl, function (error, artistsUrls) {
if (error) {
console.log(error)
} else {
console.log(artistsUrls)
}
})
```[View example with output](examples/getArtistUrls.js).
### `getArtistInfo(artistUrl, callback)`
Retrieves the artist's info from its URL.
- artistUrl _String_
- callback _Function(error, artistInfo)_#### Artist Info
An _Object_ that represents the artist's info. It matches the [artist-info JSON schema](/schemas/artist-info.json).
#### Example```js
const bandcamp = require('bandcamp-scraper')const artistUrl = 'http://musique.coeurdepirate.com'
bandcamp.getArtistInfo(artistUrl, function (error, artistInfo) {
if (error) {
console.log(error)
} else {
console.log(artistInfo)
}
})
```[View example with output](examples/getArtistInfo.js).
### `getTrackInfo(trackUrl, callback)`
Retrieves the track info from its URL.
- trackUrl _String_
- callback _Function(error, trackInfo)_#### Track Info
An _Object_ that represents the track's info. It matches the [track-info JSON schema](/schemas/track-info.json).
#### Example```js
const bandcamp = require('bandcamp-scraper')const trackUrl = 'https://dafnez.bandcamp.com/track/serenade'
bandcamp.getTrackInfo(trackUrl, function (error, trackInfo) {
if (error) {
console.log(error)
} else {
console.log(trackInfo)
}
})
```## Test
Feature tests are run _daily_, thanks to [GitHub Action](https://docs.github.com/en/free-pro-team@latest/actions) schedule actions. This way we know if the scraper is ever broken.
Run the test:
```bash
npm test
```## Contributing
Contribution is welcome! Open an issue first.
## License
MIT.