@ctrl/plex 1.5.2 → 2.0.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.
Files changed (68) hide show
  1. package/README.md +3 -2
  2. package/dist/src/alert.d.ts +12 -0
  3. package/dist/src/alert.js +29 -0
  4. package/dist/src/alert.types.d.ts +59 -0
  5. package/dist/src/alert.types.js +1 -0
  6. package/dist/{base → src/base}/partialPlexObject.d.ts +18 -12
  7. package/dist/{base → src/base}/partialPlexObject.js +32 -23
  8. package/dist/{base → src/base}/playable.d.ts +2 -2
  9. package/dist/src/base/playable.js +8 -0
  10. package/dist/{base → src/base}/plexObject.d.ts +8 -1
  11. package/dist/{base → src/base}/plexObject.js +21 -18
  12. package/dist/{baseFunctionality.d.ts → src/baseFunctionality.d.ts} +17 -1
  13. package/dist/{baseFunctionality.js → src/baseFunctionality.js} +7 -15
  14. package/dist/{client.d.ts → src/client.d.ts} +2 -2
  15. package/dist/{client.js → src/client.js} +12 -20
  16. package/dist/src/client.types.js +1 -0
  17. package/dist/src/config.js +35 -0
  18. package/dist/src/exceptions.d.ts +20 -0
  19. package/dist/src/exceptions.js +40 -0
  20. package/dist/src/index.d.ts +12 -0
  21. package/dist/src/index.js +11 -0
  22. package/dist/{library.d.ts → src/library.d.ts} +207 -21
  23. package/dist/{library.js → src/library.js} +349 -133
  24. package/dist/{library.types.d.ts → src/library.types.d.ts} +71 -1
  25. package/dist/src/library.types.js +1 -0
  26. package/dist/{media.d.ts → src/media.d.ts} +16 -4
  27. package/dist/{media.js → src/media.js} +42 -49
  28. package/dist/src/media.types.d.ts +7 -0
  29. package/dist/src/media.types.js +1 -0
  30. package/dist/{myplex.d.ts → src/myplex.d.ts} +16 -6
  31. package/dist/{myplex.js → src/myplex.js} +71 -57
  32. package/dist/src/myplex.types.js +10 -0
  33. package/dist/src/playlist.d.ts +75 -0
  34. package/dist/src/playlist.js +142 -0
  35. package/dist/src/playlist.types.d.ts +17 -0
  36. package/dist/src/playlist.types.js +1 -0
  37. package/dist/{search.d.ts → src/search.d.ts} +5 -4
  38. package/dist/{search.js → src/search.js} +16 -20
  39. package/dist/src/search.types.js +1 -0
  40. package/dist/{server.d.ts → src/server.d.ts} +22 -10
  41. package/dist/{server.js → src/server.js} +65 -50
  42. package/dist/src/server.types.js +1 -0
  43. package/dist/src/settings.d.ts +79 -0
  44. package/dist/src/settings.js +160 -0
  45. package/dist/{util.d.ts → src/util.d.ts} +2 -1
  46. package/dist/{util.js → src/util.js} +8 -12
  47. package/dist/{video.d.ts → src/video.d.ts} +39 -61
  48. package/dist/{video.js → src/video.js} +110 -93
  49. package/dist/{video.types.d.ts → src/video.types.d.ts} +1 -1
  50. package/dist/src/video.types.js +6 -0
  51. package/package.json +46 -44
  52. package/dist/base/playable.js +0 -12
  53. package/dist/client.types.js +0 -2
  54. package/dist/config.js +0 -41
  55. package/dist/index.d.ts +0 -8
  56. package/dist/index.js +0 -23
  57. package/dist/library.types.js +0 -2
  58. package/dist/myplex.types.js +0 -13
  59. package/dist/playlist.d.ts +0 -7
  60. package/dist/playlist.js +0 -19
  61. package/dist/search.types.js +0 -2
  62. package/dist/server.types.js +0 -2
  63. package/dist/video.types.js +0 -9
  64. /package/dist/{client.types.d.ts → src/client.types.d.ts} +0 -0
  65. /package/dist/{config.d.ts → src/config.d.ts} +0 -0
  66. /package/dist/{myplex.types.d.ts → src/myplex.types.d.ts} +0 -0
  67. /package/dist/{search.types.d.ts → src/search.types.d.ts} +0 -0
  68. /package/dist/{server.types.d.ts → src/server.types.d.ts} +0 -0
