@ctrl/plex 3.10.0 → 3.11.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/dist/src/alert.js CHANGED
@@ -1,9 +1,11 @@
1
1
  import WebSocket from 'ws';
2
2
  export class AlertListener {
3
+ server;
4
+ callback;
5
+ key = '/:/websockets/notifications';
3
6
  constructor(server, callback) {
4
7
  this.server = server;
5
8
  this.callback = callback;
6
- this.key = '/:/websockets/notifications';
7
9
  }
8
10
  async run() {
9
11
  const url = this.server.url(this.key, true).toString().replace('http', 'ws');
package/dist/src/audio.js CHANGED
@@ -7,7 +7,7 @@ import { Chapter, Collection, Country, Field, Format, Genre, Guid, Image, Label,
7
7
  */
8
8
  export class Audio extends Playable {
9
9
  /** Default metadata type for audio sync items. */
10
- static { this.METADATA_TYPE = 'track'; }
10
+ static METADATA_TYPE = 'track';
11
11
  /** Hardcoded list type for filtering. */
12
12
  get listType() {
13
13
  return 'audio';
@@ -153,8 +153,8 @@ export class Audio extends Playable {
153
153
  * Represents a single Track.
154
154
  */
155
155
  export class Track extends Audio {
156
- static { this.TAG = 'Track'; }
157
- static { this.TYPE = 'track'; }
156
+ static TAG = 'Track';
157
+ static TYPE = 'track';
158
158
  // Properties from Mixins (assuming, some might overlap with Audio)
159
159
  // userRating inherited from Audio
160
160
  // art inherited from Audio
@@ -309,8 +309,8 @@ export class Track extends Audio {
309
309
  */
310
310
  export class Artist extends Audio {
311
311
  /* implements AdvancedSettingsMixin, SplitMergeMixin, UnmatchMatchMixin, ExtrasMixin, HubsMixin, RatingMixin, ArtMixin, PosterMixin, ThemeMixin, ArtistEditMixins */
312
- static { this.TAG = 'Directory'; }
313
- static { this.TYPE = 'artist'; }
312
+ static TAG = 'Directory';
313
+ static TYPE = 'artist';
314
314
  get locations() {
315
315
  // Replicate listAttrs logic (assuming Location tag with path attribute)
316
316
  return this._data?.Location?.map((loc) => loc.path).filter(Boolean) ?? [];
@@ -480,8 +480,8 @@ export class Artist extends Audio {
480
480
  * Represents a single Album.
481
481
  */
482
482
  export class Album extends Audio {
483
- static { this.TAG = 'Directory'; }
484
- static { this.TYPE = 'album'; }
483
+ static TAG = 'Directory';
484
+ static TYPE = 'album';
485
485
  constructor(server, data, initpath, parent) {
486
486
  super(server, data, initpath, parent);
487
487
  this._loadData(data);
@@ -3,31 +3,28 @@ import { SearchResult, searchType } from '../search.js';
3
3
  import { getAgentIdentifier, ltrim, tagHelper } from '../util.js';
4
4
  import { PlexObject } from './plexObject.js';
5
5
  export class PartialPlexObject extends PlexObject {
6
- constructor() {
7
- super(...arguments);
8
- this._INCLUDES = {
9
- checkFiles: 0,
10
- includeAllConcerts: 0,
11
- includeBandwidths: 1,
12
- includeChapters: 1,
13
- includeChildren: 0,
14
- includeConcerts: 0,
15
- includeExternalMedia: 0,
16
- includeExtras: 0,
17
- includeFields: 'thumbBlurHash,artBlurHash',
18
- includeGeolocation: 1,
19
- includeLoudnessRamps: 1,
20
- includeMarkers: 1,
21
- includeOnDeck: 0,
22
- includePopularLeaves: 0,
23
- includePreferences: 0,
24
- includeRelated: 0,
25
- includeRelatedCount: 0,
26
- includeReviews: 0,
27
- includeStations: 0,
28
- };
29
- this._detailsKey = this._buildDetailsKey();
30
- }
6
+ _INCLUDES = {
7
+ checkFiles: 0,
8
+ includeAllConcerts: 0,
9
+ includeBandwidths: 1,
10
+ includeChapters: 1,
11
+ includeChildren: 0,
12
+ includeConcerts: 0,
13
+ includeExternalMedia: 0,
14
+ includeExtras: 0,
15
+ includeFields: 'thumbBlurHash,artBlurHash',
16
+ includeGeolocation: 1,
17
+ includeLoudnessRamps: 1,
18
+ includeMarkers: 1,
19
+ includeOnDeck: 0,
20
+ includePopularLeaves: 0,
21
+ includePreferences: 0,
22
+ includeRelated: 0,
23
+ includeRelatedCount: 0,
24
+ includeReviews: 0,
25
+ includeStations: 0,
26
+ };
27
+ _detailsKey = this._buildDetailsKey();
31
28
  /**
32
29
  * Tell Plex Media Server to performs analysis on it this item to gather
33
30
  * information. Analysis includes:
@@ -3,10 +3,18 @@ import { URLSearchParams } from 'url';
3
3
  * Base class for all? Plex objects
4
4
  */
5
5
  export class PlexObject {
6
+ server;
6
7
  /** xml element tag */
7
- static { this.TAG = null; }
8
+ static TAG = null;
8
9
  /** xml element type */
9
- static { this.TYPE = null; }
10
+ static TYPE = null;
11
+ /**
12
+ * WeakRef to the parent object that this object is built from.
13
+ */
14
+ parent;
15
+ _detailsKey;
16
+ initpath;
17
+ _INCLUDES;
10
18
  constructor(server, data, initpath, parent) {
11
19
  this.server = server;
12
20
  this.initpath = initpath ?? this.key;
@@ -57,6 +57,7 @@ export declare class PlexClient {
57
57
  _token: string | null;
58
58
  TAG: string;
59
59
  key: string;
60
+ timeout: number;
60
61
  deviceClass?: string;
61
62
  machineIdentifier?: string;
62
63
  product?: string;
@@ -66,7 +67,6 @@ export declare class PlexClient {
66
67
  platform?: string;
67
68
  platformVersion?: string;
68
69
  title?: string;
69
- timeout: number;
70
70
  constructor(options?: PlexOptions);
71
71
  /**
72
72
  * Alias of reload as any subsequent requests to this client will be
@@ -32,17 +32,18 @@ import { BASE_HEADERS, TIMEOUT } from './config.js';
32
32
  * :func:`~plexapi.client.PlexClient.proxyThroughServer()` (default False).
33
33
  */
34
34
  export class PlexClient {
35
+ /**
36
+ * HTTP address of the client
37
+ */
38
+ _baseurl = null;
39
+ /**
40
+ * Token used to access this client
41
+ */
42
+ _token = null;
43
+ TAG = 'Player';
44
+ key = '/resources';
45
+ timeout;
35
46
  constructor(options = {}) {
36
- /**
37
- * HTTP address of the client
38
- */
39
- this._baseurl = null;
40
- /**
41
- * Token used to access this client
42
- */
43
- this._token = null;
44
- this.TAG = 'Player';
45
- this.key = '/resources';
46
47
  if (options.baseurl) {
47
48
  if (options.baseurl.endsWith('/')) {
48
49
  this._baseurl = options.baseurl.slice(0, -1);
@@ -1,39 +1,39 @@
1
1
  export class BadRequest extends Error {
2
+ message = 'An invalid request, generally a user error.';
2
3
  constructor(message) {
3
4
  super(message);
4
- this.message = 'An invalid request, generally a user error.';
5
5
  this.name = 'BadRequest';
6
6
  this.message = message;
7
7
  }
8
8
  }
9
9
  export class NotFound extends Error {
10
+ message = 'Request media item or device is not found.';
10
11
  constructor(message) {
11
12
  super(message);
12
- this.message = 'Request media item or device is not found.';
13
13
  this.name = 'NotFound';
14
14
  this.message = message;
15
15
  }
16
16
  }
17
17
  export class UnknownType extends Error {
18
+ message = 'Unknown library type.';
18
19
  constructor(message) {
19
20
  super(message);
20
- this.message = 'Unknown library type.';
21
21
  this.name = 'UnknownType';
22
22
  this.message = message;
23
23
  }
24
24
  }
25
25
  export class Unsupported extends Error {
26
+ message = 'Unsupported client request.';
26
27
  constructor(message) {
27
28
  super(message);
28
- this.message = 'Unsupported client request.';
29
29
  this.name = 'Unsupported';
30
30
  this.message = message;
31
31
  }
32
32
  }
33
33
  export class Unauthorized extends Error {
34
+ message = 'Invalid username or password.';
34
35
  constructor(message) {
35
36
  super(message);
36
- this.message = 'Invalid username or password.';
37
37
  this.name = 'Unauthorized';
38
38
  this.message = message;
39
39
  }
@@ -8,7 +8,8 @@ import { Playlist } from './playlist.js';
8
8
  import { searchType } from './search.js';
9
9
  import { Movie, Show } from './video.js';
10
10
  export class Library {
11
- static { this.key = '/library'; }
11
+ server;
12
+ static key = '/library';
12
13
  constructor(server, data) {
13
14
  this.server = server;
14
15
  this._loadData(data);
@@ -35,9 +36,9 @@ export class Library {
35
36
  }
36
37
  async section(title) {
37
38
  const sections = await this.sections();
38
- const section = sections.find(s => s.title.toLowerCase() === title.toLowerCase());
39
+ const section = sections.find(s => s.title?.toLowerCase() === title.toLowerCase());
39
40
  if (!section) {
40
- const avilableSections = sections.map(s => s.title).join(', ');
41
+ const avilableSections = sections.map(s => s.title || 'Unknown').join(', ');
41
42
  throw new Error(`Invalid library section: ${title}. Available: ${avilableSections}`);
42
43
  }
43
44
  return section;
@@ -275,9 +276,10 @@ export class Library {
275
276
  * Base class for a single library section.
276
277
  */
277
278
  export class LibrarySection extends PlexObject {
278
- static { this.ALLOWED_FILTERS = []; }
279
- static { this.ALLOWED_SORT = []; }
280
- static { this.BOOLEAN_FILTERS = ['unwatched', 'duplicate']; }
279
+ static ALLOWED_FILTERS = [];
280
+ static ALLOWED_SORT = [];
281
+ static BOOLEAN_FILTERS = ['unwatched', 'duplicate'];
282
+ SECTION_TYPE;
281
283
  async all(sort = '') {
282
284
  let sortStr = '';
283
285
  if (sort) {
@@ -573,14 +575,8 @@ export class LibrarySection extends PlexObject {
573
575
  }
574
576
  }
575
577
  export class MovieSection extends LibrarySection {
576
- constructor() {
577
- super(...arguments);
578
- this.METADATA_TYPE = 'movie';
579
- this.CONTENT_TYPE = 'video';
580
- this.SECTION_TYPE = Movie;
581
- }
582
- static { this.TYPE = 'movie'; }
583
- static { this.ALLOWED_FILTERS = [
578
+ static TYPE = 'movie';
579
+ static ALLOWED_FILTERS = [
584
580
  'unwatched',
585
581
  'duplicate',
586
582
  'year',
@@ -602,8 +598,8 @@ export class MovieSection extends LibrarySection {
602
598
  'lastViewedAt',
603
599
  'viewCount',
604
600
  'addedAt',
605
- ]; }
606
- static { this.ALLOWED_SORT = [
601
+ ];
602
+ static ALLOWED_SORT = [
607
603
  'addedAt',
608
604
  'originallyAvailableAt',
609
605
  'lastViewedAt',
@@ -611,18 +607,15 @@ export class MovieSection extends LibrarySection {
611
607
  'rating',
612
608
  'mediaHeight',
613
609
  'duration',
614
- ]; }
615
- static { this.TAG = 'Directory'; }
610
+ ];
611
+ static TAG = 'Directory';
612
+ METADATA_TYPE = 'movie';
613
+ CONTENT_TYPE = 'video';
614
+ SECTION_TYPE = Movie;
616
615
  }
617
616
  export class ShowSection extends LibrarySection {
618
- constructor() {
619
- super(...arguments);
620
- this.METADATA_TYPE = 'episode';
621
- this.CONTENT_TYPE = 'video';
622
- this.SECTION_TYPE = Show;
623
- }
624
- static { this.TYPE = 'show'; }
625
- static { this.ALLOWED_FILTERS = [
617
+ static TYPE = 'show';
618
+ static ALLOWED_FILTERS = [
626
619
  'unwatched',
627
620
  'year',
628
621
  'genre',
@@ -648,16 +641,19 @@ export class ShowSection extends LibrarySection {
648
641
  'episode.userRating',
649
642
  'episode.viewCount',
650
643
  'episode.lastViewedAt',
651
- ]; }
652
- static { this.ALLOWED_SORT = [
644
+ ];
645
+ static ALLOWED_SORT = [
653
646
  'addedAt',
654
647
  'lastViewedAt',
655
648
  'originallyAvailableAt',
656
649
  'titleSort',
657
650
  'rating',
658
651
  'unwatched',
659
- ]; }
660
- static { this.TAG = 'Directory'; }
652
+ ];
653
+ static TAG = 'Directory';
654
+ METADATA_TYPE = 'episode';
655
+ CONTENT_TYPE = 'video';
656
+ SECTION_TYPE = Show;
661
657
  // TODO: figure out how to return episode objects
662
658
  // /**
663
659
  // * Search for an episode. See :func:`~plexapi.library.LibrarySection.search` for usage.
@@ -675,14 +671,11 @@ export class ShowSection extends LibrarySection {
675
671
  }
676
672
  }
677
673
  export class MusicSection extends LibrarySection {
678
- constructor() {
679
- super(...arguments);
680
- this.METADATA_TYPE = 'track';
681
- this.CONTENT_TYPE = 'audio';
682
- this.SECTION_TYPE = Track;
683
- }
684
- static { this.TYPE = 'artist'; }
685
- static { this.TAG = 'Directory'; }
674
+ static TYPE = 'artist';
675
+ static TAG = 'Directory';
676
+ METADATA_TYPE = 'track';
677
+ CONTENT_TYPE = 'audio';
678
+ SECTION_TYPE = Track;
686
679
  /** Returns a list of Album objects in this section. */
687
680
  async albums() {
688
681
  const key = `/library/sections/${this.key}/albums`;
@@ -736,7 +729,7 @@ export class MusicSection extends LibrarySection {
736
729
  }
737
730
  /** Represents a single Hub (or category) in the PlexServer search */
738
731
  export class Hub extends PlexObject {
739
- static { this.TAG = 'Hub'; }
732
+ static TAG = 'Hub';
740
733
  _loadData(data) {
741
734
  this.hubIdentifier = data.hubIdentifier;
742
735
  this.size = data.size;
@@ -766,11 +759,8 @@ export class Folder extends PlexObject {
766
759
  }
767
760
  }
768
761
  export class Collections extends PartialPlexObject {
769
- constructor() {
770
- super(...arguments);
771
- this.TYPE = 'collection';
772
- }
773
- static { this.TAG = 'Directory'; }
762
+ static TAG = 'Directory';
763
+ TYPE = 'collection';
774
764
  // Alias for childCount
775
765
  get size() {
776
766
  return this.childCount;
@@ -809,7 +799,7 @@ export class Collections extends PartialPlexObject {
809
799
  }
810
800
  }
811
801
  export class FilterChoice extends PlexObject {
812
- static { this.TAG = 'Directory'; }
802
+ static TAG = 'Directory';
813
803
  _loadData(data) {
814
804
  this.key = data.key;
815
805
  this.title = data.title;
@@ -818,7 +808,7 @@ export class FilterChoice extends PlexObject {
818
808
  }
819
809
  }
820
810
  export class FilteringType extends PlexObject {
821
- static { this.TAG = 'Type'; }
811
+ static TAG = 'Type';
822
812
  _loadData(data) {
823
813
  this.active = data.active;
824
814
  this.fields = findItems(data, undefined, FilteringField);
@@ -833,7 +823,7 @@ export class FilteringType extends PlexObject {
833
823
  * Represents a single Filter object for a {@link FilteringType}
834
824
  */
835
825
  export class FilteringFilter extends PlexObject {
836
- static { this.TAG = 'Filter'; }
826
+ static TAG = 'Filter';
837
827
  _loadData(data) {
838
828
  this.filter = data.filter;
839
829
  this.filterType = data.filterType;
@@ -846,7 +836,7 @@ export class FilteringFilter extends PlexObject {
846
836
  * Represents a single Sort object for a {@link FilteringType}
847
837
  */
848
838
  export class FilteringSort extends PlexObject {
849
- static { this.TAG = 'Sort'; }
839
+ static TAG = 'Sort';
850
840
  _loadData(data) {
851
841
  this.active = data.active;
852
842
  this.activeDirection = data.activeDirection;
@@ -862,7 +852,7 @@ export class FilteringSort extends PlexObject {
862
852
  * Represents a single Field object for a {@link FilteringType}
863
853
  */
864
854
  export class FilteringField extends PlexObject {
865
- static { this.TAG = 'Field'; }
855
+ static TAG = 'Field';
866
856
  _loadData(data) {
867
857
  this.key = data.key;
868
858
  this.title = data.title;
@@ -874,7 +864,7 @@ export class FilteringField extends PlexObject {
874
864
  * Represents a single FieldType for library filtering.
875
865
  */
876
866
  export class FilteringFieldType extends PlexObject {
877
- static { this.TAG = 'FieldType'; }
867
+ static TAG = 'FieldType';
878
868
  _loadData(data) {
879
869
  this.type = data.type;
880
870
  this.operators = findItems(data, undefined, FilteringOperator);
@@ -884,7 +874,7 @@ export class FilteringFieldType extends PlexObject {
884
874
  * Represents a single FilterChoice for library filtering.
885
875
  */
886
876
  export class FilteringOperator extends PlexObject {
887
- static { this.TAG = 'Operator'; }
877
+ static TAG = 'Operator';
888
878
  _loadData(data) {
889
879
  this.key = data.key;
890
880
  this.type = data.type;
package/dist/src/media.js CHANGED
@@ -5,6 +5,7 @@ import { PlexObject } from './base/plexObject.js';
5
5
  * the construct used for things such as Country, Director, Genre, etc.
6
6
  */
7
7
  class MediaTag extends PlexObject {
8
+ static TAG;
8
9
  // async items(): Promise<any[]> {
9
10
  // if (!this.key) {
10
11
  // throw new Error(`Key is not defined for this tag: ${this.tag}`);
@@ -19,7 +20,7 @@ class MediaTag extends PlexObject {
19
20
  }
20
21
  }
21
22
  export class Media extends PlexObject {
22
- static { this.TAG = 'Media'; }
23
+ static TAG = 'Media';
23
24
  _loadData(data) {
24
25
  this.aspectRatio = data.aspectRatio;
25
26
  this.audioChannels = data.audioChannels;
@@ -39,7 +40,7 @@ export class Media extends PlexObject {
39
40
  }
40
41
  }
41
42
  export class MediaPart extends PlexObject {
42
- static { this.TAG = 'Part'; }
43
+ static TAG = 'Part';
43
44
  /**
44
45
  * Set the selected {@link AudioStream} for this MediaPart.
45
46
  * @param stream Audio stream or stream ID to set as selected.
@@ -97,7 +98,7 @@ export class MediaPart extends PlexObject {
97
98
  }
98
99
  }
99
100
  export class MediaPartStream extends PlexObject {
100
- static { this.TAG = 'Stream'; }
101
+ static TAG = 'Stream';
101
102
  _loadData(data) {
102
103
  this.id = data.id;
103
104
  this.codec = data.codec;
@@ -112,8 +113,8 @@ export class MediaPartStream extends PlexObject {
112
113
  * Represents a single Subtitle stream within a {@link MediaPart}.
113
114
  */
114
115
  export class SubtitleStream extends MediaPartStream {
115
- static { this.TAG = 'Stream'; }
116
- static { this.STREAMTYPE = 3; }
116
+ static TAG = 'Stream';
117
+ static STREAMTYPE = 3;
117
118
  /**
118
119
  * Sets this subtitle stream as the selected subtitle stream.
119
120
  * Alias for `MediaPart.setSelectedSubtitleStream`.
@@ -145,8 +146,8 @@ export class SubtitleStream extends MediaPartStream {
145
146
  * Represents a single Lyric stream within a {@link MediaPart}.
146
147
  */
147
148
  export class LyricStream extends MediaPartStream {
148
- static { this.TAG = 'Stream'; }
149
- static { this.STREAMTYPE = 4; }
149
+ static TAG = 'Stream';
150
+ static STREAMTYPE = 4;
150
151
  _loadData(data) {
151
152
  super._loadData(data);
152
153
  this.format = data.format;
@@ -159,72 +160,48 @@ export class LyricStream extends MediaPartStream {
159
160
  * Represents a single Role (actor/actress) media tag.
160
161
  */
161
162
  export class Role extends MediaTag {
162
- constructor() {
163
- super(...arguments);
164
- this.FILTER = 'role';
165
- }
166
- static { this.TAG = 'Role'; }
163
+ static TAG = 'Role';
164
+ FILTER = 'role';
167
165
  }
168
166
  /**
169
167
  * Represents a single Genre media tag.
170
168
  */
171
169
  export class Genre extends MediaTag {
172
- constructor() {
173
- super(...arguments);
174
- this.FILTER = 'genre';
175
- }
176
- static { this.TAG = 'Genre'; }
170
+ static TAG = 'Genre';
171
+ FILTER = 'genre';
177
172
  }
178
173
  /**
179
174
  * Represents a single Country media tag.
180
175
  */
181
176
  export class Country extends MediaTag {
182
- constructor() {
183
- super(...arguments);
184
- this.FILTER = 'country';
185
- }
186
- static { this.TAG = 'Country'; }
177
+ static TAG = 'Country';
178
+ FILTER = 'country';
187
179
  }
188
180
  /**
189
181
  * Represents a single Writer media tag.
190
182
  */
191
183
  export class Writer extends MediaTag {
192
- constructor() {
193
- super(...arguments);
194
- this.FILTER = 'writer';
195
- }
196
- static { this.TAG = 'Writer'; }
184
+ static TAG = 'Writer';
185
+ FILTER = 'writer';
197
186
  }
198
187
  /**
199
188
  * Represents a single Director media tag.
200
189
  */
201
190
  export class Director extends MediaTag {
202
- constructor() {
203
- super(...arguments);
204
- this.FILTER = 'director';
205
- }
206
- static { this.TAG = 'Director'; }
191
+ static TAG = 'Director';
192
+ FILTER = 'director';
207
193
  }
208
194
  export class Similar extends MediaTag {
209
- constructor() {
210
- super(...arguments);
211
- this.FILTER = 'similar';
212
- }
213
- static { this.TAG = 'Similar'; }
195
+ static TAG = 'Similar';
196
+ FILTER = 'similar';
214
197
  }
215
198
  export class Producer extends MediaTag {
216
- constructor() {
217
- super(...arguments);
218
- this.FILTER = 'producer';
219
- }
220
- static { this.TAG = 'Producer'; }
199
+ static TAG = 'Producer';
200
+ FILTER = 'producer';
221
201
  }
222
202
  export class Marker extends MediaTag {
223
- constructor() {
224
- super(...arguments);
225
- this.FILTER = 'marker';
226
- }
227
- static { this.TAG = 'Marker'; }
203
+ static TAG = 'Marker';
204
+ FILTER = 'marker';
228
205
  _loadData(data) {
229
206
  this.type = data.type;
230
207
  this.startTimeOffset = data.startTimeOffset;
@@ -235,11 +212,8 @@ export class Marker extends MediaTag {
235
212
  * Represents a single Chapter media tag.
236
213
  */
237
214
  export class Chapter extends MediaTag {
238
- constructor() {
239
- super(...arguments);
240
- this.FILTER = 'chapter';
241
- }
242
- static { this.TAG = 'Chapter'; }
215
+ static TAG = 'Chapter';
216
+ FILTER = 'chapter';
243
217
  _loadData(data) {
244
218
  this.startTimeOffset = data.startTimeOffset;
245
219
  this.endTimeOffset = data.endTimeOffset;
@@ -250,46 +224,31 @@ export class Chapter extends MediaTag {
250
224
  * Represents a single Collection media tag.
251
225
  */
252
226
  export class Collection extends MediaTag {
253
- constructor() {
254
- super(...arguments);
255
- this.FILTER = 'collection';
256
- }
257
- static { this.TAG = 'Collection'; }
227
+ static TAG = 'Collection';
228
+ FILTER = 'collection';
258
229
  }
259
230
  /** Represents a single Label media tag. */
260
231
  export class Label extends MediaTag {
261
- constructor() {
262
- super(...arguments);
263
- this.FILTER = 'label';
264
- }
265
- static { this.TAG = 'Label'; }
232
+ static TAG = 'Label';
233
+ FILTER = 'label';
266
234
  }
267
235
  /** Represents a single Style media tag. */
268
236
  export class Style extends MediaTag {
269
- constructor() {
270
- super(...arguments);
271
- this.FILTER = 'style';
272
- }
273
- static { this.TAG = 'Style'; }
237
+ static TAG = 'Style';
238
+ FILTER = 'style';
274
239
  }
275
240
  /** Represents a single Format media tag. */
276
241
  export class Format extends MediaTag {
277
- constructor() {
278
- super(...arguments);
279
- this.FILTER = 'format';
280
- }
281
- static { this.TAG = 'Format'; }
242
+ static TAG = 'Format';
243
+ FILTER = 'format';
282
244
  }
283
245
  /** Represents a single Subformat media tag. */
284
246
  export class Subformat extends MediaTag {
285
- constructor() {
286
- super(...arguments);
287
- this.FILTER = 'subformat';
288
- }
289
- static { this.TAG = 'Subformat'; }
247
+ static TAG = 'Subformat';
248
+ FILTER = 'subformat';
290
249
  }
291
250
  export class Optimized extends PlexObject {
292
- static { this.TAG = 'Item'; }
251
+ static TAG = 'Item';
293
252
  // TODO: Implement items()
294
253
  /**
295
254
  * Remove this Optimized item.
@@ -332,13 +291,13 @@ class GuidTag extends PlexObject {
332
291
  }
333
292
  }
334
293
  export class Guid extends GuidTag {
335
- static { this.TAG = 'Guid'; }
294
+ static TAG = 'Guid';
336
295
  }
337
296
  /**
338
297
  * Represents a single Rating media tag.
339
298
  */
340
299
  export class Rating extends PlexObject {
341
- static { this.TAG = 'Rating'; }
300
+ static TAG = 'Rating';
342
301
  _loadData(data) {
343
302
  this.image = data.image;
344
303
  this.type = data.type;
@@ -380,26 +339,61 @@ class BaseResource extends PlexObject {
380
339
  * Represents a single Art object.
381
340
  */
382
341
  export class Art extends BaseResource {
383
- static { this.TAG = 'Art'; }
342
+ static TAG = 'Art';
384
343
  }
385
344
  /**
386
345
  * Represents a single Poster object.
387
346
  */
388
347
  export class Poster extends BaseResource {
389
- static { this.TAG = 'Photo'; }
348
+ static TAG = 'Photo';
390
349
  }
391
350
  /**
392
351
  * Represents a single Theme object.
393
352
  */
394
353
  export class Theme extends BaseResource {
395
- static { this.TAG = 'Theme'; }
354
+ static TAG = 'Theme';
396
355
  }
397
356
  /**
398
357
  * Represents a single Audio stream within a {@link MediaPart}.
399
358
  */
400
359
  export class AudioStream extends MediaPartStream {
401
- static { this.TAG = 'Stream'; }
402
- static { this.STREAMTYPE = 2; }
360
+ static TAG = 'Stream';
361
+ static STREAMTYPE = 2;
362
+ /** The audio channel layout of the audio stream (ex: 5.1(side)). */
363
+ audioChannelLayout;
364
+ /** The bit depth of the audio stream (ex: 16). */
365
+ bitDepth;
366
+ /** The bitrate mode of the audio stream (ex: cbr). */
367
+ bitrateMode;
368
+ /** The number of audio channels of the audio stream (ex: 6). */
369
+ channels;
370
+ /** The duration of audio stream in milliseconds. */
371
+ duration;
372
+ /** The profile of the audio stream. */
373
+ profile;
374
+ /** The sampling rate of the audio stream (ex: 48000) */
375
+ samplingRate;
376
+ /** The stream identifier of the audio stream. */
377
+ streamIdentifier;
378
+ // Track only attributes
379
+ /** The gain for the album. */
380
+ albumGain;
381
+ /** The peak for the album. */
382
+ albumPeak;
383
+ /** The range for the album. */
384
+ albumRange;
385
+ /** The end ramp for the track. */
386
+ endRamp;
387
+ /** The gain for the track. */
388
+ gain;
389
+ /** The loudness for the track. */
390
+ loudness;
391
+ /** The lra for the track. */
392
+ lra;
393
+ /** The peak for the track. */
394
+ peak;
395
+ /** The start ramp for the track. */
396
+ startRamp;
403
397
  /**
404
398
  * Sets this audio stream as the selected audio stream.
405
399
  * Alias for {@link MediaPart.setSelectedAudioStream}.
@@ -436,7 +430,7 @@ export class AudioStream extends MediaPartStream {
436
430
  }
437
431
  /** Represents a single Image media tag. */
438
432
  export class Image extends PlexObject {
439
- static { this.TAG = 'Image'; }
433
+ static TAG = 'Image';
440
434
  _loadData(data) {
441
435
  this.alt = data.alt;
442
436
  this.type = data.type;
@@ -446,7 +440,7 @@ export class Image extends PlexObject {
446
440
  }
447
441
  /** Represents a single Field. */
448
442
  export class Field extends PlexObject {
449
- static { this.TAG = 'Field'; }
443
+ static TAG = 'Field';
450
444
  _loadData(data) {
451
445
  // Convert potential string '1' or '0' to boolean
452
446
  this.locked = data.locked === '1' || data.locked === true;
@@ -455,9 +449,6 @@ export class Field extends PlexObject {
455
449
  }
456
450
  /** Represents a single Mood media tag. */
457
451
  export class Mood extends MediaTag {
458
- constructor() {
459
- super(...arguments);
460
- this.FILTER = 'mood';
461
- }
462
- static { this.TAG = 'Mood'; }
452
+ static TAG = 'Mood';
453
+ FILTER = 'mood';
463
454
  }
@@ -13,7 +13,13 @@ import { PlexServer } from './server.js';
13
13
  * and return this object.
14
14
  */
15
15
  export class MyPlexAccount {
16
- static { this.key = 'https://plex.tv/api/v2/user'; }
16
+ baseUrl;
17
+ username;
18
+ password;
19
+ token;
20
+ timeout;
21
+ server;
22
+ static key = 'https://plex.tv/api/v2/user';
17
23
  /**
18
24
  * This follows the outline described in https://forums.plex.tv/t/authenticating-with-plex/609370
19
25
  * to fetch a token and potentially compromise username and password. To use first call `getWebLogin()`
@@ -79,6 +85,18 @@ export class MyPlexAccount {
79
85
  }
80
86
  throw new Error('Failed to authenticate before timeout');
81
87
  }
88
+ FRIENDINVITE = 'https://plex.tv/api/servers/{machineId}/shared_servers'; // post with data
89
+ HOMEUSERCREATE = 'https://plex.tv/api/home/users?title={title}'; // post with data
90
+ EXISTINGUSER = 'https://plex.tv/api/home/users?invitedEmail={username}'; // post with data
91
+ FRIENDSERVERS = 'https://plex.tv/api/servers/{machineId}/shared_servers/{serverId}'; // put with data
92
+ PLEXSERVERS = 'https://plex.tv/api/servers/{machineId}'; // get
93
+ FRIENDUPDATE = 'https://plex.tv/api/friends/{userId}'; // put with args, delete
94
+ REMOVEHOMEUSER = 'https://plex.tv/api/home/users/{userId}'; // delete
95
+ REMOVEINVITE = 'https://plex.tv/api/invites/requested/{userId}?friend=0&server=1&home=0'; // delete
96
+ REQUESTED = 'https://plex.tv/api/invites/requested'; // get
97
+ REQUESTS = 'https://plex.tv/api/invites/requests'; // get
98
+ SIGNIN = 'https://plex.tv/users/sign_in.json'; // get with auth
99
+ WEBHOOKS = 'https://plex.tv/api/v2/user/webhooks'; // get, post with data
82
100
  /**
83
101
  *
84
102
  * @param username Your MyPlex username
@@ -95,18 +113,6 @@ export class MyPlexAccount {
95
113
  this.token = token;
96
114
  this.timeout = timeout;
97
115
  this.server = server;
98
- this.FRIENDINVITE = 'https://plex.tv/api/servers/{machineId}/shared_servers'; // post with data
99
- this.HOMEUSERCREATE = 'https://plex.tv/api/home/users?title={title}'; // post with data
100
- this.EXISTINGUSER = 'https://plex.tv/api/home/users?invitedEmail={username}'; // post with data
101
- this.FRIENDSERVERS = 'https://plex.tv/api/servers/{machineId}/shared_servers/{serverId}'; // put with data
102
- this.PLEXSERVERS = 'https://plex.tv/api/servers/{machineId}'; // get
103
- this.FRIENDUPDATE = 'https://plex.tv/api/friends/{userId}'; // put with args, delete
104
- this.REMOVEHOMEUSER = 'https://plex.tv/api/home/users/{userId}'; // delete
105
- this.REMOVEINVITE = 'https://plex.tv/api/invites/requested/{userId}?friend=0&server=1&home=0'; // delete
106
- this.REQUESTED = 'https://plex.tv/api/invites/requested'; // get
107
- this.REQUESTS = 'https://plex.tv/api/invites/requests'; // get
108
- this.SIGNIN = 'https://plex.tv/users/sign_in.json'; // get with auth
109
- this.WEBHOOKS = 'https://plex.tv/api/v2/user/webhooks'; // get, post with data
110
116
  if (this.token) {
111
117
  Object.defineProperty(this, 'token', {
112
118
  enumerable: false,
@@ -292,11 +298,13 @@ async function connect(cls, url, token, timeout) {
292
298
  * content such as Plex Media Servers, iPhone or Android clients, etc.
293
299
  */
294
300
  export class MyPlexResource {
295
- static { this.key = 'https://plex.tv/api/v2/resources?includeHttps=1&includeRelay=1'; }
301
+ account;
302
+ baseUrl;
303
+ static key = 'https://plex.tv/api/v2/resources?includeHttps=1&includeRelay=1';
304
+ TAG = 'Device';
296
305
  constructor(account, data, baseUrl = null) {
297
306
  this.account = account;
298
307
  this.baseUrl = baseUrl;
299
- this.TAG = 'Device';
300
308
  this._loadData(data);
301
309
  }
302
310
  async connect(ssl = null, timeout) {
@@ -354,8 +362,8 @@ export class MyPlexResource {
354
362
  }
355
363
  }
356
364
  export class ResourceConnection {
365
+ TAG = 'Connection';
357
366
  constructor(data) {
358
- this.TAG = 'Connection';
359
367
  this._loadData(data);
360
368
  }
361
369
  _loadData(data) {
@@ -374,8 +382,8 @@ export class ResourceConnection {
374
382
  * https://plex.tv/devices.xml
375
383
  */
376
384
  export class MyPlexDevice extends PlexObject {
377
- static { this.TAG = 'Device'; }
378
- static { this.key = 'https://plex.tv/devices.xml'; }
385
+ static TAG = 'Device';
386
+ static key = 'https://plex.tv/devices.xml';
379
387
  async connect() {
380
388
  // TODO: switch between PlexServer and PlexClient
381
389
  // Try connecting to all known resource connections in parellel, but
@@ -24,13 +24,7 @@ function contentClass(data) {
24
24
  }
25
25
  }
26
26
  export class Playlist extends Playable {
27
- constructor() {
28
- super(...arguments);
29
- this.TYPE = 'playlist';
30
- /** Cache of playlist items */
31
- this._items = null;
32
- }
33
- static { this.TAG = 'Playlist'; }
27
+ static TAG = 'Playlist';
34
28
  static async create(server, title, options) {
35
29
  if (options.smart) {
36
30
  throw new Error('not yet supported');
@@ -86,6 +80,9 @@ export class Playlist extends Playable {
86
80
  const data = await server.query(key, 'post');
87
81
  return new Playlist(server, data.MediaContainer.Metadata[0], key);
88
82
  }
83
+ TYPE = 'playlist';
84
+ /** Cache of playlist items */
85
+ _items = null;
89
86
  async _edit(args) {
90
87
  const searchparams = new URLSearchParams(args);
91
88
  const key = `${this.key}?${searchparams.toString()}`;
@@ -99,7 +96,7 @@ export class Playlist extends Playable {
99
96
  */
100
97
  async item(title) {
101
98
  const items = await this.items();
102
- const matched = items.find(item => item.title.toLowerCase() === title.toLowerCase());
99
+ const matched = items.find(item => item.title?.toLowerCase() === title.toLowerCase());
103
100
  return matched ?? null;
104
101
  }
105
102
  async items() {
@@ -9,13 +9,10 @@ import { BadRequest } from './exceptions.js';
9
9
  * removing, and reordering items.
10
10
  */
11
11
  export class PlayQueue extends PlexObject {
12
- constructor() {
13
- super(...arguments);
14
- /** Cache of PlayQueue items */
15
- this._items = null;
16
- }
17
- static { this.TAG = 'PlayQueue'; }
18
- static { this.TYPE = 'playqueue'; }
12
+ static TAG = 'PlayQueue';
13
+ static TYPE = 'playqueue';
14
+ /** Cache of PlayQueue items */
15
+ _items = null;
19
16
  /**
20
17
  * Retrieve an existing PlayQueue by identifier.
21
18
  */
@@ -1,7 +1,7 @@
1
1
  import { PlexObject } from './base/plexObject.js';
2
2
  import { rsplit } from './util.js';
3
3
  export class SearchResult extends PlexObject {
4
- static { this.TAG = 'SearchResult'; }
4
+ static TAG = 'SearchResult';
5
5
  _loadData(data) {
6
6
  this.guid = data.guid;
7
7
  this.lifespanEnded = data.lifespanEnded;
@@ -14,7 +14,7 @@ export class SearchResult extends PlexObject {
14
14
  * Represents a single Agent
15
15
  */
16
16
  export class Agent extends PlexObject {
17
- static { this.TAG = 'Agent'; }
17
+ static TAG = 'Agent';
18
18
  // languageCode: any[] = [];
19
19
  _loadData(data) {
20
20
  this.hasAttribution = data.hasAttribution;
@@ -17,6 +17,13 @@ import { Settings } from './settings.js';
17
17
  * can also create an PlexServer instance from :class:`~plexapi.myplex.MyPlexAccount`.
18
18
  */
19
19
  export class PlexServer {
20
+ baseurl;
21
+ token;
22
+ timeout;
23
+ key = '/';
24
+ _library;
25
+ _settings;
26
+ _myPlexAccount;
20
27
  constructor(baseurl, token,
21
28
  /**
22
29
  * Default request timeout in milliseconds.
@@ -26,7 +33,6 @@ export class PlexServer {
26
33
  this.baseurl = baseurl;
27
34
  this.token = token;
28
35
  this.timeout = timeout;
29
- this.key = '/';
30
36
  }
31
37
  async agents(mediaType) {
32
38
  let key = '/system/agents';
@@ -22,11 +22,8 @@ var Type;
22
22
  Type["Text"] = "text";
23
23
  })(Type || (Type = {}));
24
24
  export class Settings extends PlexObject {
25
- constructor() {
26
- super(...arguments);
27
- this._data = [];
28
- }
29
- static { this.key = '/:/prefs'; }
25
+ static key = '/:/prefs';
26
+ _data = [];
30
27
  all() {
31
28
  return Object.entries(this._settings)
32
29
  .sort((a, b) => a[0].localeCompare(b[0]))
@@ -70,10 +67,7 @@ export class Settings extends PlexObject {
70
67
  * Represents a single Plex setting
71
68
  */
72
69
  export class Setting extends PlexObject {
73
- constructor() {
74
- super(...arguments);
75
- this._setValue = null;
76
- }
70
+ _setValue = null;
77
71
  /**
78
72
  * Set a new value for this setitng. NOTE: You must call {@link Settings.save} before
79
73
  * any changes to setting values are persisted to the PlexServer.
@@ -99,11 +93,8 @@ export class Setting extends PlexObject {
99
93
  }
100
94
  }
101
95
  export class Preferences extends Setting {
102
- constructor() {
103
- super(...arguments);
104
- this.FILTER = 'preferences';
105
- }
106
- static { this.TAG = 'Preferences'; }
96
+ static TAG = 'Preferences';
97
+ FILTER = 'preferences';
107
98
  }
108
99
  // class Setting(PlexObject):
109
100
  // """ Represents a single Plex setting.
package/dist/src/video.js CHANGED
@@ -2,11 +2,8 @@ import { Playable } from './base/playable.js';
2
2
  import { fetchItem, fetchItems, findItems } from './baseFunctionality.js';
3
3
  import { Chapter, Collection, Country, Director, Genre, Guid, Marker, Media, Poster, Producer, Rating, Role, Similar, Writer, } from './media.js';
4
4
  class Video extends Playable {
5
- constructor() {
6
- super(...arguments);
7
- /** Hardcoded as 'video' (useful for search filters). */
8
- this.listType = 'video';
9
- }
5
+ /** Hardcoded as 'video' (useful for search filters). */
6
+ listType = 'video';
10
7
  /**
11
8
  * Returns True if this video is watched.
12
9
  */
@@ -109,12 +106,9 @@ class Video extends Playable {
109
106
  * Represents a single Movie.
110
107
  */
111
108
  export class Movie extends Video {
112
- constructor() {
113
- super(...arguments);
114
- this.TAG = 'Video';
115
- this.TYPE = 'movie';
116
- this.METADATA_TYPE = 'movie';
117
- }
109
+ TAG = 'Video';
110
+ TYPE = 'movie';
111
+ METADATA_TYPE = 'movie';
118
112
  get actors() {
119
113
  return this.roles;
120
114
  }
@@ -190,12 +184,9 @@ export class Movie extends Video {
190
184
  * Represents a single Show (including all seasons and episodes).
191
185
  */
192
186
  export class Show extends Video {
193
- constructor() {
194
- super(...arguments);
195
- this.TAG = 'Directory';
196
- this.TYPE = 'show';
197
- this.METADATA_TYPE = 'episode';
198
- }
187
+ TAG = 'Directory';
188
+ TYPE = 'show';
189
+ METADATA_TYPE = 'episode';
199
190
  /** <:class:`~plexapi.media.Similar`>): List of Similar objects. */
200
191
  // similar: List;
201
192
  /**
@@ -256,12 +247,9 @@ export class Show extends Video {
256
247
  * Represents a single Show Season (including all episodes).
257
248
  */
258
249
  export class Season extends Video {
259
- constructor() {
260
- super(...arguments);
261
- this.TAG = 'Directory';
262
- this.TYPE = 'season';
263
- this.METADATA_TYPE = 'episode';
264
- }
250
+ TAG = 'Directory';
251
+ TYPE = 'season';
252
+ METADATA_TYPE = 'episode';
265
253
  /** Returns season number */
266
254
  get seasonNumber() {
267
255
  return this.index;
@@ -290,12 +278,9 @@ export class Season extends Video {
290
278
  }
291
279
  }
292
280
  export class Episode extends Video {
293
- constructor() {
294
- super(...arguments);
295
- this.TYPE = 'episode';
296
- this.METADATA_TYPE = 'episode';
297
- }
298
- static { this.TAG = 'Video'; }
281
+ static TAG = 'Video';
282
+ TYPE = 'episode';
283
+ METADATA_TYPE = 'episode';
299
284
  /**
300
285
  * Returns this episodes season number.
301
286
  */
@@ -380,12 +365,9 @@ export class Episode extends Video {
380
365
  }
381
366
  }
382
367
  export class Clip extends Video {
383
- constructor() {
384
- super(...arguments);
385
- this.TYPE = 'clip';
386
- this.METADATA_TYPE = 'clip';
387
- }
388
- static { this.TAG = 'Video'; }
368
+ static TAG = 'Video';
369
+ TYPE = 'clip';
370
+ METADATA_TYPE = 'clip';
389
371
  _loadData(data) {
390
372
  super._loadData(data);
391
373
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctrl/plex",
3
- "version": "3.10.0",
3
+ "version": "3.11.0",
4
4
  "description": "plex api client in typescript using ofetch",
5
5
  "author": "Scott Cooper <scttcper@gmail.com>",
6
6
  "publishConfig": {
@@ -34,33 +34,33 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@ctrl/mac-address": "^3.1.0",
37
- "ofetch": "^1.4.1",
37
+ "ofetch": "^1.5.1",
38
38
  "p-any": "^4.0.0",
39
- "type-fest": "^5.0.1",
39
+ "type-fest": "^5.2.0",
40
40
  "ws": "^8.18.3",
41
41
  "xml2js": "^0.6.2"
42
42
  },
43
43
  "devDependencies": {
44
- "@ctrl/oxlint-config": "1.2.8",
44
+ "@ctrl/oxlint-config": "1.3.2",
45
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.7.2",
46
+ "@sindresorhus/tsconfig": "8.1.0",
47
+ "@trivago/prettier-plugin-sort-imports": "6.0.0",
48
+ "@types/node": "24.10.1",
49
49
  "@types/ws": "8.18.1",
50
50
  "@types/xml2js": "0.4.14",
51
- "@types/yargs": "17.0.33",
52
- "@vitest/coverage-v8": "3.2.4",
51
+ "@types/yargs": "17.0.34",
52
+ "@vitest/coverage-v8": "4.0.8",
53
53
  "execa": "9.6.0",
54
54
  "globby": "15.0.0",
55
55
  "make-dir": "5.1.0",
56
56
  "ora": "9.0.0",
57
- "oxlint": "1.22.0",
57
+ "oxlint": "1.28.0",
58
58
  "p-retry": "7.1.0",
59
59
  "prettier": "3.6.2",
60
60
  "tsx": "4.20.6",
61
61
  "typedoc": "0.28.14",
62
62
  "typescript": "5.9.3",
63
- "vitest": "3.2.4",
63
+ "vitest": "4.0.8",
64
64
  "yargs": "18.0.0"
65
65
  },
66
66
  "release": {
@@ -91,5 +91,5 @@
91
91
  "engines": {
92
92
  "node": ">=18"
93
93
  },
94
- "packageManager": "pnpm@10.18.2"
94
+ "packageManager": "pnpm@10.22.0"
95
95
  }