@ctrl/plex 1.5.3 → 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 +29 -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} +348 -132
  24. package/dist/{library.types.d.ts → src/library.types.d.ts} +59 -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} +4 -3
  38. package/dist/{search.js → src/search.js} +13 -19
  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} +38 -60
  48. package/dist/{video.js → src/video.js} +109 -92
  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,13 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Season = exports.Show = exports.Movie = void 0;
4
- const playable_1 = require("./base/playable");
5
- const baseFunctionality_1 = require("./baseFunctionality");
6
- const media_1 = require("./media");
7
- class Video extends playable_1.Playable {
8
- constructor(server, data, initpath, parent) {
9
- super(server, data, initpath, parent);
10
- this.server = server;
1
+ import { Playable } from './base/playable.js';
2
+ import { fetchItem, fetchItems, findItems } from './baseFunctionality.js';
3
+ import { Chapter, Collection, Country, Director, Genre, Guid, Marker, Media, Producer, Role, Similar, Writer, } from './media.js';
4
+ class Video extends Playable {
5
+ constructor() {
6
+ super(...arguments);
11
7
  /** Hardcoded as 'video' (useful for search filters). */
12
8
  this.listType = 'video';
13
9
  }
@@ -25,13 +21,11 @@ class Video extends playable_1.Playable {
25
21
  * the most specific thumbnail for that item.
26
22
  */
27
23
  get thumbUrl() {
28
- var _a, _b;
29
- const thumb = (_b = (_a = this.thumb) !== null && _a !== void 0 ? _a : this.parentThumb) !== null && _b !== void 0 ? _b : this.granparentThumb;
24
+ const thumb = this.thumb ?? this.parentThumb ?? this.granparentThumb;
30
25
  return this.server.url(thumb, true);
31
26
  }
32
27
  get artUrl() {
33
- var _a;
34
- const art = (_a = this.art) !== null && _a !== void 0 ? _a : this.grandparentArt;
28
+ const art = this.art ?? this.grandparentArt;
35
29
  return this.server.url(art, true);
36
30
  }
37
31
  /**
@@ -55,30 +49,34 @@ class Video extends playable_1.Playable {
55
49
  await this.server.query(key);
56
50
  await this.reload();
57
51
  }
52
+ async extras() {
53
+ const data = await this.server.query(this._detailsKey);
54
+ return findItems(data.MediaContainer.Metadata[0].Extras?.Metadata, undefined, Extra, this.server, this);
55
+ }
58
56
  _loadData(data) {
59
- var _a, _b;
60
- this.addedAt = new Date(data.addedAt * 1000);
61
- this.librarySectionID = data.librarySectionID;
62
- this.lastViewedAt = data.lastViewedAt
63
- ? new Date(data.lastViewedAt * 1000)
64
- : undefined;
65
- this.updatedAt = data.lastViewedAt ? new Date(data.updatedAt * 1000) : undefined;
66
57
  this.key = data.key;
67
58
  this.ratingKey = data.ratingKey;
68
- this.viewCount = (_a = data.viewCount) !== null && _a !== void 0 ? _a : 0;
69
59
  this.title = data.title;
70
60
  this.summary = data.summary;
71
61
  this.thumb = data.thumb;
72
62
  this.title = data.title;
73
- this.titleSort = (_b = data.titleSort) !== null && _b !== void 0 ? _b : this.title;
74
63
  this.type = data.type;
64
+ this.librarySectionID = data.librarySectionID;
65
+ this.addedAt = new Date(data.addedAt * 1000);
66
+ this.lastViewedAt = data.lastViewedAt
67
+ ? new Date(data.lastViewedAt * 1000)
68
+ : undefined;
69
+ this.updatedAt = data.lastViewedAt ? new Date(data.updatedAt * 1000) : undefined;
70
+ this.viewCount = data.viewCount ?? 0;
71
+ this.titleSort = data.titleSort ?? this.title;
75
72
  this.viewCount = data.viewCount;
73
+ this.playlistItemID = data.playlistItemID;
76
74
  }
77
75
  }
78
76
  /**
79
77
  * Represents a single Movie.
80
78
  */
81
- class Movie extends Video {
79
+ export class Movie extends Video {
82
80
  constructor() {
83
81
  super(...arguments);
84
82
  this.TAG = 'Video';
@@ -89,15 +87,31 @@ class Movie extends Video {
89
87
  return this.roles;
90
88
  }
91
89
  async locations() {
92
- var _a, _b;
93
90
  if (!this.isFullObject) {
94
91
  await this.reload();
95
92
  }
96
- const parts = ((_b = (_a = this.media) === null || _a === void 0 ? void 0 : _a.map(media => media.parts)) !== null && _b !== void 0 ? _b : []).flat();
93
+ const parts = (this.media?.map(media => media.parts) ?? []).flat();
97
94
  return parts.map(part => part.file);
98
95
  }
96
+ /**
97
+ * Returns True if this movie has an intro marker
98
+ */
99
+ async hasIntroMarker() {
100
+ if (!this.isFullObject) {
101
+ await this.reload();
102
+ }
103
+ return this.markers.some(marker => marker.type === 'intro');
104
+ }
105
+ /**
106
+ * Returns True if this movie has a credits marker
107
+ */
108
+ async hasCreditsMarker() {
109
+ if (!this.isFullObject) {
110
+ await this.reload();
111
+ }
112
+ return this.markers.some(marker => marker.type === 'credits');
113
+ }
99
114
  _loadData(data) {
100
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
101
115
  super._loadData(data);
102
116
  this.art = data.art;
103
117
  this.audienceRating = data.audienceRating;
@@ -107,45 +121,42 @@ class Movie extends Video {
107
121
  this.duration = data.duration;
108
122
  this.guid = data.guid;
109
123
  this.originalTitle = data.originalTitle;
110
- this.originallyAvailableAt = new Date(data.originallyAvailableAt);
124
+ this.originallyAvailableAt = data.originallyAvailableAt;
111
125
  this.primaryExtraKey = data.primaryExtraKey;
112
126
  this.rating = data.rating;
113
127
  this.ratingImage = data.ratingImage;
114
128
  this.studio = data.studio;
115
129
  this.tagline = data.tagline;
116
130
  this.userRating = data.userRating;
117
- this.viewOffset = (_a = data.viewOffset) !== null && _a !== void 0 ? _a : 0;
131
+ this.viewOffset = data.viewOffset ?? 0;
118
132
  this.year = data.year;
119
133
  this.librarySectionID = data.librarySectionID;
120
- this.directors =
121
- (_c = (_b = data.Director) === null || _b === void 0 ? void 0 : _b.map(data => new media_1.Director(this.server, data, undefined, this))) !== null && _c !== void 0 ? _c : [];
122
- this.countries =
123
- (_e = (_d = data.Country) === null || _d === void 0 ? void 0 : _d.map(data => new media_1.Country(this.server, data, undefined, this))) !== null && _e !== void 0 ? _e : [];
124
- this.writers = (_g = (_f = data.Writer) === null || _f === void 0 ? void 0 : _f.map(data => new media_1.Writer(this.server, data, undefined, this))) !== null && _g !== void 0 ? _g : [];
134
+ this.directors = data.Director?.map(d => new Director(this.server, d, undefined, this)) ?? [];
135
+ this.countries = data.Country?.map(d => new Country(this.server, d, undefined, this)) ?? [];
136
+ this.writers = data.Writer?.map(d => new Writer(this.server, d, undefined, this)) ?? [];
125
137
  this.collections =
126
- (_j = (_h = data.Collection) === null || _h === void 0 ? void 0 : _h.map(data => new media_1.Collection(this.server, data, undefined, this))) !== null && _j !== void 0 ? _j : [];
127
- this.roles = (_l = (_k = data.Role) === null || _k === void 0 ? void 0 : _k.map(data => new media_1.Role(this.server, data, undefined, this))) !== null && _l !== void 0 ? _l : [];
128
- this.similar = (_o = (_m = data.Similar) === null || _m === void 0 ? void 0 : _m.map(data => new media_1.Similar(this.server, data, undefined, this))) !== null && _o !== void 0 ? _o : [];
129
- this.genres = (_q = (_p = data.Genre) === null || _p === void 0 ? void 0 : _p.map(data => new media_1.Genre(this.server, data, undefined, this))) !== null && _q !== void 0 ? _q : [];
130
- this.producers =
131
- (_s = (_r = data.Producer) === null || _r === void 0 ? void 0 : _r.map(data => new media_1.Producer(this.server, data, undefined, this))) !== null && _s !== void 0 ? _s : [];
132
- this.media = (_u = (_t = data.Media) === null || _t === void 0 ? void 0 : _t.map(data => new media_1.Media(this.server, data, undefined, this))) !== null && _u !== void 0 ? _u : [];
138
+ data.Collection?.map(d => new Collection(this.server, d, undefined, this)) ?? [];
139
+ this.roles = data.Role?.map(d => new Role(this.server, d, undefined, this)) ?? [];
140
+ this.similar = data.Similar?.map(d => new Similar(this.server, d, undefined, this)) ?? [];
141
+ this.genres = data.Genre?.map(d => new Genre(this.server, d, undefined, this)) ?? [];
142
+ this.producers = data.Producer?.map(d => new Producer(this.server, d, undefined, this)) ?? [];
143
+ this.media = data.Media?.map(d => new Media(this.server, d, undefined, this)) ?? [];
144
+ this.guids = data.Guid?.map(d => new Guid(this.server, d, undefined, this)) ?? [];
145
+ this.markers = data.Marker?.map(d => new Marker(this.server, d, undefined, this)) ?? [];
133
146
  }
134
147
  _loadFullData(data) {
135
- var _a, _b, _c;
136
148
  const metadata = data.Metadata[0];
137
149
  this._loadData(metadata);
138
150
  this.librarySectionID = metadata.librarySectionID;
139
- this.chapters = (_a = metadata.Chapter) === null || _a === void 0 ? void 0 : _a.map(chapter => new media_1.Chapter(this.server, chapter));
151
+ this.chapters = metadata.Chapter?.map(chapter => new Chapter(this.server, chapter));
140
152
  this.collections =
141
- (_c = (_b = metadata.Collection) === null || _b === void 0 ? void 0 : _b.map(collection => new media_1.Collection(this.server, collection, undefined, this))) !== null && _c !== void 0 ? _c : [];
153
+ metadata.Collection?.map(collection => new Collection(this.server, collection, undefined, this)) ?? [];
142
154
  }
143
155
  }
144
- exports.Movie = Movie;
145
156
  /**
146
157
  * Represents a single Show (including all seasons and episodes).
147
158
  */
148
- class Show extends Video {
159
+ export class Show extends Video {
149
160
  constructor() {
150
161
  super(...arguments);
151
162
  this.TAG = 'Directory';
@@ -176,17 +187,16 @@ class Show extends Video {
176
187
  // }
177
188
  async seasons(query) {
178
189
  const key = `/library/metadata/${this.ratingKey}/children?excludeAllLeaves=1`;
179
- return baseFunctionality_1.fetchItems(this.server, key, query, Season, this);
190
+ return fetchItems(this.server, key, query, Season, this);
180
191
  }
181
192
  async episodes(query) {
182
193
  const key = `/library/metadata/${this.ratingKey}/allLeaves`;
183
- const episodes = await baseFunctionality_1.fetchItems(this.server, key, query);
194
+ const episodes = await fetchItems(this.server, key, query);
184
195
  return episodes.map(episode => new Episode(this.server, episode, key, this));
185
196
  }
186
197
  _loadData(data) {
187
- var _a, _b, _c, _d, _e;
188
198
  super._loadData(data);
189
- this.key = ((_a = data.key) !== null && _a !== void 0 ? _a : '').replace('/children', '');
199
+ this.key = (data.key ?? '').replace('/children', '');
190
200
  this.art = data.art;
191
201
  this.banner = data.banner;
192
202
  this.childCount = data.childCount;
@@ -202,18 +212,17 @@ class Show extends Video {
202
212
  this.theme = data.theme;
203
213
  this.viewedLeafCount = data.viewedLeafCount;
204
214
  this.year = data.year;
205
- this.genres = (_c = (_b = data.Genre) === null || _b === void 0 ? void 0 : _b.map(genre => new media_1.Genre(this.server, genre))) !== null && _c !== void 0 ? _c : [];
206
- this.roles = (_e = (_d = data.Role) === null || _d === void 0 ? void 0 : _d.map(role => new media_1.Role(this.server, role))) !== null && _e !== void 0 ? _e : [];
215
+ this.genres = data.Genre?.map(genre => new Genre(this.server, genre)) ?? [];
216
+ this.roles = data.Role?.map(role => new Role(this.server, role)) ?? [];
207
217
  }
208
218
  _loadFullData(data) {
209
219
  this._loadData(data.Metadata[0]);
210
220
  }
211
221
  }
212
- exports.Show = Show;
213
222
  /**
214
223
  * Represents a single Show Season (including all episodes).
215
224
  */
216
- class Season extends Video {
225
+ export class Season extends Video {
217
226
  constructor() {
218
227
  super(...arguments);
219
228
  this.TAG = 'Directory';
@@ -233,7 +242,7 @@ class Season extends Video {
233
242
  */
234
243
  async episodes(query) {
235
244
  const key = `/library/metadata/${this.ratingKey}/children`;
236
- const episodes = await baseFunctionality_1.fetchItems(this.server, key, query);
245
+ const episodes = await fetchItems(this.server, key, query);
237
246
  return episodes.map(episode => new Episode(this.server, episode, key, this));
238
247
  }
239
248
  _loadData(data) {
@@ -247,34 +256,13 @@ class Season extends Video {
247
256
  this._loadData(data);
248
257
  }
249
258
  }
250
- exports.Season = Season;
251
- class Episode extends Video {
259
+ export class Episode extends Video {
252
260
  constructor() {
253
261
  super(...arguments);
254
262
  this.TYPE = 'episode';
255
263
  this.METADATA_TYPE = 'episode';
256
- this._INCLUDES = {
257
- checkFiles: 1,
258
- includeAllConcerts: 1,
259
- includeBandwidths: 1,
260
- includeChapters: 1,
261
- includeChildren: 1,
262
- includeConcerts: 1,
263
- includeExternalMedia: 1,
264
- includeExtras: 1,
265
- includeFields: 'thumbBlurHash,artBlurHash',
266
- includeGeolocation: 1,
267
- includeLoudnessRamps: 1,
268
- includeMarkers: 1,
269
- includeOnDeck: 1,
270
- includePopularLeaves: 1,
271
- includePreferences: 1,
272
- includeRelated: 1,
273
- includeRelatedCount: 1,
274
- includeReviews: 1,
275
- includeStations: 1,
276
- };
277
264
  }
265
+ static { this.TAG = 'Video'; }
278
266
  /**
279
267
  * Returns this episodes season number.
280
268
  */
@@ -291,16 +279,15 @@ class Episode extends Video {
291
279
  return `s${seasonNumber}e${episodeNumber}`;
292
280
  }
293
281
  async season() {
294
- const data = await baseFunctionality_1.fetchItem(this.server, this.parentKey);
282
+ const data = await fetchItem(this.server, this.parentKey);
295
283
  return new Season(this.server, data, this.parentKey, this);
296
284
  }
297
285
  async show() {
298
- const data = await baseFunctionality_1.fetchItem(this.server, this.grandparentKey);
286
+ const data = await fetchItem(this.server, this.grandparentKey);
299
287
  return new Show(this.server, data, this.grandparentKey, this);
300
288
  }
301
289
  locations() {
302
- var _a, _b;
303
- const parts = ((_b = (_a = this.media) === null || _a === void 0 ? void 0 : _a.map(media => media.parts)) !== null && _b !== void 0 ? _b : []).flat();
290
+ const parts = (this.media?.map(media => media.parts) ?? []).flat();
304
291
  return parts.map(part => part.file);
305
292
  }
306
293
  /**
@@ -312,8 +299,16 @@ class Episode extends Video {
312
299
  }
313
300
  return this.markers.some(marker => marker.type === 'intro');
314
301
  }
302
+ /**
303
+ * Returns True if this episode has a credits marker
304
+ */
305
+ async hasCreditsMarker() {
306
+ if (!this.isFullObject) {
307
+ await this.reload();
308
+ }
309
+ return this.markers.some(marker => marker.type === 'credits');
310
+ }
315
311
  _loadData(data) {
316
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
317
312
  super._loadData(data);
318
313
  this.key = (data.key || '').replace('/children', '');
319
314
  this.title = data.title;
@@ -339,18 +334,40 @@ class Episode extends Video {
339
334
  this.rating = data.rating;
340
335
  this.viewOffset = data.viewOffset;
341
336
  this.year = data.year;
342
- this.directors =
343
- (_b = (_a = data.Director) === null || _a === void 0 ? void 0 : _a.map(data => new media_1.Director(this.server, data, undefined, this))) !== null && _b !== void 0 ? _b : [];
344
- this.writers = (_d = (_c = data.Writer) === null || _c === void 0 ? void 0 : _c.map(data => new media_1.Writer(this.server, data, undefined, this))) !== null && _d !== void 0 ? _d : [];
345
- this.media = (_e = data.Media) === null || _e === void 0 ? void 0 : _e.map(data => new media_1.Media(this.server, data, undefined, this));
337
+ this.directors = data.Director?.map(d => new Director(this.server, d, undefined, this)) ?? [];
338
+ this.writers = data.Writer?.map(d => new Writer(this.server, d, undefined, this)) ?? [];
339
+ this.media = data.Media?.map(d => new Media(this.server, d, undefined, this));
346
340
  this.collections =
347
- (_g = (_f = data.Collection) === null || _f === void 0 ? void 0 : _f.map(data => new media_1.Collection(this.server, data, undefined, this))) !== null && _g !== void 0 ? _g : [];
348
- this.chapters =
349
- (_j = (_h = data.Chapter) === null || _h === void 0 ? void 0 : _h.map(data => new media_1.Chapter(this.server, data, undefined, this))) !== null && _j !== void 0 ? _j : [];
350
- this.markers = (_l = (_k = data.Marker) === null || _k === void 0 ? void 0 : _k.map(data => new media_1.Marker(this.server, data, undefined, this))) !== null && _l !== void 0 ? _l : [];
341
+ data.Collection?.map(d => new Collection(this.server, d, undefined, this)) ?? [];
342
+ this.chapters = data.Chapter?.map(d => new Chapter(this.server, d, undefined, this)) ?? [];
343
+ this.markers = data.Marker?.map(d => new Marker(this.server, d, undefined, this)) ?? [];
344
+ }
345
+ _loadFullData(data) {
346
+ this._loadData(data.Metadata[0]);
347
+ }
348
+ }
349
+ export class Clip extends Video {
350
+ constructor() {
351
+ super(...arguments);
352
+ this.TYPE = 'clip';
353
+ this.METADATA_TYPE = 'clip';
354
+ }
355
+ static { this.TAG = 'Video'; }
356
+ _loadData(data) {
357
+ super._loadData(data);
358
+ }
359
+ _loadFullData(data) {
360
+ this._loadData(data.Metadata[0]);
361
+ }
362
+ }
363
+ /**
364
+ * Represents a single Extra (trailer, behindTheScenes, etc).
365
+ */
366
+ export class Extra extends Clip {
367
+ _loadData(data) {
368
+ super._loadData(data);
351
369
  }
352
370
  _loadFullData(data) {
353
371
  this._loadData(data.Metadata[0]);
354
372
  }
355
373
  }
356
- Episode.TAG = 'Video';
@@ -113,7 +113,7 @@ export interface ChapterData extends MediaTagData {
113
113
  filter?: string;
114
114
  }
115
115
  export interface MarkerData extends MediaTagData {
116
- type: 'intro';
116
+ type: 'intro' | 'credits';
117
117
  startTimeOffset: number;
118
118
  endTimeOffset: number;
119
119
  }
@@ -0,0 +1,6 @@
1
+ export var ChapterSource;
2
+ (function (ChapterSource) {
3
+ ChapterSource["Agent"] = "agent";
4
+ ChapterSource["Media"] = "media";
5
+ ChapterSource["Mixed"] = "mixed";
6
+ })(ChapterSource || (ChapterSource = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctrl/plex",
3
- "version": "1.5.3",
3
+ "version": "2.0.0",
4
4
  "description": "plex api client in typescript",
5
5
  "author": "Scott Cooper <scttcper@gmail.com>",
6
6
  "publishConfig": {
@@ -8,10 +8,11 @@
8
8
  },
9
9
  "license": "MIT",
10
10
  "repository": "scttcper/plex",
11
- "main": "dist/index.js",
12
- "typings": "dist/index.d.ts",
11
+ "type": "module",
12
+ "main": "./dist/src/index.js",
13
+ "typings": "./dist/src/index.d.ts",
13
14
  "files": [
14
- "dist"
15
+ "dist/src"
15
16
  ],
16
17
  "sideEffects": false,
17
18
  "keywords": [
@@ -19,56 +20,57 @@
19
20
  "typescript"
20
21
  ],
21
22
  "scripts": {
22
- "lint": "eslint --ext .js,.ts",
23
- "lint:fix": "eslint --fix --ext .js,.ts",
23
+ "lint": "eslint --ext .ts .",
24
+ "lint:fix": "eslint --fix --ext .ts .",
24
25
  "prepare": "npm run build",
25
- "build": "tsc -p tsconfig.build.json",
26
+ "build": "tsc",
26
27
  "build:docs": "typedoc",
27
- "test": "jest --runInBand",
28
- "test:ci": "jest --ci --runInBand --reporters=default --reporters=jest-junit --coverage",
29
- "claim-server": "ts-node scripts/claim-server.ts",
30
- "add-media": "ts-node scripts/add-media.ts",
31
- "test-cleanup": "ts-node scripts/test-cleanup.ts"
28
+ "test": "vitest run",
29
+ "test:ci": "vitest run --coverage --reporter=default --reporter=junit --outputFile=./junit.xml",
30
+ "bootstraptest": "node --loader ts-node/esm scripts/bootstraptest.ts",
31
+ "teardowntest": "node --loader ts-node/esm scripts/teardowntest.ts",
32
+ "claim-server": "node --loader ts-node/esm scripts/claim-server.ts",
33
+ "add-media": "node --loader ts-node/esm scripts/add-media.ts",
34
+ "test-cleanup": "node --loader ts-node/esm scripts/test-cleanup.ts"
32
35
  },
33
36
  "dependencies": {
34
- "@ctrl/mac-address": "^2.1.2",
35
- "got": "^11.8.2",
36
- "p-any": "^3.0.0",
37
- "type-fest": "^0.21.3",
38
- "xml2js": "^0.4.23"
37
+ "@ctrl/mac-address": "^3.0.3",
38
+ "got": "^13.0.0",
39
+ "p-any": "^4.0.0",
40
+ "type-fest": "^4.15.0",
41
+ "ws": "^8.16.0",
42
+ "xml2js": "^0.6.2"
39
43
  },
40
44
  "devDependencies": {
41
- "@babel/plugin-transform-modules-commonjs": "7.13.8",
42
- "@babel/preset-typescript": "7.13.0",
43
- "@ctrl/eslint-config": "1.3.1",
44
- "@types/lodash": "4.14.168",
45
- "@types/node": "14.14.34",
46
- "@types/puppeteer": "5.4.3",
47
- "@types/xml2js": "0.4.8",
48
- "@jest/globals": "26.6.2",
49
- "jest": "26.6.3",
50
- "jest-junit": "12.0.0",
45
+ "@ctrl/eslint-config": "4.0.14",
46
+ "@sindresorhus/tsconfig": "5.0.0",
47
+ "@types/lodash": "4.17.0",
48
+ "@types/micromatch": "4.0.7",
49
+ "@types/node": "20.12.7",
50
+ "@types/ws": "8.5.10",
51
+ "@types/xml2js": "0.4.14",
52
+ "@types/yargs": "17.0.32",
53
+ "@vitest/coverage-v8": "^1.5.0",
54
+ "delay": "6.0.0",
55
+ "execa": "8.0.1",
56
+ "glob": "10.3.12",
57
+ "globby": "14.0.1",
51
58
  "lodash": "4.17.21",
52
- "puppeteer": "8.0.0",
53
- "ts-node": "9.1.1",
54
- "typedoc": "0.20.30",
55
- "typescript": "4.2.3"
56
- },
57
- "jest": {
58
- "testEnvironment": "node"
59
- },
60
- "babel": {
61
- "presets": [
62
- "@babel/preset-typescript"
63
- ],
64
- "plugins": [
65
- "@babel/plugin-transform-modules-commonjs"
66
- ]
59
+ "make-dir": "4.0.0",
60
+ "ora": "8.0.1",
61
+ "p-retry": "6.2.0",
62
+ "ts-node": "10.9.2",
63
+ "typedoc": "0.25.13",
64
+ "typescript": "5.4.5",
65
+ "vitest": "1.5.0",
66
+ "yargs": "17.7.2"
67
67
  },
68
68
  "release": {
69
- "branch": "master"
69
+ "branches": [
70
+ "master"
71
+ ]
70
72
  },
71
73
  "engines": {
72
- "node": ">=10"
74
+ "node": ">=16.10"
73
75
  }
74
76
  }
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Playable = void 0;
4
- const partialPlexObject_1 = require("./partialPlexObject");
5
- /**
6
- * This is a general place to store functions specific to media that is Playable.
7
- * Things were getting mixed up a bit when dealing with Shows, Season, Artists,
8
- * Albums which are all not playable.
9
- */
10
- class Playable extends partialPlexObject_1.PartialPlexObject {
11
- }
12
- exports.Playable = Playable;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
package/dist/config.js DELETED
@@ -1,41 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.BASE_HEADERS = exports.X_PLEX_IDENTIFIER = exports.X_PLEX_DEVICE_NAME = exports.X_PLEX_DEVICE = exports.X_PLEX_VERSION = exports.X_PLEX_PRODUCT = exports.X_PLEX_PLATFORM_VERSION = exports.X_PLEX_PLATFORM = exports.X_PLEX_PROVIDES = exports.X_PLEX_ENABLE_FAST_CONNECT = exports.X_PLEX_CONTAINER_SIZE = exports.TIMEOUT = exports.VERSION = exports.PROJECT = void 0;
7
- const os_1 = __importDefault(require("os"));
8
- const mac_address_1 = require("@ctrl/mac-address");
9
- // TODO: Load User Defined Config
10
- // const DEFAULT_CONFIG_PATH = os.path.expanduser('~/.config/plexapi/config.ini');
11
- // const CONFIG_PATH = os.environ.get('PLEXAPI_CONFIG_PATH', DEFAULT_CONFIG_PATH);
12
- // const CONFIG = PlexConfig(CONFIG_PATH);
13
- // PlexAPI Settings
14
- exports.PROJECT = 'PlexAPI';
15
- exports.VERSION = '3.3.0';
16
- exports.TIMEOUT = 30000;
17
- exports.X_PLEX_CONTAINER_SIZE = 100;
18
- exports.X_PLEX_ENABLE_FAST_CONNECT = false;
19
- // Plex Header Configuation
20
- exports.X_PLEX_PROVIDES = 'controller';
21
- exports.X_PLEX_PLATFORM = os_1.default.type();
22
- exports.X_PLEX_PLATFORM_VERSION = os_1.default.release();
23
- exports.X_PLEX_PRODUCT = exports.PROJECT;
24
- exports.X_PLEX_VERSION = exports.VERSION;
25
- exports.X_PLEX_DEVICE = exports.X_PLEX_PLATFORM;
26
- exports.X_PLEX_DEVICE_NAME = os_1.default.hostname();
27
- const mac = mac_address_1.getMAC();
28
- const base16Mac = mac_address_1.parseMAC(mac).toLong().toString(16);
29
- exports.X_PLEX_IDENTIFIER = `0x${base16Mac}`;
30
- exports.BASE_HEADERS = {
31
- 'X-Plex-Platform': exports.X_PLEX_PLATFORM,
32
- 'X-Plex-Platform-Version': exports.X_PLEX_PLATFORM_VERSION,
33
- 'X-Plex-Provides': exports.X_PLEX_PROVIDES,
34
- 'X-Plex-Product': exports.X_PLEX_PRODUCT,
35
- 'X-Plex-Version': exports.X_PLEX_VERSION,
36
- 'X-Plex-Device': exports.X_PLEX_DEVICE,
37
- 'X-Plex-Device-Name': exports.X_PLEX_DEVICE_NAME,
38
- 'X-Plex-Client-Identifier': exports.X_PLEX_IDENTIFIER,
39
- 'X-Plex-Sync-Version': '2',
40
- 'X-Plex-Language': 'en',
41
- };
package/dist/index.d.ts DELETED
@@ -1,8 +0,0 @@
1
- export * from './client';
2
- export * from './server';
3
- export * from './myplex';
4
- export * from './library';
5
- export * from './video';
6
- export * from './media';
7
- export * from './playlist';
8
- export { SearchResult, Agent } from './search';
package/dist/index.js DELETED
@@ -1,23 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.Agent = exports.SearchResult = void 0;
14
- __exportStar(require("./client"), exports);
15
- __exportStar(require("./server"), exports);
16
- __exportStar(require("./myplex"), exports);
17
- __exportStar(require("./library"), exports);
18
- __exportStar(require("./video"), exports);
19
- __exportStar(require("./media"), exports);
20
- __exportStar(require("./playlist"), exports);
21
- var search_1 = require("./search");
22
- Object.defineProperty(exports, "SearchResult", { enumerable: true, get: function () { return search_1.SearchResult; } });
23
- Object.defineProperty(exports, "Agent", { enumerable: true, get: function () { return search_1.Agent; } });
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Protocol = exports.Status = void 0;
4
- var Status;
5
- (function (Status) {
6
- Status["Online"] = "online";
7
- Status["Offline"] = "offline";
8
- })(Status = exports.Status || (exports.Status = {}));
9
- var Protocol;
10
- (function (Protocol) {
11
- Protocol["HTTP"] = "http";
12
- Protocol["HTTPS"] = "https";
13
- })(Protocol = exports.Protocol || (exports.Protocol = {}));
@@ -1,7 +0,0 @@
1
- import { Playable } from './base/playable';
2
- export declare class Playlist extends Playable {
3
- static TAG: string;
4
- TYPE: string;
5
- protected _loadData(data: any): void;
6
- protected _loadFullData(data: any): void;
7
- }
package/dist/playlist.js DELETED
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Playlist = void 0;
4
- const playable_1 = require("./base/playable");
5
- class Playlist extends playable_1.Playable {
6
- constructor() {
7
- super(...arguments);
8
- this.TYPE = 'playlist';
9
- }
10
- _loadData(data) {
11
- // console.log(JSON.stringify(data));
12
- // TODO
13
- }
14
- _loadFullData(data) {
15
- this._loadData(data);
16
- }
17
- }
18
- exports.Playlist = Playlist;
19
- Playlist.TAG = 'Playlist';
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });