-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.ts
871 lines (758 loc) · 20.6 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
import md5 from "spark-md5";
import type {
AlbumID3,
AlbumInfo,
AlbumList,
AlbumList2,
ArtistInfo,
ArtistInfo2,
ArtistWithAlbumsID3,
ArtistsID3,
Bookmarks,
ChatMessages,
Directory,
Genres,
Indexes,
InternetRadioStations,
License,
MusicFolders,
NewestPodcasts,
NowPlaying,
PlayQueue,
Playlist,
Playlists,
Podcasts,
ScanStatus,
SearchResult2,
SearchResult3,
Shares,
SimilarSongs,
SimilarSongs2,
Songs,
Starred,
Starred2,
TopSongs,
User,
Users,
VideoInfo,
Videos,
} from "./types.js";
export * from "./types.js";
import { arrayBufferToBase64 } from "./utils.js";
export interface SubsonicConfig {
url: string;
type: "subsonic" | "opensubsonic" | "navidrome";
}
export type Params = Record<string, string | string[] | number | number[] | boolean | undefined>;
export interface SubsonicBaseResponse {
status: string;
version: string;
type?: string;
serverVersion?: string;
openSubsonic?: boolean;
}
export default class SubsonicAPI {
#config: SubsonicConfig;
#fetch?: typeof fetch;
#crypto?: Crypto;
#user?: { username: string; password: string };
authenticated = false;
constructor(config: SubsonicConfig) {
this.#config = config;
}
async init() {
this.#crypto = globalThis.crypto
? globalThis.crypto
: await import("node:crypto").then((crypto) => (crypto as any).webcrypto as Crypto);
if (globalThis.fetch) {
this.#fetch = globalThis.fetch.bind(globalThis);
} else throw new Error("fetch not available");
}
async login({ username, password }: { username: string; password: string }) {
await this.init();
this.#user = { username, password };
this.authenticated = true;
try {
await this.ping();
} catch (error: unknown) {
this.#user = undefined;
this.authenticated = false;
throw error;
}
}
async navidromeSession() {
await this.init();
if (this.#config.type !== "navidrome")
throw new Error("navidromeSession is only available for navidrome");
if (!this.#user) throw new Error("not authenticated");
const base = this.baseURL();
const response = await this.#fetch!(`${base}auth/login`, {
method: "POST",
body: JSON.stringify({ username: this.#user?.username, password: this.#user?.password }),
});
if (!response.ok) return Promise.reject(response.statusText);
const data: {
id: string;
isAdmin: boolean;
name: string;
subsonicSalt: string;
subsonicToken: string;
token: string;
username: string;
} = await response.json();
return data;
}
#generateSalt() {
if (!this.#crypto) throw new Error("crypto not available");
return arrayBufferToBase64(this.#crypto.getRandomValues(new Uint8Array(16)));
}
#generateToken(password: string) {
const salt = this.#generateSalt();
return {
salt,
token: md5.hash(password + salt),
};
}
async custom(method: string, params: Params) {
return this.#request(method, params);
}
async customJSON<T>(method: string, params: Params) {
return this.#requestJSON<T>(method, params);
}
async #requestJSON<T>(method: string, args?: Params) {
return this.#request(method, args)
.then(async (res) => res.json())
.then(async (res) => res?.["subsonic-response"] as Promise<T>);
}
baseURL() {
let base = this.#config.url;
if (!base.startsWith("http")) base = `https://${base}`;
if (!base.endsWith("/")) base += "/";
return base;
}
async #request(method: string, params?: Params) {
if (!this.authenticated) throw new Error("not authenticated");
if (!this.#user) throw new Error("not authenticated");
if (!this.#fetch) throw new Error("not authenticated");
let base = this.baseURL();
if (!base.endsWith("rest/")) base += "rest/";
base += `${method}.view`;
const url = new URL(base);
url.searchParams.set("v", "1.16.1");
url.searchParams.set("c", "subsonic-api");
url.searchParams.set("f", "json");
url.searchParams.set("u", this.#user.username);
if (params) {
for (const [key, value] of Object.entries(params)) {
if (typeof value === "undefined") continue;
if (Array.isArray(value)) {
for (const v of value) {
url.searchParams.append(key, v.toString());
}
} else {
url.searchParams.set(key, value.toString());
}
}
}
const { token, salt } = this.#generateToken(this.#user.password);
url.searchParams.set("t", token);
url.searchParams.set("s", salt);
return this.#fetch(url.toString(), {
method: "GET",
headers: {
"Content-Type": "application/json",
},
});
}
// ----------
// SYSTEM API
// ----------
async ping() {
return this.#requestJSON<SubsonicBaseResponse>("ping", {});
}
async getLicense() {
return this.#requestJSON<
SubsonicBaseResponse & {
license: License;
}
>("getLicense", {});
}
// ------------
// BROWSING API
// ------------
async getMusicFolders() {
return this.#requestJSON<
SubsonicBaseResponse & {
musicFolders: MusicFolders;
}
>("getMusicFolders", {});
}
async getIndexes(args?: { musicFolderId?: string; ifModifiedSince?: number }) {
return this.#requestJSON<
SubsonicBaseResponse & {
indexes: Indexes;
}
>("getIndexes", args);
}
async getMusicDirectory(args: { id: string }) {
return this.#requestJSON<
SubsonicBaseResponse & {
directory: Directory;
}
>("getMusicDirectory", args);
}
async getGenres() {
return this.#requestJSON<
SubsonicBaseResponse & {
genres: Genres;
}
>("getGenres", {});
}
async getArtists(args?: { musicFolderId?: string }) {
return this.#requestJSON<
SubsonicBaseResponse & {
artists: ArtistsID3;
}
>("getArtists", args);
}
async getArtist(args: { id: string }) {
return this.#requestJSON<
SubsonicBaseResponse & {
artist: ArtistWithAlbumsID3;
}
>("getArtist", args);
}
async getAlbum(args: { id: string }) {
return this.#requestJSON<
SubsonicBaseResponse & {
album: AlbumID3;
}
>("getAlbum", args);
}
async getSong(args: { id: string }) {
return this.#requestJSON<
SubsonicBaseResponse & {
song: AlbumID3;
}
>("getSong", args);
}
async getVideos(args?: { musicFolderId?: string }) {
return this.#requestJSON<
SubsonicBaseResponse & {
videos: Videos;
}
>("getVideos", args);
}
async getVideoInfo(args: { id: string }) {
return this.#requestJSON<
SubsonicBaseResponse & {
videoInfo: VideoInfo;
}
>("getVideoInfo", args);
}
async getArtistInfo(args: { id: string; count?: number; includeNotPresent?: boolean }) {
return this.#requestJSON<
SubsonicBaseResponse & {
artistInfo: ArtistInfo;
}
>("getArtistInfo", args);
}
async getArtistInfo2(args: { id: string; count?: number; includeNotPresent?: boolean }) {
return this.#requestJSON<
SubsonicBaseResponse & {
artistInfo2: ArtistInfo2;
}
>("getArtistInfo2", args);
}
async getAlbumInfo(args: { id: string }) {
return this.#requestJSON<
SubsonicBaseResponse & {
albumInfo: AlbumInfo;
}
>("getAlbumInfo", args);
}
async getAlbumInfo2(args: { id: string }) {
return this.#requestJSON<
SubsonicBaseResponse & {
albumInfo: AlbumInfo;
}
>("getAlbumInfo2", args);
}
async getSimilarSongs(args: { id: string; count?: number }) {
return this.#requestJSON<
SubsonicBaseResponse & {
similarSongs: SimilarSongs;
}
>("getSimilarSongs", args);
}
async getSimilarSongs2(args: { id: string; count?: number }) {
return this.#requestJSON<
SubsonicBaseResponse & {
similarSongs2: SimilarSongs2;
}
>("getSimilarSongs2", args);
}
async getTopSongs(args: { count?: number }) {
return this.#requestJSON<
SubsonicBaseResponse & {
topSongs: TopSongs;
}
>("getTopSongs", args);
}
async getAlbumList(args: {
type:
| "alphabeticalByName"
| "alphabeticalByArtist"
| "byYear"
| "random"
| "newest"
| "highest"
| "frequent"
| "recent";
size?: number;
offset?: number;
fromYear?: number;
toYear?: number;
genre?: string;
musicFolderId?: string;
}) {
return this.#requestJSON<
SubsonicBaseResponse & {
albumList: AlbumList;
}
>("getAlbumList", args);
}
async getAlbumList2(args: {
type:
| "alphabeticalByName"
| "alphabeticalByArtist"
| "byYear"
| "random"
| "newest"
| "highest"
| "frequent"
| "recent";
size?: number;
offset?: number;
fromYear?: number;
toYear?: number;
genre?: string;
musicFolderId?: string;
}) {
return this.#requestJSON<
SubsonicBaseResponse & {
albumList2: AlbumList2;
}
>("getAlbumList2", args);
}
async getRandomSongs(args?: {
size?: number;
genre?: string;
fromYear?: number;
toYear?: number;
musicFolderId?: string;
}) {
return this.#requestJSON<
SubsonicBaseResponse & {
randomSongs: Songs;
}
>("getRandomSongs", args);
}
async getSongsByGenre(args: {
genre: string;
count?: number;
offset?: number;
musicFolderId?: string;
}) {
return this.#requestJSON<
SubsonicBaseResponse & {
songsByGenre: Songs;
}
>("getSongsByGenre", args);
}
async getNowPlaying() {
return this.#requestJSON<
SubsonicBaseResponse & {
nowPlaying: NowPlaying;
}
>("getNowPlaying", {});
}
async getStarred(args?: { musicFolderId?: string }) {
return this.#requestJSON<
SubsonicBaseResponse & {
starred: Starred;
}
>("getStarred", args);
}
async getStarred2(args?: { musicFolderId?: string }) {
return this.#requestJSON<
SubsonicBaseResponse & {
starred2: Starred2;
}
>("getStarred2", args);
}
/**
* @deprecated Deprecated since 1.4.0, use search2 instead.
*/
async search(args?: {
artist?: string;
album?: string;
title?: string;
any?: string;
count?: number;
offset?: number;
newerThan: number;
}) {
return this.#requestJSON<
SubsonicBaseResponse & {
searchResult2: SearchResult2;
}
>("search2", args);
}
async search2(args: {
query: string;
artistCount?: number;
artistOffset?: number;
albumCount?: number;
albumOffset?: number;
songCount?: number;
songOffset?: number;
musicFolderId?: string;
}) {
return this.#requestJSON<
SubsonicBaseResponse & {
searchResult2: SearchResult2;
}
>("search2", args);
}
async search3(args: {
query: string;
artistCount?: number;
artistOffset?: number;
albumCount?: number;
albumOffset?: number;
songCount?: number;
songOffset?: number;
musicFolderId?: string;
}) {
return this.#requestJSON<
SubsonicBaseResponse & {
searchResult3: SearchResult3;
}
>("search3", args);
}
async getPlaylists(args?: { username?: string }) {
return this.#requestJSON<
SubsonicBaseResponse & {
playlists: Playlists;
}
>("getPlaylists", args);
}
async getPlaylist(args: { id: string }) {
return this.#requestJSON<
SubsonicBaseResponse & {
playlist: Playlist;
}
>("getPlaylist", args);
}
async createPlaylist(args: { playlistId?: string; name: string; songId?: string[] }) {
return this.#requestJSON<
SubsonicBaseResponse & {
playlist: Playlist;
}
>("createPlaylist", args);
}
async updatePlaylist(args: {
playlistId: string;
name?: string;
comment?: string;
public?: boolean;
songIdToAdd?: string[];
songIndexToRemove?: number[];
}) {
return this.#requestJSON<
SubsonicBaseResponse & {
playlist: Playlist;
}
>("updatePlaylist", args);
}
async deletePlaylist(args: { id: string }) {
return this.#requestJSON<
SubsonicBaseResponse & {
playlist: Playlist;
}
>("deletePlaylist", args);
}
async stream(args: {
id: string;
maxBitRate?: number;
format?: "raw" | "mp3" | "ogg" | "aac";
timeOffset?: number;
size?: number;
estimateContentLength?: boolean;
converted?: boolean;
}) {
return this.#request("stream", args);
}
async download(args: {
id: string;
/**
* Only supported by Navidrome
*/
maxBitRate?: number;
/**
* Only supported by Navidrome
*/
format?: "raw" | "mp3" | "ogg" | "aac";
/**
* Only supported by Navidrome
*/
timeOffset?: number;
}) {
return this.#request("download", args);
}
async hls(args: { id: string; bitRate?: number; audioTrack?: number }) {
return this.#request("hls", args);
}
async getCaptions(args: { id: string }) {
return this.#request("getCaptions", args);
}
async getCoverArt(args: { id: string; size?: number }) {
return this.#request("getCoverArt", args);
}
async getLyrics(args: { artist?: string; title?: string }) {
return this.#request("getLyrics", args);
}
async getAvatar(args: { username: string; size?: number }) {
return this.#request("getAvatar", args);
}
async star(args: { id?: string; albumId?: string; artistId?: string }) {
return this.#requestJSON<SubsonicBaseResponse>("star", args);
}
async unstar(args: { id?: string; albumId?: string; artistId?: string }) {
return this.#requestJSON<SubsonicBaseResponse>("star", args);
}
async setRating(args: { id: string; rating: number }) {
return this.#requestJSON<SubsonicBaseResponse>("setRating", args);
}
async scrobble(args: { id: string; submission?: boolean; time?: number }) {
return this.#requestJSON<SubsonicBaseResponse>("scrobble", args);
}
async getShares() {
return this.#requestJSON<
SubsonicBaseResponse & {
shares: Shares;
}
>("getShares", {});
}
async createShare(args: { id: string; description?: string; expires?: number }) {
return this.#requestJSON<
SubsonicBaseResponse & {
shares: Shares;
}
>("createShare", args);
}
async updateShare(args: { id: string; description?: string; expires?: number }) {
return this.#requestJSON<SubsonicBaseResponse>("updateShare", args);
}
async deleteShare(args: { id: string }) {
return this.#requestJSON<SubsonicBaseResponse>("deleteShare", args);
}
async getPodcasts(args?: { id?: string; includeEpisodes?: boolean }) {
return this.#requestJSON<
SubsonicBaseResponse & {
podcasts: Podcasts;
}
>("getPodcasts", args);
}
async getNewestPodcasts(args?: { since?: number }) {
return this.#requestJSON<
SubsonicBaseResponse & {
newestPodcasts: NewestPodcasts;
}
>("getNewestPodcasts", args);
}
async refreshPodcasts() {
return this.#requestJSON<SubsonicBaseResponse>("refreshPodcasts", {});
}
async createPodcastChannel(args: { url: string }) {
return this.#requestJSON<SubsonicBaseResponse>("createPodcastChannel", args);
}
async deletePodcastChannel(args: { id: string }) {
return this.#requestJSON<SubsonicBaseResponse>("deletePodcastChannel", args);
}
async deletePodcastEpisode(args: { id: string }) {
return this.#requestJSON<SubsonicBaseResponse>("deletePodcastEpisode", args);
}
async downloadPodcastEpisode(args: { id: string }) {
return this.#request("downloadPodcastEpisode", args);
}
async jukeboxControl(args: {
action:
| "start"
| "stop"
| "skip"
| "add"
| "setGain"
| "clear"
| "shuffle"
| "get"
| "status"
| "remove"
| "set";
index?: number;
gain?: number;
id?: string;
offset?: number;
}) {
return this.#requestJSON<SubsonicBaseResponse>("jukeboxControl", args);
}
async getInternetRadioStations() {
return this.#requestJSON<
SubsonicBaseResponse & {
internetRadioStations: InternetRadioStations;
}
>("getInternetRadioStations", {});
}
async createInternetRadioStation(args: { name: string; streamUrl: string; homepageUrl?: string }) {
return this.#requestJSON<SubsonicBaseResponse>("createInternetRadioStation", args);
}
async updateInternetRadioStation(args: {
id: string;
name?: string;
streamUrl?: string;
homepageUrl?: string;
}) {
return this.#requestJSON<SubsonicBaseResponse>("updateInternetRadioStation", args);
}
async deleteInternetRadioStation(args: { id: string }) {
return this.#requestJSON<SubsonicBaseResponse>("deleteInternetRadioStation", args);
}
async getChatMessages(args?: { since?: number }) {
return this.#requestJSON<
SubsonicBaseResponse & {
chatMessages: ChatMessages;
}
>("getChatMessages", args);
}
async addChatMessage(args: { message: string }) {
return this.#requestJSON<SubsonicBaseResponse>("addChatMessage", args);
}
async getUser(args?: { username?: string }) {
return this.#requestJSON<
SubsonicBaseResponse & {
user: User;
}
>("getUser", args);
}
async getUsers() {
return this.#requestJSON<
SubsonicBaseResponse & {
users: Users;
}
>("getUsers", {});
}
async createUser(args: {
username: string; // The name of the new user.
password: string; // The password of the new user, either in clear text of
// hex-encoded (see above).
email: string; // The email address of the new user.
ldapAuthenticated?: string; // Whether the user is authenicated in LDAP.
adminRole?: string; // Whether the user is administrator.
settingsRole?: string; // Whether the user is allowed to change personal
//settings and password.
streamRole?: string; // Whether the user is allowed to play files.
jukeboxRole?: string; // Whether the user is allowed to play files in
//jukebox mode.
downloadRole?: string; // Whether the user is allowed to download files.
uploadRole?: string; // Whether the user is allowed to upload files.
playlistRole?: string; // Whether the user is allowed to create and delete
//playlists. Since 1.8.0, changing this role has no effect.
coverArtRole?: string; // Whether the user is allowed to change cover art
//and tags.
commentRole?: string; // Whether the user is allowed to create and edit
//comments and ratings.
podcastRole?: string; // Whether the user is allowed to administrate Podcasts.
shareRole?: string; // (Since 1.8.0) Whether the user is allowed to
//share files with anyone.
videoConversionRole?: string; // (Since 1.15.0) Whether the user is
//allowed to start video conversions.
musicFolderId?: string[]; // (Since 1.12.0) IDs of the music folders the
// user is allowed access to.
}) {
return this.#requestJSON<SubsonicBaseResponse>("createUser", args);
}
async updateUser(args: {
username: string; // The name of the new user.
password: string; // The password of the new user, either in clear text of
// hex-encoded (see above).
email: string; // The email address of the new user.
ldapAuthenticated?: string; // Whether the user is authenicated in LDAP.
adminRole?: string; // Whether the user is administrator.
settingsRole?: string; // Whether the user is allowed to change personal
//settings and password.
streamRole?: string; // Whether the user is allowed to play files.
jukeboxRole?: string; // Whether the user is allowed to play files in jukebox mode.
downloadRole?: string; // Whether the user is allowed to download files.
uploadRole?: string; // Whether the user is allowed to upload files.
playlistRole?: string; // Whether the user is allowed to create and delete
//playlists. Since 1.8.0, changing this role has no effect.
coverArtRole?: string; // Whether the user is allowed to change cover art
//and tags.
commentRole?: string; // Whether the user is allowed to create and edit
// comments and ratings.
podcastRole?: string; // Whether the user is allowed to administrate Podcasts.
shareRole?: string; // (Since 1.8.0) Whether the user is allowed to share
// files with anyone.
videoConversionRole?: string; // (Since 1.15.0) Whether the user is allowed
// to start video conversions.
musicFolderId?: string[]; // (Since 1.12.0) IDs of the music folders the
// user is allowed access to.
maxBitRate?: string; // (Since 1.13.0) The maximum bit rate for this
//user. 0 = no limit.
}) {
return this.#requestJSON<SubsonicBaseResponse>("createUser", args);
}
async deleteUser(args: { username: string }) {
return this.#requestJSON<SubsonicBaseResponse>("deleteUser", args);
}
async changePassword(args: { username: string; password: string }) {
return this.#requestJSON<SubsonicBaseResponse>("changePassword", args);
}
async getBookmarks() {
return this.#requestJSON<
SubsonicBaseResponse & {
bookmarks: Bookmarks;
}
>("getBookmarks", {});
}
async createBookmark(args: { id: string; position: number; comment?: string }) {
return this.#requestJSON<SubsonicBaseResponse>("createBookmark", args);
}
async deleteBookmark(args: { id: string }) {
return this.#requestJSON<SubsonicBaseResponse>("deleteBookmark", args);
}
async getPlayQueue() {
return this.#requestJSON<SubsonicBaseResponse & Partial<{ playQueue: PlayQueue }>>("getPlayQueue", {});
}
async savePlayQueue(args: { id: string; current?: string; position: number }) {
return this.#requestJSON<SubsonicBaseResponse>("savePlayQueue", args);
}
async getScanStatus() {
return this.#requestJSON<
SubsonicBaseResponse & {
scanStatus: ScanStatus;
lastScan?: number;
folderCount?: number;
}
>("getScanStatus", {});
}
/**
* @description Start scanning media library. (fullScan is only supported by
* Navidrome)
*/
async startScan(args?: { fullScan?: boolean }) {
return this.#requestJSON<SubsonicBaseResponse>("startScan", args);
}
}
export { SubsonicAPI };