javascript-ampache 1.0.0 → 1.0.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.
@@ -245,7 +245,7 @@ export declare class System extends Base {
245
245
  id: UID;
246
246
  type: 'song' | 'podcast_episode' | 'search' | 'playlist';
247
247
  format?: string;
248
- }): Promise<unknown>;
248
+ }): Promise<Blob>;
249
249
  /**
250
250
  * Get an art image file.
251
251
  * @remarks MINIMUM_API_VERSION=400001
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "javascript-ampache",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "A JS library for the Ampache API",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.m.js",
package/src/base.ts CHANGED
@@ -58,6 +58,27 @@ export abstract class Base {
58
58
  })
59
59
  }
60
60
 
61
+ protected binary<T> (endpoint: string, includeAuth: boolean = true): Promise<Blob> {
62
+ let url = this.url + "/server/json.server.php?action=" + endpoint;
63
+
64
+ if (includeAuth) {
65
+ url += "&auth=" + this.sessionKey + "&version=" + this.version;
66
+ }
67
+
68
+ if (this.debug) {
69
+ console.debug(
70
+ "javascript-ampache query URL %c" + url,
71
+ "color: black; font-style: italic; background-color: orange;padding: 2px"
72
+ );
73
+ }
74
+
75
+ return fetch(url)
76
+ .then(response => response.blob())
77
+ .then(r => {
78
+ return r;
79
+ })
80
+ }
81
+
61
82
  public setSessionKey(sessionKey: string) {
62
83
  this.sessionKey = sessionKey;
63
84
  }
@@ -370,7 +370,7 @@ export class System extends Base {
370
370
  }) {
371
371
  let query = 'stream';
372
372
  query += qs.stringify(params, '&');
373
- return this.request(query);
373
+ return this.binary(query);
374
374
  }
375
375
 
376
376
  /**
@@ -389,7 +389,7 @@ export class System extends Base {
389
389
  }) {
390
390
  let query = 'download';
391
391
  query += qs.stringify(params, '&');
392
- return this.request(query);
392
+ return this.binary(query);
393
393
  }
394
394
 
395
395
  /**
@@ -405,7 +405,7 @@ export class System extends Base {
405
405
  }) {
406
406
  let query = 'get_art';
407
407
  query += qs.stringify(params, '&');
408
- return this.request(query);
408
+ return this.binary(query);
409
409
  }
410
410
 
411
411
  /**