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

plexacious

v0.3.0

Published

A library to facilitate talking to a Plex server via its web API.

Downloads

3

Readme

plexacious

npm version Build Status Known Vulnerabilities

A Plex bot library for integration with chat bots.

:warning: Warning

This package should be consider unstable. APIs may change between 0.x releases as I continue to work on it.

Installation

npm install plexacious
npm run configure

Usage

Initialize

const Plexacious = require('plexacious');
const config = require('./config');

const bot = new Plexacious();

bot.init(config) // Alternatively, construct your own config object and pass it in

API

init

init(config)

Set up the Plex server information and start the digest timer.

Parameters
  • {Object} config: The configuration settings for the Plex server connection.
Return

Returns the Plexacious object instance for method chaining.

Example
bot.init({
  hostname: 'localhost',
  port: 1234,
  https: false,
  token: 'abcdefg',
  refreshDuration: 30,
});

setRefreshDuration

setRefreshDuration(timer)

Clear the current digest timer and set a new interval timer for the digest process. This will also cause the digest to run immediately (so that it's not possible to indefinitely delay the digest by constantly changing the timer).

Parameters:
  • {integer} timer: The desired interval between digest processes, in minutes.
Return:

Returns the Plexacious object instance for method chaining.

Example:
bot.setRefreshDuration(30);

on

on(event[, callback])

Attach or detach a callback function to an event

Parameters:
  • {string} event: The event to which to attach or from which to detach the callback function.
  • {function} callback: (optional) The callback function to attach to the event. If not provided, the existing callback function on this event will be detached, if any.
Return:

Returns the Plexacious object instance for method chaining.

Example:
bot.on('mediaAdded', (media) => console.log(media.title));

query

query(path)

Performs a GET action on the provided path on the Plex server, and returns the objects

Parameters:
  • {string} path: The API path to request
Return:

A Promise that resolves to an array of objects

Example:
let library = await bot.query('/library');
bot.query('/library').then(things => {
  console.dir(things);
});

Events

init

Called when the bot instantiates, just before calling the digest function for the first time.

Example:
bot.on('init', () => console.log('Bot startup'));

startDigest

Called every time the digest starts, before any calls to the Plex API are made.

endDigest

Called every time the digest ends, after all API calls.

newSession

Called when a new streaming session is detected. Takes the session object as an argument.

endSession

Called when a streaming session is detected to have ended. Takes the session object as an argument.

newMedia

Called when a new piece of media has been discovered in Plex's "Recently Added" section. Takes the media object as an argument.

Example:
bot.on('newMedia', (media) => console.log(media.title));