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

music-library-index

v2.1.0

Published

build a searchable javascript object model given track metadata objects

Downloads

13

Readme

Music Library Index

Given track metadata objects, constructs a searchable object model. This module is used both in the client and the server of Groove Basin.

Features

  • Sort order ignores 'a', 'an' and 'the' in artists, albums, and names.
  • Sorting and searching is case insensitive and diacritics-insensitive.
  • Searching uses word-based filtering (this is how most music player applications implement filtering) on all track fields.
  • Distinguishes albums by name, date, and album artist.
  • Produces these indexes:
    • Artists in sorted order
      • For each of these artists, albums in sorted order.
        • For each of these albums, tracks in sorted order.
    • Albums in sorted order
      • For each of these albums, tracks in sorted order.
    • Tracks by user-defined key.
    • Artists by library-defined key.
    • Albums by library-defined key.
  • Searching allows the use of special constructs:
    • Quoted terms ("...") exactly match every character, including spaces, upper- and lower-case letters, and characters with diacritics. Inside quotes, use \" for a literal quote and \\ for a literal backslash.
    • Terms starting with not: match anything not matched by the rest of the term. For example metal not:metalica or just not:"Justin Bieber".
    • Parentheses can be used to group terms. For example tool not:(opiate live).
    • Use or:(...) to match any of the terms in the parentheses. For example or:(chopin mozart bach). Use further nested parentheses to return to "and"-style matching. For example or:(chopin mozart (johann sebastian bach)).

Usage

var MusicLibraryIndex = require('music-library-index');
var library = new MusicLibraryIndex();

library.addTrack({
  key: "Anberlin/Never Take Friendship Personal/02. Paperthin Hymn.mp3",
  name: "Paperthin Hymn",
  artistName: "Anberlin",
  albumName: "Never Take Friendship Personal",
  year: 2005,
  genre: "Other",
  track: 2,
  albumArtistName: "Anberlin",
});

library.addTrack({
  key: "Anberlin/Never Take Friendship Personal/08. The Feel Good Drag.mp3",
  name: "The Feel Good Drag",
  artistName: "Anberlin",
  albumName: "Never Take Friendship Personal",
  year: 2005,
  genre: "Other",
  track: 8,
  albumArtistName: "Anberlin",
  label: {"favorites_id": 1},
});

library.rebuildTracks();

library.addLabel({
  id: "favorites_id",
  name: "favorites",
});

library.rebuildLabels();

console.log(library.artistList[0]);
console.log(library.trackTable);

Tests

  basic index building
    ✓ trackTable 
    ✓ artistList 
    ✓ albumList 
    ✓ searching 

  compilation album
    ✓ filed in various artists 

  tracks from same album missing year metadata
    ✓ still knows they're in the same album 

  different albums with same name
    ✓ detects that they are different 

  album with a few tracks by different artists
    ✓ only creates one album 

  album by an artist
    ✓ should be filed under the artist 

  album by an artist
    ✓ sorts by disc before track 

  album artist with no album
    ✓ shouldn't be various artists 

  unknown artist, unknown album
    ✓ should be put into the same album 
    ✓ searching should not affect anything 

  album with album artist
    ✓ shouldn't be various artists