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

lastfm-autocorrect

v1.0.0

Published

An objectMode transform stream that attempts to auto-correct and enhance track metadata using Last.fm's correction API, Levenstein distance and SoundEx.

Downloads

6

Readme

lastfm-autocorrect

A transform stream in objectMode that attempts to auto-correct and enhance track metadata using Last.fm's correction API, Levenstein distance and SoundEx.

It does the following things:

  • Tries to correct the track title, artist name and album name. If any of these have been corrected the corrected property will be true and the corresponding boolean properties trackCorrected, artistCorrected, albumCorrected will be set.

  • If any of track title, artist name or album name have been corrected, the original data will be stored in the original property.

  • Will try to find the MBIDs (MusicBrainz IDs) for track title, artist name and album title and store them in trackMBID, artistMBID, albumMBID accordingly.

  • Sets a duration property containing the track duration in milliseconds. If Last.fm does not provide a duration, the average duration of all tracks that have passed through the stream will be used. In that case durationEstimated will be true.

This module requires a Last.fm API key.

Installation

npm install lastfm-autocorrect --save

Usage

var autocorrectStream = require('lastfm-autocorrect');

var autocorrect = autocorrectStream('MY_LASTFM_API_KEY_123456');

Input Format

The stream takes JavaScript objects in the following format:

{
  title: "The track title",
  artist: "The artist name",
  album: "The album title"
}

Example

var autocorrectStream = require('lastfm-autocorrect'),
    SomaStationStream = require('somastation'),
    through = require('through');

var LASTFM_API_KEY = 'MY_LASTFM_API_KEY_123456';
var groovesalad = new SomaStationStream('groovesalad');
var autocorrect = autocorrectStream(LASTFM_API_KEY);

groovesalad
    .pipe(through(function (track) {
        console.log('Original:');
        console.log(track);
        this.queue(track);
    }))
    .pipe(autocorrect)
    .pipe(through(function (track) {
        console.log('Auto-corrected:');
        console.log(track);
    }))

Output:

Original:
{ time: 1425846938000,
  artist: 'Walter Wanderly',
  title: 'Cry Out Your Sadness',
  album: 'Samba Swing' }

Auto-corrected:
{ time: 1425846938000,
  artist: 'Walter Wanderley',
  title: 'Cry Out Your Sadness',
  album: 'Samba Swing',
  trackCorrected: true,
  artistCorrected: true,
  albumCorrected: false,
  corrected: true,
  trackMBID: '013c274a-c368-4b33-89c0-6a90ca930c22',
  artistMBID: '598aa4bc-992d-4f51-8c6b-e8c860f50493',
  albumMBID: undefined,
  duration: 0,
  durationEstimated: false,
  original: 
   { time: 1425846938000,
     artist: 'Walter Wanderly',
     title: 'Cry Out Your Sadness',
     album: 'Samba Swing' } }

License

MIT License

Copyright (c) 2013 Max Kueng (http://maxkueng.com/)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.