Socket
Socket
Sign inDemoInstall

plex-websocket

Package Overview
Dependencies
62
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    plex-websocket

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


Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

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: "example@gmail.com",
    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: "example@gmail.com",
    token: "app.plex.tv/desktop => Inspect => Application => Local Storage => myPlexAccessToken"
};

Keywords

FAQs

Last updated on 22 May 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc