npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

scrapefm

v1.0.1

Published

A lightweight last.fm scraper (no API key).

Downloads

17

Readme

scrapefm

A lightweight last.fm scraper. Provides access to last.fm's album, artist, track and search features through a simple, intuitive API. This module does not require an API key.

Installation

$ npm install scrapefm

Examples

var scrapefm = require('scrapefm');

scrapefm.search('ty segall', function (err, results) {
    if (!err) {
        results.forEach(function (result) {
            console.log(result.type + ': ' + result[result.type]);
        });
    }
});

// artist: Ty Segall
// artist: Ty Segall Band
// album: Melted
// album: Slaughterhouse
// ...

scrapefm.album('melted ty', function (err, album) {
    if (!err && album) {
        console.log(album.album + ' by ' + album.artist);
        album.tracks.forEach(function (track, i) {
            i++;
            console.log(i + '. ' + track.track + ' - ' + track.duration + 's');
        });
    }
});

// Melted by Ty Segall
// 1. Finger - 173s
// 2. Caesar - 183s
// ...

API

scrapefm.search(terms, [options], done)

Search last.fm website for an artist, tag, album or track.

terms is expected to be a string.

options is an optional object with the following properties:

{
    host: 'http://www.last.fm', // which base host to use for scraping
    needle: { } // options passed into each needle request
}

done returns an array of search results (in order of relevance).

scrapefm.artist(terms, [options], done)

Fetch various information about an artist.

terms is a string of the artist's name.

options is the same options described in .search.

done returns an object of the following:

{
    artist: String,
    description: String,
    listeners: Number,
    scrobbles: Number,
    tags: [ String, ... ],

    // the top <15 tracks
    tracks: [
        {
            track: String,
            listeners: Number
        },
        ...
    ],

    // the top <4 albums
    albums: [
        {
            album: String,
            listeners: Number,
            art: String
            tracks: Number
        },
        ...
    ],

    // the top <6 similar artists
    similar: [
        {
            artist: String,
            art: String
        },
        ...
    ]
}

scrapefm.album(terms, [options], done)

Fetch various information about a specific album.

terms can either be a string or an object. If terms is a string,it's searched and the first album found is used. If terms is an object, it should have the album and artist properties.

options is the same options described in .search.

done returns an object of the following:

{
    album: String,
    artist: String,
    description: String,
    released: Date,
    label: String,
    listeners: Number,
    scrobbles: Number,
    art: String, // album art URL
    tags: [ String, ... ],
    tracks: [
        {
            track: String,
            duration: Number, // seconds
            listeners: Number
        },
        ...
    ]
}

scrapefm.track(terms, [options], done)

Fetch information about a specific track.

terms can either be a string or an object. If terms is a string, it's searched and the first track is used. If terms is an object, it should have artist and track properties.

options is the same options described in .search.

done returns an object of the following:

{
    track: String,
    duration: Number,
    description: String,
    artist: String,
    album: String,
    listeners: Number,
    scrobbles: Number,
    art: String, // album art URL
    tags: [ String, ... ],
    similar: [
        {
            artist: String,
            track: String,
            duration: Number,
            listeners: Number
        },
        ...
    ]
}

License

MIT