mirror of
https://github.com/LukeHagar/plexjs.git
synced 2025-12-06 12:37:46 +00:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc9335abcf | ||
|
|
792fedc759 | ||
|
|
e343455e77 | ||
|
|
7a7931b0d0 | ||
|
|
b3c26fd1a7 | ||
|
|
26fa0aef86 | ||
|
|
74ecefac8b | ||
|
|
8855195c09 | ||
|
|
227636620e | ||
|
|
5866739942 | ||
|
|
0eacb0e7c4 | ||
|
|
c0efb9a732 | ||
|
|
71484de76e | ||
|
|
be73efff0b | ||
|
|
a00c394526 | ||
|
|
3d57b22b26 | ||
|
|
995bbedbb6 |
@@ -5,7 +5,7 @@ files:
|
|||||||
destinationFilename: package.json
|
destinationFilename: package.json
|
||||||
npmName: plexjs
|
npmName: plexjs
|
||||||
npmRepository: lukehagar
|
npmRepository: lukehagar
|
||||||
npmVersion: 0.0.20
|
npmVersion: 0.0.21
|
||||||
useSingleRequestParameter: true
|
useSingleRequestParameter: true
|
||||||
sortParamsByRequiredFlag: true
|
sortParamsByRequiredFlag: true
|
||||||
gitUserID: lukehagar
|
gitUserID: lukehagar
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"trailingComma": "all",
|
|
||||||
"singleQuote": true,
|
|
||||||
"printWidth": 80
|
|
||||||
}
|
|
||||||
@@ -5,25 +5,21 @@
|
|||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "rimraf ./build && tsc",
|
"build": "rimraf ./build && tsc",
|
||||||
"start:dev": "npx nodemon",
|
"dev": "npx nodemon",
|
||||||
"start": "npm run build && node build/index.js"
|
"start": "npm run build && node build/index.js"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@lukehagar/plexjs": "^0.0.19",
|
"@lukehagar/plexjs": "^0.0.20",
|
||||||
"@types/jest": "^29.5.0",
|
"@types/jest": "^29.5.0",
|
||||||
"@types/node": "^18.6.1",
|
"@types/node": "^18.6.1",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.31.0",
|
"@typescript-eslint/eslint-plugin": "^5.31.0",
|
||||||
"@typescript-eslint/parser": "^5.31.0",
|
"@typescript-eslint/parser": "^5.31.0",
|
||||||
"eslint": "^8.20.0",
|
"dotenv": "^16.0.3",
|
||||||
"eslint-config-prettier": "^8.5.0",
|
|
||||||
"eslint-plugin-jest": "^27.2.1",
|
|
||||||
"eslint-plugin-prettier": "^4.2.1",
|
|
||||||
"nodemon": "^2.0.19",
|
"nodemon": "^2.0.19",
|
||||||
"onchange": "^7.1.0",
|
"onchange": "^7.1.0",
|
||||||
"prettier": "^2.7.1",
|
|
||||||
"rimraf": "^5.0.0",
|
"rimraf": "^5.0.0",
|
||||||
"run-script-os": "^1.1.6",
|
"run-script-os": "^1.1.6",
|
||||||
"ts-node": "^10.9.1",
|
"ts-node": "^10.9.1",
|
||||||
|
|||||||
@@ -1,9 +1,19 @@
|
|||||||
// eslint-disable-next-line no-console
|
import {
|
||||||
import { Configuration, ServerApi } from '@lukehagar/plexjs';
|
Configuration,
|
||||||
|
ServerApi,
|
||||||
|
DevicesApi,
|
||||||
|
UserApi,
|
||||||
|
} from "@lukehagar/plexjs";
|
||||||
|
import dotenv from "dotenv";
|
||||||
|
dotenv.config();
|
||||||
|
|
||||||
const config = new Configuration({ basePath: 'http://10.10.10.47:32400' });
|
const config = new Configuration({
|
||||||
const api = new ServerApi(config);
|
basePath: process.env.BASE_PATH,
|
||||||
|
plexToken: process.env.PLEX_TOKEN,
|
||||||
|
});
|
||||||
|
|
||||||
api.getServerCapabilities();
|
new ServerApi(config).getServerCapabilities().then((resp) => console.log(resp));
|
||||||
|
|
||||||
console.log('Hello world!');
|
new DevicesApi(config).getDevices().then((resp) => console.log(resp));
|
||||||
|
|
||||||
|
new UserApi(config).getUserDetails().then((resp) => console.log(resp));
|
||||||
|
|||||||
1142
examples/yarn.lock
1142
examples/yarn.lock
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
|||||||
## plexjs@0.0.20
|
## plexjs@0.0.21
|
||||||
|
|
||||||
This generator creates TypeScript/JavaScript client that utilizes [axios](https://github.com/axios/axios). The generated Node module can be used in the following environments:
|
This generator creates TypeScript/JavaScript client that utilizes [axios](https://github.com/axios/axios). The generated Node module can be used in the following environments:
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ navigate to the folder of your consuming project and run one of the following co
|
|||||||
_published:_
|
_published:_
|
||||||
|
|
||||||
```
|
```
|
||||||
npm install plexjs@0.0.20 --save
|
npm install plexjs@0.0.21 --save
|
||||||
```
|
```
|
||||||
|
|
||||||
_unPublished (not recommended):_
|
_unPublished (not recommended):_
|
||||||
|
|||||||
2571
plexjs/api.ts
2571
plexjs/api.ts
File diff suppressed because it is too large
Load Diff
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
import { IAxiosRetryConfig } from "axios-retry";
|
import { IAxiosRetryConfig } from "axios-retry";
|
||||||
|
|
||||||
export interface ConfigurationParameters {
|
export type ConfigurationParameters = {
|
||||||
plexToken?: string;
|
plexToken?: string;
|
||||||
clientIdentifier?: string;
|
clientIdentifier?: string;
|
||||||
device?: string;
|
device?: string;
|
||||||
@@ -90,7 +90,7 @@ export class Configuration {
|
|||||||
* @memberof Configuration
|
* @memberof Configuration
|
||||||
*/
|
*/
|
||||||
version?: string;
|
version?: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* parameter for apiKey security
|
* parameter for apiKey security
|
||||||
* @param name security name
|
* @param name security name
|
||||||
@@ -134,12 +134,12 @@ export class Configuration {
|
|||||||
constructor(param: ConfigurationParameters = {}) {
|
constructor(param: ConfigurationParameters = {}) {
|
||||||
this.plexToken = param.plexToken;
|
this.plexToken = param.plexToken;
|
||||||
this.clientIdentifier = param.clientIdentifier || "Plexjs";
|
this.clientIdentifier = param.clientIdentifier || "Plexjs";
|
||||||
this.device = param.device || "Unspecified";
|
this.device = param.device;
|
||||||
this.deviceName = param.deviceName || "Unspecified";
|
this.deviceName = param.deviceName;
|
||||||
this.platform = param.platform || "Plexjs";
|
this.platform = param.platform || "Plexjs";
|
||||||
this.platformVersion = param.platformVersion || process.env.npm_package_version;
|
this.platformVersion = param.platformVersion;
|
||||||
this.product = param.product || "Plexjs";
|
this.product = param.product;
|
||||||
this.version = param.version || process.env.npm_package_version;
|
this.version = param.version;
|
||||||
|
|
||||||
this.apiKey = (header: string) => {
|
this.apiKey = (header: string) => {
|
||||||
switch (header) {
|
switch (header) {
|
||||||
|
|||||||
4
plexjs/package-lock.json
generated
4
plexjs/package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@lukehagar/plexjs",
|
"name": "@lukehagar/plexjs",
|
||||||
"version": "0.0.20",
|
"version": "0.0.21",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@lukehagar/plexjs",
|
"name": "@lukehagar/plexjs",
|
||||||
"version": "0.0.20",
|
"version": "0.0.21",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.26.1",
|
"axios": "^0.26.1",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@lukehagar/plexjs",
|
"name": "@lukehagar/plexjs",
|
||||||
"version": "0.0.20",
|
"version": "0.0.21",
|
||||||
"description": "Community Made Plex JS/TS Module",
|
"description": "Community Made Plex JS/TS Module",
|
||||||
"author": "Luke Hagar",
|
"author": "Luke Hagar",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
36
readme.md
36
readme.md
@@ -2,10 +2,42 @@
|
|||||||
|
|
||||||
## Description
|
## Description
|
||||||
|
|
||||||
A typescript sdk for accessing the Plex.tv and Plex Media Server REST API's.
|
A typescript sdk for interacting with Plex.tv and Plex Media Server REST API's.
|
||||||
|
|
||||||
|
Documentation for all of the available endpoints [can be found here](https://plexapi.dev/docs/plex)
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
npm
|
||||||
```bash
|
```bash
|
||||||
npm install plexjs
|
npm install @lukehagar/plexjs
|
||||||
|
```
|
||||||
|
|
||||||
|
yarn
|
||||||
|
```bash
|
||||||
|
yarn add @lukehagar/plexjs
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
import {
|
||||||
|
Configuration,
|
||||||
|
ServerApi,
|
||||||
|
DevicesApi,
|
||||||
|
UserApi,
|
||||||
|
} from "@lukehagar/plexjs";
|
||||||
|
import dotenv from "dotenv";
|
||||||
|
dotenv.config();
|
||||||
|
|
||||||
|
const config = new Configuration({
|
||||||
|
basePath: process.env.BASE_PATH,
|
||||||
|
plexToken: process.env.PLEX_TOKEN,
|
||||||
|
});
|
||||||
|
|
||||||
|
new ServerApi(config).getServerCapabilities().then((resp) => console.log(resp));
|
||||||
|
|
||||||
|
new DevicesApi(config).getDevices().then((resp) => console.log(resp));
|
||||||
|
|
||||||
|
new UserApi(config).getUserDetails().then((resp) => console.log(resp));
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
{{>licenseInfo}}
|
{{>licenseInfo}}
|
||||||
import { IAxiosRetryConfig } from "axios-retry";
|
import { IAxiosRetryConfig } from "axios-retry";
|
||||||
|
|
||||||
export interface ConfigurationParameters {
|
export type ConfigurationParameters = {
|
||||||
plexToken?: string;
|
plexToken?: string;
|
||||||
clientIdentifier?: string;
|
clientIdentifier?: string;
|
||||||
device?: string;
|
device?: string;
|
||||||
@@ -79,7 +79,7 @@ export class Configuration {
|
|||||||
* @memberof Configuration
|
* @memberof Configuration
|
||||||
*/
|
*/
|
||||||
version?: string;
|
version?: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* parameter for apiKey security
|
* parameter for apiKey security
|
||||||
* @param name security name
|
* @param name security name
|
||||||
@@ -123,12 +123,12 @@ export class Configuration {
|
|||||||
constructor(param: ConfigurationParameters = {}) {
|
constructor(param: ConfigurationParameters = {}) {
|
||||||
this.plexToken = param.plexToken;
|
this.plexToken = param.plexToken;
|
||||||
this.clientIdentifier = param.clientIdentifier || "Plexjs";
|
this.clientIdentifier = param.clientIdentifier || "Plexjs";
|
||||||
this.device = param.device || "Unspecified";
|
this.device = param.device;
|
||||||
this.deviceName = param.deviceName || "Unspecified";
|
this.deviceName = param.deviceName;
|
||||||
this.platform = param.platform || "Plexjs";
|
this.platform = param.platform || "Plexjs";
|
||||||
this.platformVersion = param.platformVersion || process.env.npm_package_version;
|
this.platformVersion = param.platformVersion;
|
||||||
this.product = param.product || "Plexjs";
|
this.product = param.product;
|
||||||
this.version = param.version || process.env.npm_package_version;
|
this.version = param.version;
|
||||||
|
|
||||||
this.apiKey = (header: string) => {
|
this.apiKey = (header: string) => {
|
||||||
switch (header) {
|
switch (header) {
|
||||||
|
|||||||
Reference in New Issue
Block a user