@ctrl/plex 3.12.0 → 3.12.1

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.
@@ -61,8 +61,9 @@ export class PlexObject {
61
61
  params.set(k, (value === true ? 1 : value).toString());
62
62
  }
63
63
  }
64
- if ([...params.keys()].length > 0) {
65
- detailsKey += `?${params.toString()}`;
64
+ const searchParams = params.toString();
65
+ if (searchParams.length > 0) {
66
+ detailsKey += `?${searchParams}`;
66
67
  }
67
68
  }
68
69
  return detailsKey;
@@ -93,8 +93,9 @@ export class PlexServer {
93
93
  if (limit) {
94
94
  params.limit = limit.toString();
95
95
  }
96
- const key = `/hubs/search?${new URLSearchParams(params).toString()}`;
97
- const hubs = await fetchItems(this, key, undefined, Hub, this);
96
+ const url = new URL('/hubs/search', this.baseurl);
97
+ url.search = new URLSearchParams(params).toString();
98
+ const hubs = await fetchItems(this, url.pathname + url.search, undefined, Hub, this);
98
99
  return hubs;
99
100
  }
100
101
  /**
@@ -154,8 +155,9 @@ export class PlexServer {
154
155
  args['X-Plex-Container-Start'] = '0';
155
156
  args['X-Plex-Container-Size'] = Math.min(X_PLEX_CONTAINER_SIZE, maxresults).toString();
156
157
  let results = [];
157
- let key = `/status/sessions/history/all?${new URLSearchParams(args).toString()}`;
158
- let raw = await this.query(key);
158
+ const url = new URL('/status/sessions/history/all', this.baseurl);
159
+ url.search = new URLSearchParams(args).toString();
160
+ let raw = await this.query(url.pathname + url.search);
159
161
  const totalResults = raw.MediaContainer.totalSize;
160
162
  // Filter out null/undefined items from the metadata
161
163
  const validMetadata = raw.MediaContainer.Metadata?.filter(Boolean) ?? [];
@@ -164,8 +166,8 @@ export class PlexServer {
164
166
  X_PLEX_CONTAINER_SIZE === raw.MediaContainer.size &&
165
167
  maxresults > results.length) {
166
168
  args['X-Plex-Container-Start'] = (Number(args['X-Plex-Container-Start']) + Number(args['X-Plex-Container-Size'])).toString();
167
- key = `/status/sessions/history/all?${new URLSearchParams(args).toString()}`;
168
- raw = await this.query(key);
169
+ url.search = new URLSearchParams(args).toString();
170
+ raw = await this.query(url.pathname + url.search);
169
171
  // Filter out null/undefined items from the metadata
170
172
  const validMetadata = raw.MediaContainer.Metadata?.filter(item => item != null) ?? [];
171
173
  results.push(...validMetadata);
@@ -264,10 +266,15 @@ export class PlexServer {
264
266
  * None for server, 'playlist' for playlists, 'details' for all other media types.
265
267
  */
266
268
  _buildWebURL(base = 'https://app.plex.tv/desktop/', endpoint, params) {
269
+ const url = new URL(base);
270
+ const queryString = params?.toString() ? `?${params.toString()}` : '';
267
271
  if (endpoint) {
268
- return `${base}#!/server/${this.machineIdentifier}/${endpoint}?${params?.toString()}`;
272
+ url.hash = `!/server/${this.machineIdentifier}/${endpoint}${queryString}`;
269
273
  }
270
- return `${base}#!/media/${this.machineIdentifier}/com.plexapp.plugins.library?${params?.toString()}`;
274
+ else {
275
+ url.hash = `!/media/${this.machineIdentifier}/com.plexapp.plugins.library${queryString}`;
276
+ }
277
+ return url.toString();
271
278
  }
272
279
  _uriRoot() {
273
280
  return `server://${this.machineIdentifier}/com.plexapp.plugins.library`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctrl/plex",
3
- "version": "3.12.0",
3
+ "version": "3.12.1",
4
4
  "description": "plex api client in typescript using ofetch",
5
5
  "author": "Scott Cooper <scttcper@gmail.com>",
6
6
  "publishConfig": {