@ctrl/plex 3.6.0 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -3
- package/dist/src/client.js +1 -1
- package/dist/src/library.d.ts +4 -0
- package/dist/src/server.js +1 -1
- package/package.json +46 -28
package/README.md
CHANGED
|
@@ -13,11 +13,12 @@ npm install @ctrl/plex
|
|
|
13
13
|
|
|
14
14
|
### Docs
|
|
15
15
|
|
|
16
|
-
https://ctrl-plex.vercel.app
|
|
16
|
+
https://ctrl-plex.vercel.app
|
|
17
17
|
|
|
18
18
|
### Use
|
|
19
19
|
|
|
20
20
|
Create a plex connection
|
|
21
|
+
|
|
21
22
|
```ts
|
|
22
23
|
import { MyPlexAccount } from '@ctrl/plex';
|
|
23
24
|
|
|
@@ -28,6 +29,7 @@ const library = await plex.library();
|
|
|
28
29
|
```
|
|
29
30
|
|
|
30
31
|
###### Example 1: List all unwatched movies.
|
|
32
|
+
|
|
31
33
|
```ts
|
|
32
34
|
import { MovieSection } from '@ctrl/plex';
|
|
33
35
|
|
|
@@ -38,6 +40,7 @@ const results = await section.search({ unwatched: true });
|
|
|
38
40
|
```
|
|
39
41
|
|
|
40
42
|
###### Example 2: Search for a list of movies containing a title
|
|
43
|
+
|
|
41
44
|
```ts
|
|
42
45
|
const library = await plex.library();
|
|
43
46
|
const section = await library.section<MovieSection>('Movies');
|
|
@@ -45,6 +48,7 @@ const results = await section.search({ title: 'Rush Hour' });
|
|
|
45
48
|
```
|
|
46
49
|
|
|
47
50
|
###### Example 3: List all content containing a specific query
|
|
51
|
+
|
|
48
52
|
```ts
|
|
49
53
|
const results = await plex.search('Arnold');
|
|
50
54
|
// Each hub represents a single Hub (or category) in the PlexServer search (movie, actor, etc)
|
|
@@ -55,6 +59,7 @@ for (const hub of results) {
|
|
|
55
59
|
```
|
|
56
60
|
|
|
57
61
|
###### Example 4: List all episodes of a tv show.
|
|
62
|
+
|
|
58
63
|
```ts
|
|
59
64
|
import { ShowSection } from '@ctrl/plex';
|
|
60
65
|
|
|
@@ -66,7 +71,8 @@ const episodes = await results[0].episodes();
|
|
|
66
71
|
```
|
|
67
72
|
|
|
68
73
|
### Differences from python plex client
|
|
69
|
-
|
|
74
|
+
|
|
75
|
+
JS is a different language and some methods of the api were not possible.
|
|
70
76
|
Chaining functions with requests must be awaited mostly individually. Constructors in JS don't typically make requests
|
|
71
77
|
and accessing properties normally cannot make requests either.
|
|
72
78
|
|
|
@@ -99,13 +105,13 @@ Post testing, remove plex server from account. Warning this is destructive. Do n
|
|
|
99
105
|
npm run test-cleanup
|
|
100
106
|
```
|
|
101
107
|
|
|
102
|
-
|
|
103
108
|
### Running tests locally (mostly for myself)
|
|
104
109
|
|
|
105
110
|
get a claim token from https://www.plex.tv/claim/
|
|
106
111
|
export PLEX_CLAIM_TOKEN=claim-token
|
|
107
112
|
|
|
108
113
|
start plex container for testing
|
|
114
|
+
|
|
109
115
|
```console
|
|
110
116
|
docker run -d \
|
|
111
117
|
--name=plex \
|
|
@@ -134,11 +140,13 @@ docker run -d \
|
|
|
134
140
|
```
|
|
135
141
|
|
|
136
142
|
Pull latest plex container if needed
|
|
143
|
+
|
|
137
144
|
```console
|
|
138
145
|
docker pull lscr.io/linuxserver/plex:latest
|
|
139
146
|
```
|
|
140
147
|
|
|
141
148
|
bootstrap plex server with test media
|
|
149
|
+
|
|
142
150
|
```console
|
|
143
151
|
NODE_OPTIONS="--loader ts-node/esm" node scripts/bootstraptest.ts --no-docker --server-name=orbstack --password=$PLEX_PASSWORD --username=$PLEX_USERNAME
|
|
144
152
|
```
|
package/dist/src/client.js
CHANGED
package/dist/src/library.d.ts
CHANGED
package/dist/src/server.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { URL, URLSearchParams } from 'url';
|
|
2
1
|
import { ofetch } from 'ofetch';
|
|
2
|
+
import { URL, URLSearchParams } from 'url';
|
|
3
3
|
import { fetchItem, fetchItems } from './baseFunctionality.js';
|
|
4
4
|
import { PlexClient } from './client.js';
|
|
5
5
|
import { BASE_HEADERS, TIMEOUT, X_PLEX_CONTAINER_SIZE } from './config.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ctrl/plex",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.0",
|
|
4
4
|
"description": "plex api client in typescript",
|
|
5
5
|
"author": "Scott Cooper <scttcper@gmail.com>",
|
|
6
6
|
"publishConfig": {
|
|
@@ -20,58 +20,76 @@
|
|
|
20
20
|
"typescript"
|
|
21
21
|
],
|
|
22
22
|
"scripts": {
|
|
23
|
-
"lint": "
|
|
24
|
-
"lint:
|
|
25
|
-
"lint:eslint": "eslint .",
|
|
26
|
-
"lint:fix": "pnpm run '/^(lint:biome|lint:eslint):fix$/'",
|
|
27
|
-
"lint:eslint:fix": "eslint . --fix",
|
|
28
|
-
"lint:biome:fix": "biome check . --write",
|
|
23
|
+
"lint": "oxlint . && prettier --check . --experimental-cli",
|
|
24
|
+
"lint:fix": "oxlint . --fix && prettier --write . --log-level=error --experimental-cli",
|
|
29
25
|
"prepare": "npm run build",
|
|
30
26
|
"build": "tsc",
|
|
31
27
|
"build:docs": "typedoc",
|
|
32
28
|
"test": "vitest run",
|
|
33
29
|
"test:ci": "vitest run --coverage --reporter=default --reporter=junit --outputFile=./junit.xml",
|
|
34
|
-
"bootstraptest": "
|
|
35
|
-
"teardowntest": "
|
|
36
|
-
"add-media": "
|
|
37
|
-
"test-cleanup": "
|
|
30
|
+
"bootstraptest": "tsx scripts/bootstraptest.ts",
|
|
31
|
+
"teardowntest": "tsx scripts/teardowntest.ts",
|
|
32
|
+
"add-media": "tsx scripts/add-media.ts",
|
|
33
|
+
"test-cleanup": "tsx scripts/test-cleanup.ts"
|
|
38
34
|
},
|
|
39
35
|
"dependencies": {
|
|
40
36
|
"@ctrl/mac-address": "^3.1.0",
|
|
41
37
|
"ofetch": "^1.4.1",
|
|
42
38
|
"p-any": "^4.0.0",
|
|
43
|
-
"type-fest": "^
|
|
44
|
-
"ws": "^8.18.
|
|
39
|
+
"type-fest": "^5.0.0",
|
|
40
|
+
"ws": "^8.18.3",
|
|
45
41
|
"xml2js": "^0.6.2"
|
|
46
42
|
},
|
|
47
43
|
"devDependencies": {
|
|
48
|
-
"@
|
|
49
|
-
"@ctrl/
|
|
50
|
-
"@sindresorhus/tsconfig": "
|
|
51
|
-
"@
|
|
44
|
+
"@ctrl/oxlint-config": "1.2.3",
|
|
45
|
+
"@ctrl/video-filename-parser": "5.4.1",
|
|
46
|
+
"@sindresorhus/tsconfig": "8.0.1",
|
|
47
|
+
"@trivago/prettier-plugin-sort-imports": "5.2.2",
|
|
48
|
+
"@types/node": "24.3.3",
|
|
52
49
|
"@types/ws": "8.18.1",
|
|
53
50
|
"@types/xml2js": "0.4.14",
|
|
54
51
|
"@types/yargs": "17.0.33",
|
|
55
|
-
"@vitest/coverage-v8": "3.
|
|
56
|
-
"
|
|
57
|
-
"execa": "9.5.2",
|
|
52
|
+
"@vitest/coverage-v8": "3.2.4",
|
|
53
|
+
"execa": "9.6.0",
|
|
58
54
|
"globby": "14.1.0",
|
|
59
|
-
"make-dir": "5.
|
|
55
|
+
"make-dir": "5.1.0",
|
|
60
56
|
"ora": "8.2.0",
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
57
|
+
"oxlint": "1.15.0",
|
|
58
|
+
"p-retry": "7.0.0",
|
|
59
|
+
"prettier": "3.6.2",
|
|
60
|
+
"tsx": "4.20.5",
|
|
61
|
+
"typedoc": "0.28.12",
|
|
62
|
+
"typescript": "5.9.2",
|
|
63
|
+
"vitest": "3.2.4",
|
|
64
|
+
"yargs": "18.0.0"
|
|
67
65
|
},
|
|
68
66
|
"release": {
|
|
69
67
|
"branches": [
|
|
70
68
|
"master"
|
|
71
69
|
]
|
|
72
70
|
},
|
|
71
|
+
"prettier": {
|
|
72
|
+
"singleQuote": true,
|
|
73
|
+
"trailingComma": "all",
|
|
74
|
+
"arrowParens": "avoid",
|
|
75
|
+
"semi": true,
|
|
76
|
+
"printWidth": 100,
|
|
77
|
+
"plugins": [
|
|
78
|
+
"@trivago/prettier-plugin-sort-imports"
|
|
79
|
+
],
|
|
80
|
+
"importOrder": [
|
|
81
|
+
"^node:.*$",
|
|
82
|
+
"<THIRD_PARTY_MODULES>",
|
|
83
|
+
"^(@ctrl)(/.*|$)",
|
|
84
|
+
"^\\.\\./(?!.*\\.css$)",
|
|
85
|
+
"^\\./(?!.*\\.css$)(?=.*/)",
|
|
86
|
+
"^\\./(?!.*\\.css$)(?!.*/)"
|
|
87
|
+
],
|
|
88
|
+
"importOrderSeparation": true,
|
|
89
|
+
"importOrderSortSpecifiers": false
|
|
90
|
+
},
|
|
73
91
|
"engines": {
|
|
74
92
|
"node": ">=18"
|
|
75
93
|
},
|
|
76
|
-
"packageManager": "pnpm@10.
|
|
94
|
+
"packageManager": "pnpm@10.16.0"
|
|
77
95
|
}
|