@@ -1,4 +1,4 @@
1
- import { ChapterSource, MediaTagData } from './video.types';
1
+ import { ChapterSource, MarkerData, MediaTagData } from './video.types.js';
2
2
  export interface LibraryRootResponse {
3
3
  size: number;
4
4
  allowSync: boolean;
@@ -32,6 +32,7 @@ export interface SectionsDirectory {
32
32
  refreshing: boolean;
33
33
  thumb: string;
34
34
  key: string;
35
+ ratingKey: string;
35
36
  type: string;
36
37
  title: string;
37
38
  agent: string;
@@ -106,6 +107,9 @@ export interface MovieData {
106
107
  Role?: MediaTag[];
107
108
  Similar?: MediaTagData[];
108
109
  Producer?: MediaTagData[];
110
+ Extras?: ExtrasData[];
111
+ Guid?: Guid[];
112
+ Marker?: MarkerData[];
109
113
  }
110
114
  export interface MediaTag {
111
115
  tag: string;
@@ -117,6 +121,9 @@ export interface Media {
117
121
  videoProfile: string;
118
122
  Part: Part[];
119
123
  }
124
+ export interface Guid {
125
+ id: string;
126
+ }
120
127
  export interface Part {
121
128
  id: number;
122
129
  key: string;
@@ -126,6 +133,17 @@ export interface Part {
126
133
  container: string;
127
134
  videoProfile: string;
128
135
  }
136
+ export interface FullShowData {
137
+ size: number;
138
+ allowSync: boolean;
139
+ identifier: string;
140
+ librarySectionID: number;
141
+ librarySectionTitle: string;
142
+ librarySectionUUID: string;
143
+ mediaTagPrefix: string;
144
+ mediaTagVersion: number;
145
+ Metadata: ShowData[];
146
+ }
129
147
  export interface ShowData {
130
148
  ratingKey: string;
131
149
  key: string;
@@ -177,3 +195,55 @@ export interface CollectionData {
177
195
  maxYear: string;
178
196
  minYear: string;
179
197
  }
198
+ export interface ExtrasData {
199
+ ratingKey: string;
200
+ key: string;
201
+ guid: string;
202
+ type: string;
203
+ title: string;
204
+ titleSort: string;
205
+ summary: string;
206
+ index: number;
207
+ thumb: string;
208
+ subtype: string;
209
+ duration: number;
210
+ addedAt: number;
211
+ extraType: number;
212
+ Media: ExtrasMedia[];
213
+ }
214
+ export interface ExtrasMedia {
215
+ id: number;
216
+ duration: number;
217
+ bitrate: number;
218
+ width: number;
219
+ height: number;
220
+ aspectRatio: number;
221
+ audioCodec: string;
222
+ videoCodec: string;
223
+ videoResolution: string;
224
+ container: string;
225
+ optimizedForStreaming: number;
226
+ protocol: string;
227
+ premium: boolean;
228
+ Part: Array<{
229
+ id: number;
230
+ duration: number;
231
+ container: string;
232
+ key: string;
233
+ Stream: ExtrasStream[];
234
+ }>;
235
+ }
236
+ interface ExtrasStream {
237
+ id: number;
238
+ streamType: number;
239
+ codec: string;
240
+ index: number;
241
+ bitrate?: number;
242
+ height?: number;
243
+ width?: number;
244
+ displayTitle: string;
245
+ extendedDisplayTitle: string;
246
+ selected?: boolean;
247
+ channels?: number;
248
+ }
249
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,5 @@
1
- import { PlexObject } from './base/plexObject';
2
- import { ChapterData, MarkerData, MediaData, MediaPartData, MediaPartStreamData } from './video.types';
1
+ import { PlexObject } from './base/plexObject.js';
2
+ import { ChapterData, MarkerData, MediaData, MediaPartData, MediaPartStreamData } from './video.types.js';
3
3
  /**
4
4
  * Base class for media tags used for filtering and searching your library
5
5
  * items or navigating the metadata of media items in your library. Tags are
@@ -67,7 +67,6 @@ export declare class MediaPart extends PlexObject {
67
67
  file: string;
68
68
  id: number;
69
69
  indexes: string;
70
- key: string;
71
70
  size: number;
72
71
  optimizedForStreaming: boolean;
73
72
  syncItemId: string;
@@ -134,7 +133,7 @@ export declare class Producer extends MediaTag {
134
133
  export declare class Marker extends MediaTag {
135
134
  static TAG: "Marker";
136
135
  FILTER: "marker";
137
- type: 'intro';
136
+ type: 'intro' | 'credits';
138
137
  startTimeOffset: number;
139
138
  endTimeOffset: number;
140
139
  protected _loadData(data: MarkerData): void;
@@ -167,4 +166,17 @@ export declare class Optimized extends PlexObject {
167
166
  targetTagID: any;
168
167
  protected _loadData(data: any): void;
169
168
  }
169
+ /**
170
+ * Base class for guid tags used only for Guids, as they contain only a string identifier
171
+ */
172
+ declare class GuidTag extends PlexObject {
173
+ /**
174
+ * The guid for external metadata sources (e.g. IMDB, TMDB, TVDB). ex - imdb://tt3222784
175
+ */
176
+ id: string;
177
+ protected _loadData(data: any): void;
178
+ }
179
+ export declare class Guid extends GuidTag {
180
+ static TAG: "Guid";
181
+ }
170
182
  export {};
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Optimized = exports.Collection = exports.Chapter = exports.Marker = exports.Producer = exports.Similar = exports.Director = exports.Writer = exports.Country = exports.Genre = exports.Role = exports.MediaPartStream = exports.MediaPart = exports.Media = void 0;
4
- const plexObject_1 = require("./base/plexObject");
1
+ import { PlexObject } from './base/plexObject.js';
5
2
  /**
6
3
  * Base class for media tags used for filtering and searching your library
7
4
  * items or navigating the metadata of media items in your library. Tags are
8
5
  * the construct used for things such as Country, Director, Genre, etc.
9
6
  */
10
- class MediaTag extends plexObject_1.PlexObject {
7
+ class MediaTag extends PlexObject {
11
8
  // async items(): Promise<any[]> {
12
9
  // if (!this.key) {
13
10
  // throw new Error(`Key is not defined for this tag: ${this.tag}`);
@@ -21,7 +18,8 @@ class MediaTag extends plexObject_1.PlexObject {
21
18
  this.tag = data.tag;
22
19
  }
23
20
  }
24
- class Media extends plexObject_1.PlexObject {
21
+ export class Media extends PlexObject {
22
+ static { this.TAG = 'Media'; }
25
23
  _loadData(data) {
26
24
  this.aspectRatio = data.aspectRatio;
27
25
  this.audioChannels = data.audioChannels;
@@ -40,11 +38,9 @@ class Media extends plexObject_1.PlexObject {
40
38
  this.parts = data.Part.map(part => new MediaPart(this.server, part, undefined, this));
41
39
  }
42
40
  }
43
- exports.Media = Media;
44
- Media.TAG = 'Media';
45
- class MediaPart extends plexObject_1.PlexObject {
41
+ export class MediaPart extends PlexObject {
42
+ static { this.TAG = 'Part'; }
46
43
  _loadData(data) {
47
- var _a, _b;
48
44
  this.container = data.container;
49
45
  this.duration = data.duration;
50
46
  this.file = data.file;
@@ -55,12 +51,11 @@ class MediaPart extends plexObject_1.PlexObject {
55
51
  this.videoProfile = data.videoProfile;
56
52
  this.exists = data.exists;
57
53
  this.streams =
58
- (_b = (_a = data.Stream) === null || _a === void 0 ? void 0 : _a.map(stream => new MediaPartStream(this.server, stream, undefined, this))) !== null && _b !== void 0 ? _b : [];
54
+ data.Stream?.map(stream => new MediaPartStream(this.server, stream, undefined, this)) ?? [];
59
55
  }
60
56
  }
61
- exports.MediaPart = MediaPart;
62
- MediaPart.TAG = 'Part';
63
- class MediaPartStream extends plexObject_1.PlexObject {
57
+ export class MediaPartStream extends PlexObject {
58
+ static { this.TAG = 'Stream'; }
64
59
  _loadData(data) {
65
60
  this.id = data.id;
66
61
  this.codec = data.codec;
@@ -71,120 +66,109 @@ class MediaPartStream extends plexObject_1.PlexObject {
71
66
  this.streamType = data.streamType;
72
67
  }
73
68
  }
74
- exports.MediaPartStream = MediaPartStream;
75
- MediaPartStream.TAG = 'Stream';
76
69
  /**
77
70
  * Represents a single Role (actor/actress) media tag.
78
71
  */
79
- class Role extends MediaTag {
72
+ export class Role extends MediaTag {
80
73
  constructor() {
81
74
  super(...arguments);
82
75
  this.FILTER = 'role';
83
76
  }
77
+ static { this.TAG = 'Role'; }
84
78
  }
85
- exports.Role = Role;
86
- Role.TAG = 'Role';
87
79
  /**
88
80
  * Represents a single Genre media tag.
89
81
  */
90
- class Genre extends MediaTag {
82
+ export class Genre extends MediaTag {
91
83
  constructor() {
92
84
  super(...arguments);
93
85
  this.FILTER = 'genre';
94
86
  }
87
+ static { this.TAG = 'Genre'; }
95
88
  }
96
- exports.Genre = Genre;
97
- Genre.TAG = 'Genre';
98
89
  /**
99
90
  * Represents a single Country media tag.
100
91
  */
101
- class Country extends MediaTag {
92
+ export class Country extends MediaTag {
102
93
  constructor() {
103
94
  super(...arguments);
104
95
  this.FILTER = 'country';
105
96
  }
97
+ static { this.TAG = 'Country'; }
106
98
  }
107
- exports.Country = Country;
108
- Country.TAG = 'Country';
109
99
  /**
110
100
  * Represents a single Writer media tag.
111
101
  */
112
- class Writer extends MediaTag {
102
+ export class Writer extends MediaTag {
113
103
  constructor() {
114
104
  super(...arguments);
115
105
  this.FILTER = 'writer';
116
106
  }
107
+ static { this.TAG = 'Writer'; }
117
108
  }
118
- exports.Writer = Writer;
119
- Writer.TAG = 'Writer';
120
109
  /**
121
110
  * Represents a single Director media tag.
122
111
  */
123
- class Director extends MediaTag {
112
+ export class Director extends MediaTag {
124
113
  constructor() {
125
114
  super(...arguments);
126
115
  this.FILTER = 'director';
127
116
  }
117
+ static { this.TAG = 'Director'; }
128
118
  }
129
- exports.Director = Director;
130
- Director.TAG = 'Director';
131
- class Similar extends MediaTag {
119
+ export class Similar extends MediaTag {
132
120
  constructor() {
133
121
  super(...arguments);
134
122
  this.FILTER = 'similar';
135
123
  }
124
+ static { this.TAG = 'Similar'; }
136
125
  }
137
- exports.Similar = Similar;
138
- Similar.TAG = 'Similar';
139
- class Producer extends MediaTag {
126
+ export class Producer extends MediaTag {
140
127
  constructor() {
141
128
  super(...arguments);
142
129
  this.FILTER = 'producer';
143
130
  }
131
+ static { this.TAG = 'Producer'; }
144
132
  }
145
- exports.Producer = Producer;
146
- Producer.TAG = 'Producer';
147
- class Marker extends MediaTag {
133
+ export class Marker extends MediaTag {
148
134
  constructor() {
149
135
  super(...arguments);
150
136
  this.FILTER = 'marker';
151
137
  }
138
+ static { this.TAG = 'Marker'; }
152
139
  _loadData(data) {
153
140
  this.type = data.type;
154
141
  this.startTimeOffset = data.startTimeOffset;
155
142
  this.endTimeOffset = data.endTimeOffset;
156
143
  }
157
144
  }
158
- exports.Marker = Marker;
159
- Marker.TAG = 'Marker';
160
145
  /**
161
146
  * Represents a single Chapter media tag.
162
147
  */
163
- class Chapter extends MediaTag {
148
+ export class Chapter extends MediaTag {
164
149
  constructor() {
165
150
  super(...arguments);
166
151
  this.FILTER = 'chapter';
167
152
  }
153
+ static { this.TAG = 'Chapter'; }
168
154
  _loadData(data) {
169
155
  this.startTimeOffset = data.startTimeOffset;
170
156
  this.endTimeOffset = data.endTimeOffset;
171
157
  this.thumb = data.thumb;
172
158
  }
173
159
  }
174
- exports.Chapter = Chapter;
175
- Chapter.TAG = 'Chapter';
176
160
  /**
177
161
  * Represents a single Collection media tag.
178
162
  */
179
- class Collection extends MediaTag {
163
+ export class Collection extends MediaTag {
180
164
  constructor() {
181
165
  super(...arguments);
182
166
  this.FILTER = 'collection';
183
167
  }
168
+ static { this.TAG = 'Collection'; }
184
169
  }
185
- exports.Collection = Collection;
186
- Collection.TAG = 'Collection';
187
- class Optimized extends plexObject_1.PlexObject {
170
+ export class Optimized extends PlexObject {
171
+ static { this.TAG = 'Item'; }
188
172
  _loadData(data) {
189
173
  this.id = data.id;
190
174
  this.composite = data.composite;
@@ -194,5 +178,14 @@ class Optimized extends plexObject_1.PlexObject {
194
178
  this.targetTagID = data.targetTagID;
195
179
  }
196
180
  }
197
- exports.Optimized = Optimized;
198
- Optimized.TAG = 'Item';
181
+ /**
182
+ * Base class for guid tags used only for Guids, as they contain only a string identifier
183
+ */
184
+ class GuidTag extends PlexObject {
185
+ _loadData(data) {
186
+ this.id = data.id;
187
+ }
188
+ }
189
+ export class Guid extends GuidTag {
190
+ static { this.TAG = 'Guid'; }
191
+ }
@@ -0,0 +1,7 @@
1
+ export interface SearchResultData {
2
+ guid: string;
3
+ name: string;
4
+ score: number;
5
+ year: number;
6
+ lifespanEnded: boolean;
7
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,6 @@
1
- import { ResourcesResponse, Connection, Device } from './myplex.types';
2
- import { PlexServer } from './server';
3
- import { PlexObject } from './base/plexObject';
1
+ import { PlexObject } from './base/plexObject.js';
2
+ import { Connection, Device, ResourcesResponse } from './myplex.types.js';
3
+ import { PlexServer } from './server.js';
4
4
  /**
5
5
  * MyPlex account and profile information. This object represents the data found Account on
6
6
  * the myplex.tv servers at the url https://plex.tv/users/account. You may create this object
@@ -10,9 +10,9 @@ import { PlexObject } from './base/plexObject';
10
10
  */
11
11
  export declare class MyPlexAccount {
12
12
  private readonly baseUrl;
13
- username?: string | undefined;
13
+ username?: string;
14
14
  private readonly password?;
15
- token?: string | undefined;
15
+ token?: string;
16
16
  private readonly timeout;
17
17
  private readonly server?;
18
18
  static key: string;
@@ -82,7 +82,7 @@ export declare class MyPlexAccount {
82
82
  * @param timeout timeout in seconds on initial connect to myplex
83
83
  * @param server not often available
84
84
  */
85
- constructor(baseUrl?: string | null, username?: string | undefined, password?: string | undefined, token?: string | undefined, timeout?: number, server?: PlexServer | undefined);
85
+ constructor(baseUrl?: string | null, username?: string, password?: string, token?: string, timeout?: number, server?: PlexServer);
86
86
  /**
87
87
  * Returns a new :class:`~server.PlexServer` or :class:`~client.PlexClient` object.
88
88
  * Often times there is more than one address specified for a server or client.
@@ -96,6 +96,11 @@ export declare class MyPlexAccount {
96
96
  */
97
97
  resource(name: string): Promise<MyPlexResource>;
98
98
  resources(): Promise<MyPlexResource[]>;
99
+ /**
100
+ * @param name Name to match against.
101
+ * @param clientId clientIdentifier to match against.
102
+ */
103
+ device(name?: string, clientId?: string): Promise<MyPlexDevice>;
99
104
  /**
100
105
  * Returns a list of all :class:`~plexapi.myplex.MyPlexDevice` objects connected to the server.
101
106
  */
@@ -218,5 +223,10 @@ export declare class MyPlexDevice extends PlexObject {
218
223
  lastSeenAt: Date;
219
224
  /** List of connection URIs for the device. */
220
225
  connections?: string[];
226
+ connect(): Promise<PlexServer>;
227
+ /**
228
+ * Remove this device from your account
229
+ */
230
+ delete(): Promise<void>;
221
231
  protected _loadData(data: Device): void;
222
232
  }