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

plex-websocket

v1.0.3

Published

Read [Github](https://github.com/Forbidden-Duck/plex-websocket) README, in case of unpublished changes # Plex-Websocket A tool to allow JavaScript and Typescript users to aquire the full power of [plex-api](https://github.com/phillipj/node-plex-api) wit

Downloads

29

Readme

Read Github README, in case of unpublished changes

Plex-Websocket

A tool to allow JavaScript and Typescript users to aquire the full power of plex-api with Websockets
YOU DO NOT NEED TO INSTALL plex-api IT COMES WITH THE MODULE
Please note that plex-api has no type declarations so installing it might be better

npm install plex-websocket

Features

Quickly connect to a remote Plex Media Server by using a well known JavaScript Plex API tool plex-api

This will work with the plex-api authenticator tool. The websocket just needs the authToken which is provided either by you or by the authenticator module

const LOGININFO = {
    hostname: "255.255.255.255",
    username: "[email protected]",
    token: "app.plex.tv/desktop => Inspect => Application => Local Storage => myPlexAccessToken"
}; // Login information of the Plex Media User
const PlexAPI = require("plex-api");
const PlexLogin = new PlexAPI(LOGININFO); // Login with plex-api

function onPacket(type, data) {
    if (type === PlexWebsocket.WebsocketClient.PACKETTYPES.PLAYING) {
        console.log("\nPlaying State Change");
        console.log("Session IDs: ", data.PlaySessionStateNotification.map(session => session.sessionKey).join(", "));
        console.log("Rating Keys: ", data.PlaySessionStateNotification.map(session => session.ratingKey).join(", "));
        console.log("States: ", data.PlaySessionStateNotification.map(session => session.state).join(", "));
    }
} // Create a function for receiving packets

// Create a WebsocketClient with the create plex-api login and onPacket function
const WSClient = new PlexWebsocket.WebsocketClient(PlexLogin, onPacket);
WSClient.websocket.on("connect", () => console.log("Connected")); // When a successful connection is made
WSClient.websocket.on("error", err => console.log("Error\n", err)); // When an error occurs (Will terminate program)
WSClient.websocket.on("debug", message => console.log("Debug\n", message)); // Debug event for errors

Test Script

npm test

Script Location
Ensure that LOGININFO has been filled in with your information

const LOGININFO = {
    hostname: "255.255.255.255",
    username: "[email protected]",
    token: "app.plex.tv/desktop => Inspect => Application => Local Storage => myPlexAccessToken"
};