mirror of
https://github.com/LukeHagar/plexjs.git
synced 2025-12-07 12:37:45 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d638acb5d2 | ||
|
|
f87006d3e8 | ||
|
|
fcab6f2532 | ||
|
|
4c552faaf5 | ||
|
|
7ea8776750 | ||
|
|
b9487a78df |
5
.github/workflows/bump_version.yml
vendored
5
.github/workflows/bump_version.yml
vendored
@@ -5,11 +5,6 @@ on:
|
||||
inputs:
|
||||
version:
|
||||
description: The version to bump to
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- plexjs/**
|
||||
|
||||
jobs:
|
||||
update_typescript_version:
|
||||
|
||||
@@ -5,7 +5,7 @@ files:
|
||||
destinationFilename: package.json
|
||||
npmName: plexjs
|
||||
npmRepository: lukehagar
|
||||
npmVersion: 0.0.19
|
||||
npmVersion: 0.0.20
|
||||
useSingleRequestParameter: true
|
||||
sortParamsByRequiredFlag: true
|
||||
gitUserID: lukehagar
|
||||
|
||||
@@ -6,45 +6,28 @@
|
||||
"scripts": {
|
||||
"build": "rimraf ./build && tsc",
|
||||
"start:dev": "npx nodemon",
|
||||
"start": "npm run build && node build/index.js",
|
||||
"lint": "eslint . --ext .ts",
|
||||
"prettier-format": "run-script-os",
|
||||
"prettier-format:win32": "prettier --config .prettierrc \"./src/**/*.ts\" --write",
|
||||
"prettier-format:darwin:linux": "prettier --config .prettierrc 'src/**/*.ts' --write",
|
||||
"prettier-format:default": "prettier --config .prettierrc 'src/**/*.ts' --write",
|
||||
"prettier-watch": "run-script-os",
|
||||
"prettier-watch:win32": "onchange \"src/**/*.ts\" -- prettier --write {{changed}}",
|
||||
"prettier-watch:darwin:linux": "onchange 'src/**/*.ts' -- prettier --write {{changed}}",
|
||||
"prettier-watch:default": "onchange 'src/**/*.ts' -- prettier --write {{changed}}"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "npm run test && npm run prettier-format && npm run lint"
|
||||
}
|
||||
"start": "npm run build && node build/index.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"@lukehagar/plexjs": "^0.0.18",
|
||||
"@types/jest": "^28.1.8",
|
||||
"@lukehagar/plexjs": "^0.0.19",
|
||||
"@types/jest": "^29.5.0",
|
||||
"@types/node": "^18.6.1",
|
||||
"@typescript-eslint/eslint-plugin": "^5.31.0",
|
||||
"@typescript-eslint/parser": "^5.31.0",
|
||||
"eslint": "^8.20.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"eslint-plugin-jest": "^26.6.0",
|
||||
"eslint-plugin-jest": "^27.2.1",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"husky": "^8.0.1",
|
||||
"jest": "^28.1.3",
|
||||
"nodemon": "^2.0.19",
|
||||
"onchange": "^7.1.0",
|
||||
"prettier": "^2.7.1",
|
||||
"rimraf": "^3.0.2",
|
||||
"rimraf": "^5.0.0",
|
||||
"run-script-os": "^1.1.6",
|
||||
"ts-jest": "^28.0.7",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "^4.7.4"
|
||||
"typescript": "^5.0.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"jest-cucumber": "^3.0.1"
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// eslint-disable-next-line no-console
|
||||
import { Configuration, DevicesApi } from '@lukehagar/plexjs';
|
||||
import { Configuration, ServerApi } from '@lukehagar/plexjs';
|
||||
|
||||
let config = new Configuration({ basePath: 'http://localhost:80' });
|
||||
const config = new Configuration({ basePath: 'http://10.10.10.47:32400' });
|
||||
const api = new ServerApi(config);
|
||||
|
||||
api.getServerCapabilities();
|
||||
|
||||
console.log('Hello world!');
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
## plexjs@0.0.19
|
||||
## plexjs@0.0.20
|
||||
|
||||
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:_
|
||||
|
||||
```
|
||||
npm install plexjs@0.0.19 --save
|
||||
npm install plexjs@0.0.20 --save
|
||||
```
|
||||
|
||||
_unPublished (not recommended):_
|
||||
|
||||
630
plexjs/api.ts
630
plexjs/api.ts
File diff suppressed because it is too large
Load Diff
@@ -15,13 +15,82 @@
|
||||
import { IAxiosRetryConfig } from "axios-retry";
|
||||
|
||||
export interface ConfigurationParameters {
|
||||
|
||||
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
|
||||
plexToken?: string;
|
||||
clientIdentifier?: string;
|
||||
device?: string;
|
||||
deviceName?: string;
|
||||
platform?: string;
|
||||
platformVersion?: string;
|
||||
product?: string;
|
||||
version?: string;
|
||||
basePath?: string;
|
||||
|
||||
}
|
||||
|
||||
export class Configuration {
|
||||
/**
|
||||
* Plex Media Server or Plex.TV Authentication token
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
plexToken?: string;
|
||||
|
||||
/**
|
||||
* UUID, serial number, or other number unique per device
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
clientIdentifier?: string;
|
||||
|
||||
/**
|
||||
* Device name and model number, eg iPhone3,2, Motorola XOOM™, LG5200TV
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
device?: string;
|
||||
|
||||
/**
|
||||
* Customized Device Name
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
deviceName?: string;
|
||||
|
||||
/**
|
||||
* Platform name, eg iOS, MacOSX, Android, LG, etc
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
platform?: string;
|
||||
|
||||
/**
|
||||
* Operating system version, eg 4.3.1, 10.6.7, 3.2
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
platformVersion?: string;
|
||||
|
||||
/**
|
||||
* Plex application name, eg Laika, Plex Media Server, Media Link
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
product?: string;
|
||||
|
||||
/**
|
||||
* Plex application version number
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
version?: string;
|
||||
|
||||
/**
|
||||
* parameter for apiKey security
|
||||
* @param name security name
|
||||
@@ -63,10 +132,42 @@ export class Configuration {
|
||||
retriesConfig?: IAxiosRetryConfig
|
||||
|
||||
constructor(param: ConfigurationParameters = {}) {
|
||||
this.plexToken = param.plexToken;
|
||||
this.clientIdentifier = param.clientIdentifier || "Plexjs";
|
||||
this.device = param.device || "Unspecified";
|
||||
this.deviceName = param.deviceName || "Unspecified";
|
||||
this.platform = param.platform || "Plexjs";
|
||||
this.platformVersion = param.platformVersion || process.env.npm_package_version;
|
||||
this.product = param.product || "Plexjs";
|
||||
this.version = param.version || process.env.npm_package_version;
|
||||
|
||||
this.apiKey = param.apiKey;
|
||||
this.apiKey = (header: string) => {
|
||||
switch (header) {
|
||||
case "X-Plex-Token":
|
||||
return this.plexToken
|
||||
case "X-Plex-Client-Identifier":
|
||||
return this.clientIdentifier
|
||||
case "X-Plex-Device-Name":
|
||||
return this.deviceName
|
||||
case "X-Plex-Device":
|
||||
return this.device
|
||||
case "X-Plex-Platform-Version":
|
||||
return this.platformVersion
|
||||
case "X-Plex-Platform":
|
||||
return this.platform
|
||||
case "X-Plex-Product":
|
||||
return this.product
|
||||
case "X-Plex-Version":
|
||||
return this.version
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
this.basePath = param.basePath;
|
||||
}
|
||||
|
||||
public setAuthToken(token: string) {
|
||||
this.plexToken = token
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
4
plexjs/package-lock.json
generated
4
plexjs/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@lukehagar/plexjs",
|
||||
"version": "0.0.19",
|
||||
"version": "0.0.20",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@lukehagar/plexjs",
|
||||
"version": "0.0.19",
|
||||
"version": "0.0.20",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"axios": "^0.26.1",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@lukehagar/plexjs",
|
||||
"version": "0.0.19",
|
||||
"version": "0.0.20",
|
||||
"description": "Community Made Plex JS/TS Module",
|
||||
"author": "Luke Hagar",
|
||||
"repository": {
|
||||
|
||||
@@ -4,13 +4,82 @@
|
||||
import { IAxiosRetryConfig } from "axios-retry";
|
||||
|
||||
export interface ConfigurationParameters {
|
||||
|
||||
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
|
||||
plexToken?: string;
|
||||
clientIdentifier?: string;
|
||||
device?: string;
|
||||
deviceName?: string;
|
||||
platform?: string;
|
||||
platformVersion?: string;
|
||||
product?: string;
|
||||
version?: string;
|
||||
basePath?: string;
|
||||
|
||||
}
|
||||
|
||||
export class Configuration {
|
||||
/**
|
||||
* Plex Media Server or Plex.TV Authentication token
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
plexToken?: string;
|
||||
|
||||
/**
|
||||
* UUID, serial number, or other number unique per device
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
clientIdentifier?: string;
|
||||
|
||||
/**
|
||||
* Device name and model number, eg iPhone3,2, Motorola XOOM™, LG5200TV
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
device?: string;
|
||||
|
||||
/**
|
||||
* Customized Device Name
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
deviceName?: string;
|
||||
|
||||
/**
|
||||
* Platform name, eg iOS, MacOSX, Android, LG, etc
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
platform?: string;
|
||||
|
||||
/**
|
||||
* Operating system version, eg 4.3.1, 10.6.7, 3.2
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
platformVersion?: string;
|
||||
|
||||
/**
|
||||
* Plex application name, eg Laika, Plex Media Server, Media Link
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
product?: string;
|
||||
|
||||
/**
|
||||
* Plex application version number
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
version?: string;
|
||||
|
||||
/**
|
||||
* parameter for apiKey security
|
||||
* @param name security name
|
||||
@@ -52,10 +121,42 @@ export class Configuration {
|
||||
retriesConfig?: IAxiosRetryConfig
|
||||
|
||||
constructor(param: ConfigurationParameters = {}) {
|
||||
this.plexToken = param.plexToken;
|
||||
this.clientIdentifier = param.clientIdentifier || "Plexjs";
|
||||
this.device = param.device || "Unspecified";
|
||||
this.deviceName = param.deviceName || "Unspecified";
|
||||
this.platform = param.platform || "Plexjs";
|
||||
this.platformVersion = param.platformVersion || process.env.npm_package_version;
|
||||
this.product = param.product || "Plexjs";
|
||||
this.version = param.version || process.env.npm_package_version;
|
||||
|
||||
this.apiKey = param.apiKey;
|
||||
this.apiKey = (header: string) => {
|
||||
switch (header) {
|
||||
case "X-Plex-Token":
|
||||
return this.plexToken
|
||||
case "X-Plex-Client-Identifier":
|
||||
return this.clientIdentifier
|
||||
case "X-Plex-Device-Name":
|
||||
return this.deviceName
|
||||
case "X-Plex-Device":
|
||||
return this.device
|
||||
case "X-Plex-Platform-Version":
|
||||
return this.platformVersion
|
||||
case "X-Plex-Platform":
|
||||
return this.platform
|
||||
case "X-Plex-Product":
|
||||
return this.product
|
||||
case "X-Plex-Version":
|
||||
return this.version
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
this.basePath = param.basePath;
|
||||
}
|
||||
|
||||
public setAuthToken(token: string) {
|
||||
this.plexToken = token
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user