mirror of
https://github.com/LukeHagar/plexjs.git
synced 2025-12-06 20:47:46 +00:00
Compare commits
57 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
18c735a920 | ||
|
|
331618b77a | ||
|
|
5f601ecf65 | ||
|
|
8eeef06c9c | ||
|
|
bc9335abcf | ||
|
|
792fedc759 | ||
|
|
e343455e77 | ||
|
|
7a7931b0d0 | ||
|
|
b3c26fd1a7 | ||
|
|
26fa0aef86 | ||
|
|
74ecefac8b | ||
|
|
8855195c09 | ||
|
|
227636620e | ||
|
|
5866739942 | ||
|
|
0eacb0e7c4 | ||
|
|
c0efb9a732 | ||
|
|
71484de76e | ||
|
|
be73efff0b | ||
|
|
a00c394526 | ||
|
|
3d57b22b26 | ||
|
|
995bbedbb6 | ||
|
|
d638acb5d2 | ||
|
|
f87006d3e8 | ||
|
|
fcab6f2532 | ||
|
|
4c552faaf5 | ||
|
|
7ea8776750 | ||
|
|
b9487a78df | ||
|
|
4addcb43e0 | ||
|
|
05444f54ad | ||
|
|
a7139cc510 | ||
|
|
ddbf96d1d1 | ||
|
|
a40e1f6ee9 | ||
|
|
b37ec6d21e | ||
|
|
b868a95db1 | ||
|
|
7d18553ff0 | ||
|
|
e83d09070a | ||
|
|
0794b8457e | ||
|
|
c6ba56222a | ||
|
|
e8f38b8d0a | ||
|
|
898fa0212d | ||
|
|
67a632bbc2 | ||
|
|
19c72dd7d3 | ||
|
|
f4e18606ce | ||
|
|
dfb04b01ca | ||
|
|
59185de71e | ||
|
|
ef52691a35 | ||
|
|
5ae5c02dbf | ||
|
|
3da49e7178 | ||
|
|
e8658f4d85 | ||
|
|
db5f6e554a | ||
|
|
05e801ee19 | ||
|
|
b4e644b42b | ||
|
|
6c27a91f07 | ||
|
|
abc76a4a13 | ||
|
|
1021fd9033 | ||
|
|
5cf4bcc6f6 | ||
|
|
7c7a7acbd9 |
18
.github/workflows/bump_version.yml
vendored
18
.github/workflows/bump_version.yml
vendored
@@ -69,9 +69,27 @@ jobs:
|
||||
npm install
|
||||
npm run build
|
||||
|
||||
- name: Publish to NPM
|
||||
id: publish
|
||||
uses: JS-DevTools/npm-publish@v1
|
||||
with:
|
||||
token: ${{ secrets.NPM_TOKEN }}
|
||||
package: ./plexjs/package.json
|
||||
|
||||
- name: Commit changes and create new version tag
|
||||
if: steps.buildSDK.outcome == 'success'
|
||||
uses: stefanzweifel/git-auto-commit-action@v4
|
||||
with:
|
||||
commit_message: Bump version to ${{ github.event.inputs.version }}
|
||||
tagging_message: ${{ github.event.inputs.version }}
|
||||
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
|
||||
with:
|
||||
tag_name: ${{ github.event.inputs.version }}
|
||||
release_name: ${{ github.event.inputs.version }}
|
||||
draft: false
|
||||
prerelease: false
|
||||
|
||||
21
.github/workflows/publish-to-npm.yml
vendored
21
.github/workflows/publish-to-npm.yml
vendored
@@ -1,21 +0,0 @@
|
||||
name: Publish SDK package to npmjs
|
||||
on:
|
||||
release:
|
||||
types: [created]
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 12
|
||||
- run: |
|
||||
cd plexjs
|
||||
npm ci
|
||||
|
||||
- id: publish
|
||||
uses: JS-DevTools/npm-publish@v1
|
||||
with:
|
||||
token: ${{ secrets.NPM_TOKEN }}
|
||||
package: ./plexjs/package.json
|
||||
@@ -5,7 +5,7 @@ files:
|
||||
destinationFilename: package.json
|
||||
npmName: plexjs
|
||||
npmRepository: lukehagar
|
||||
npmVersion: 0.0.7
|
||||
npmVersion: 0.0.22
|
||||
useSingleRequestParameter: true
|
||||
sortParamsByRequiredFlag: true
|
||||
gitUserID: lukehagar
|
||||
|
||||
6
examples/.eslintignore
Normal file
6
examples/.eslintignore
Normal file
@@ -0,0 +1,6 @@
|
||||
# don't ever lint node_modules
|
||||
node_modules
|
||||
# don't lint build output (make sure it's set to your correct build folder name)
|
||||
build
|
||||
# don't lint nyc coverage output
|
||||
coverage
|
||||
19
examples/.eslintrc
Normal file
19
examples/.eslintrc
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"root": true,
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"plugins": ["@typescript-eslint", "prettier", "jest"],
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"prettier"
|
||||
],
|
||||
"rules": {
|
||||
"no-console": 1,
|
||||
"prettier/prettier": 2
|
||||
},
|
||||
"env": {
|
||||
"browser": true,
|
||||
"node": true,
|
||||
"jest/globals": true
|
||||
}
|
||||
}
|
||||
107
examples/.gitignore
vendored
Normal file
107
examples/.gitignore
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
43
examples/README.md
Normal file
43
examples/README.md
Normal file
@@ -0,0 +1,43 @@
|
||||
# 🧰 Simple TypeScript Starter | 2022
|
||||
|
||||
> We talk about a lot of **advanced Node.js and TypeScript** concepts on [the blog](https://khalilstemmler.com), particularly focused around Domain-Driven Design and large-scale enterprise application patterns. However, I received a few emails from readers that were interested in seeing what a basic TypeScript starter project looks like. So I've put together just that.
|
||||
|
||||
### Features
|
||||
|
||||
- Minimal
|
||||
- TypeScript v4
|
||||
- Testing with Jest
|
||||
- Linting with Eslint and Prettier
|
||||
- Pre-commit hooks with Husky
|
||||
- VS Code debugger scripts
|
||||
- Local development with Nodemon
|
||||
|
||||
### Scripts
|
||||
|
||||
#### `npm run start:dev`
|
||||
|
||||
Starts the application in development using `nodemon` and `ts-node` to do hot reloading.
|
||||
|
||||
#### `npm run start`
|
||||
|
||||
Starts the app in production by first building the project with `npm run build`, and then executing the compiled JavaScript at `build/index.js`.
|
||||
|
||||
#### `npm run build`
|
||||
|
||||
Builds the app at `build`, cleaning the folder first.
|
||||
|
||||
#### `npm run test`
|
||||
|
||||
Runs the `jest` tests once.
|
||||
|
||||
#### `npm run test:dev`
|
||||
|
||||
Run the `jest` tests in watch mode, waiting for file changes.
|
||||
|
||||
#### `npm run prettier-format`
|
||||
|
||||
Format your code.
|
||||
|
||||
#### `npm run prettier-watch`
|
||||
|
||||
Format your code in watch mode, waiting for file changes.
|
||||
6
examples/nodemon.json
Normal file
6
examples/nodemon.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"watch": ["src"],
|
||||
"ext": ".ts,.js",
|
||||
"ignore": [],
|
||||
"exec": "npx ts-node ./src/index.ts"
|
||||
}
|
||||
17904
examples/package-lock.json
generated
Normal file
17904
examples/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
31
examples/package.json
Normal file
31
examples/package.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "typescript-starter",
|
||||
"version": "1.0.0",
|
||||
"description": "A basic typescript app starter for 2023.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"build": "rimraf ./build && tsc",
|
||||
"dev": "npx nodemon",
|
||||
"start": "npm run build && node build/index.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"@lukehagar/plexjs": "^0.0.21",
|
||||
"@types/jest": "^29.5.1",
|
||||
"@types/node": "^18.6.1",
|
||||
"@typescript-eslint/eslint-plugin": "^5.31.0",
|
||||
"@typescript-eslint/parser": "^5.31.0",
|
||||
"dotenv": "^16.0.3",
|
||||
"nodemon": "^2.0.19",
|
||||
"onchange": "^7.1.0",
|
||||
"rimraf": "^5.0.0",
|
||||
"run-script-os": "^1.1.6",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "^5.0.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"jest-cucumber": "^3.0.1"
|
||||
}
|
||||
}
|
||||
19
examples/src/index.ts
Normal file
19
examples/src/index.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
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));
|
||||
16
examples/tsconfig.json
Normal file
16
examples/tsconfig.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"allowJs": true,
|
||||
"outDir": "build",
|
||||
"rootDir": "src",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"types": ["node", "jest"],
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["src/**/*.spec.ts"]
|
||||
}
|
||||
4412
examples/yarn.lock
Normal file
4412
examples/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
## plexjs@0.0.7
|
||||
## plexjs@0.0.22
|
||||
|
||||
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.7 --save
|
||||
npm install plexjs@0.0.22 --save
|
||||
```
|
||||
|
||||
_unPublished (not recommended):_
|
||||
|
||||
3201
plexjs/api.ts
3201
plexjs/api.ts
File diff suppressed because it is too large
Load Diff
@@ -14,14 +14,83 @@
|
||||
|
||||
import { IAxiosRetryConfig } from "axios-retry";
|
||||
|
||||
export interface ConfigurationParameters {
|
||||
|
||||
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
|
||||
export type ConfigurationParameters = {
|
||||
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 || "plexjs";
|
||||
this.deviceName = param.deviceName || "plexjs";
|
||||
this.platform = param.platform || "plexjs";
|
||||
this.platformVersion = param.platformVersion || "0.0.22";
|
||||
this.product = param.product || "plexjs";
|
||||
this.version = param.version || "0.0.22";
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,4 +14,5 @@
|
||||
|
||||
|
||||
export * from "./api";
|
||||
export {Configuration, ConfigurationParameters} from "./configuration";
|
||||
|
||||
|
||||
4
plexjs/package-lock.json
generated
4
plexjs/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@lukehagar/plexjs",
|
||||
"version": "0.0.7",
|
||||
"version": "0.0.22",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@lukehagar/plexjs",
|
||||
"version": "0.0.7",
|
||||
"version": "0.0.22",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"axios": "^0.26.1",
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
{
|
||||
"name": "@lukehagar/plexjs",
|
||||
"version": "0.0.7",
|
||||
"version": "0.0.22",
|
||||
"description": "Community Made Plex JS/TS Module",
|
||||
"author": "Luke Hagar",
|
||||
"type": "module",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/LukeHagar/plexjs.git"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"target": "ES5",
|
||||
"module": "CommonJS",
|
||||
"noImplicitAny": true,
|
||||
"outDir": "./dist",
|
||||
"outDir": "dist",
|
||||
"rootDir": ".",
|
||||
"lib": [
|
||||
"es6",
|
||||
@@ -12,10 +12,12 @@
|
||||
],
|
||||
"typeRoots": [
|
||||
"node_modules/@types"
|
||||
]
|
||||
],
|
||||
"sourceMap": true
|
||||
},
|
||||
"exclude": [
|
||||
"dist",
|
||||
"node_modules"
|
||||
"node_modules",
|
||||
"./dist/**/*"
|
||||
]
|
||||
}
|
||||
|
||||
36
readme.md
36
readme.md
@@ -2,10 +2,42 @@
|
||||
|
||||
## 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
|
||||
|
||||
npm
|
||||
```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,14 +3,83 @@
|
||||
{{>licenseInfo}}
|
||||
import { IAxiosRetryConfig } from "axios-retry";
|
||||
|
||||
export interface ConfigurationParameters {
|
||||
|
||||
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
|
||||
export type ConfigurationParameters = {
|
||||
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 || "{{npmName}}";
|
||||
this.device = param.device || "{{npmName}}";
|
||||
this.deviceName = param.deviceName || "{{npmName}}";
|
||||
this.platform = param.platform || "{{npmName}}";
|
||||
this.platformVersion = param.platformVersion || "{{npmVersion}}";
|
||||
this.product = param.product || "{{npmName}}";
|
||||
this.version = param.version || "{{npmVersion}}";
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,4 +3,5 @@
|
||||
{{>licenseInfo}}
|
||||
|
||||
export * from "./api";
|
||||
export {Configuration, ConfigurationParameters} from "./configuration";
|
||||
{{#withSeparateModelsAndApi}}export * from "./{{tsModelPackage}}";{{/withSeparateModelsAndApi}}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
"version": "{{npmVersion}}",
|
||||
"description": "Community Made Plex JS/TS Module",
|
||||
"author": "Luke Hagar",
|
||||
"type": "module",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/LukeHagar/plexjs.git"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"target": "{{#supportsES6}}ES6{{/supportsES6}}{{^supportsES6}}ES5{{/supportsES6}}",
|
||||
"module": "{{#supportsES6}}ES6{{/supportsES6}}{{^supportsES6}}CommonJS{{/supportsES6}}",
|
||||
"noImplicitAny": true,
|
||||
"outDir": "./dist",
|
||||
"outDir": "dist",
|
||||
"rootDir": ".",
|
||||
{{^supportsES6}}
|
||||
"lib": [
|
||||
@@ -14,10 +14,12 @@
|
||||
{{/supportsES6}}
|
||||
"typeRoots": [
|
||||
"node_modules/@types"
|
||||
]
|
||||
],
|
||||
"sourceMap": true
|
||||
},
|
||||
"exclude": [
|
||||
"dist",
|
||||
"node_modules"
|
||||
"node_modules",
|
||||
"./dist/**/*"
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user