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

@jjdenhertog/plex-music-search

v1.0.5

Published

Library to find tracks in your Plex Library

Downloads

56

Readme

Plex Music Search

The plex-music-search library can be used to search for tracks in a Plex music library, building on the functionality of music-search with Plex-specific configurations.

Table of Contents

Installation

Install the plex-music-search library with npm:

npm install @jjdenhertog/plex-music-search

Usage

The library provides a straightforward API to search tracks in your Plex library. To get started, you’ll need the URI and token for your Plex server.

import PlexMusicSearch from '@jjdenhertog/plex-music-search';

const searchItems = [
    { id: "track1", title: "Shape of You", album: "Divide", artists: ["Ed Sheeran"] },
    // More items...
];

const plexMusicSearch = new PlexMusicSearch({
    uri: "https://your-plex-server-url",
    token: "your-plex-auth-token",
});

// Search for multiple tracks
const searchResult = await plexMusicSearch.search(searchItems);
console.log(searchResult);

What is with the ID while searching?

You might notice that the search query must contain an ID

const searchItems = [
    { id: "track1", title: "Shape of You", album: "Divide", artists: ["Ed Sheeran"] },
    // More items...
];

Most of the times when you're searching for a track you are doing it to match one library with the other. For example matching Spotify with Plex. The result after searching will contain the original search query including the id and the results. The results are all the tracks matching with the search query. With this approach you can trace back the results more easily.

If you do not need the id for this purpose, you can simply leave it empty:

{ id: "", title: "Shape of You", album: "Divide", artists: ["Ed Sheeran"] }

Configuration Options

The plex-music-search library supports several configuration options to customize the search behavior. Here’s a quick look at the main options:

  • uri: URL of the Plex server.
  • token: Plex authentication token.

Example:

const plexMusicSearch = new PlexMusicSearch({
    uri: "https://your-plex-server-url",
    token: "your-plex-auth-token"
});

Getting Plex URI and Token

To use plex-music-search, you’ll need your Plex server's URI and a token for authentication:

  1. URI: This is the base URL of your Plex server. You can usually find this in your Plex server settings, or by accessing Plex Web and copying the URL from your browser.

  2. Token: The Plex token is required to authenticate API requests. To find your token:

    • Open Plex Web and log in.
    • Right-click on the page and select "Inspect" or "View Page Source."
    • Look for the token in the source code (often found after the term "X-Plex-Token").

Faster searching

The default approach searches quite thoroughly through your library but as a result it can be time-consuming. By default it uses three search approaches. By limiting to only one search approach you will decrease the time searching tremendously.

const searchItems = [
    { id: "1234", title: "Shape of You", album: "Divide", artists: ["Ed Sheeran"] },
    // More items...
];

const plexMusicSearch = new PlexMusicSearch({
    uri: "https://your-plex-server-url",
    token: "your-plex-auth-token",
    searchApproaches: [{ id: 'fast', filtered: true, trimmed: false}]
});

// Search for multiple tracks
const searchResult = await plexMusicSearch.search(searchItems);

Support This Open-Source Project ❤️

If you appreciate my work, consider starring this repository or making a donation to support ongoing development. Your support means the world to me—thank you!

Buy Me a Coffee

Are you a developer and have some free time on your hand? It would be great if you can help me maintain and improve this library.