Wikifonia scraper
Simple scraper for the wonderful Wikifonia.
This scrapes the search pages, and returns a list of track
objects, which
contains information such as, title, artist(s), performer(s), lyricist(s) and
Wikifonia ID.
Install
$ npm install wikifonia
Usage
The one method in this library, is the search
function:
wikifonia.search({ artist, title, page }) -> { tracks, pages }
Takes an object, with one or more of above parameters.
- artist: The name of the sheet author
- title: The title of the sheet
- page: The first page of the search results is 0, the second is 1, etc.
Returns a Promise
of an object with two properties:
{
tracks: [], // Array of tracks
pages: 1 // Number of pages (zero-indexed)
}
Each track
has the following properties:
track = {
title: String,
artist: String | Array(String),
performer: String | Array(String),
lyricist: String | Array(String),
id: String
}
The syntax looks like this:
var wikifonia = require('wikifonia');
wikifonia.search({ artist: 'Charlie Parker' })
.then(function(res) {
var tracks = res.tracks;
var pages = res.pages;
// Now do something nice with all your Charlie Parker tracks!
});
wikifonia.search({ title: 'Scrapple from the Apple' })
.then(function(res) {
var tracks = res.tracks;
var pages = res.pages;
// Do something with you Scrapple from the Apple track(s)
});
wikifonia.stream(track | trackID) -> WritableStream
Oh yea, there's one more convenience method to get a stream from which you can download the compressed MusicXML file (.mxl) directly
wikifonia.search({ title: 'Jump Monk' }).then(function(res) {
// Take the first track
var track = res.tracks[0];
// Stream it to a local file
wikifonia.stream(track).pipe(fs.createWriteStream('jump_monk.mxl'));
});
The method takes either a track (as returned from the search
method) or a
track ID (which is also part of the track
object returned from the search
method)