navidrome-mcp 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.
- package/LICENSE +661 -0
- package/README.md +397 -0
- package/dist/capabilities.d.ts +20 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +25 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/client/auth-manager.d.ts +27 -0
- package/dist/client/auth-manager.d.ts.map +1 -0
- package/dist/client/auth-manager.js +54 -0
- package/dist/client/auth-manager.js.map +1 -0
- package/dist/client/navidrome-client.d.ts +28 -0
- package/dist/client/navidrome-client.d.ts.map +1 -0
- package/dist/client/navidrome-client.js +84 -0
- package/dist/client/navidrome-client.js.map +1 -0
- package/dist/config.d.ts +41 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +132 -0
- package/dist/config.js.map +1 -0
- package/dist/constants/defaults.d.ts +29 -0
- package/dist/constants/defaults.d.ts.map +1 -0
- package/dist/constants/defaults.js +37 -0
- package/dist/constants/defaults.js.map +1 -0
- package/dist/constants/timeouts.d.ts +66 -0
- package/dist/constants/timeouts.d.ts.map +1 -0
- package/dist/constants/timeouts.js +66 -0
- package/dist/constants/timeouts.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +70 -0
- package/dist/index.js.map +1 -0
- package/dist/resources/index.d.ts +21 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +83 -0
- package/dist/resources/index.js.map +1 -0
- package/dist/schemas/common.d.ts +68 -0
- package/dist/schemas/common.d.ts.map +1 -0
- package/dist/schemas/common.js +69 -0
- package/dist/schemas/common.js.map +1 -0
- package/dist/schemas/index.d.ts +21 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +24 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/pagination.d.ts +153 -0
- package/dist/schemas/pagination.d.ts.map +1 -0
- package/dist/schemas/pagination.js +93 -0
- package/dist/schemas/pagination.js.map +1 -0
- package/dist/schemas/validation.d.ts +147 -0
- package/dist/schemas/validation.d.ts.map +1 -0
- package/dist/schemas/validation.js +143 -0
- package/dist/schemas/validation.js.map +1 -0
- package/dist/tools/handlers/lastfm-handlers.d.ts +5 -0
- package/dist/tools/handlers/lastfm-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/lastfm-handlers.js +143 -0
- package/dist/tools/handlers/lastfm-handlers.js.map +1 -0
- package/dist/tools/handlers/lyrics-handlers.d.ts +5 -0
- package/dist/tools/handlers/lyrics-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/lyrics-handlers.js +51 -0
- package/dist/tools/handlers/lyrics-handlers.js.map +1 -0
- package/dist/tools/handlers/playlist-handlers.d.ts +5 -0
- package/dist/tools/handlers/playlist-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/playlist-handlers.js +316 -0
- package/dist/tools/handlers/playlist-handlers.js.map +1 -0
- package/dist/tools/handlers/queue-handlers.d.ts +5 -0
- package/dist/tools/handlers/queue-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/queue-handlers.js +135 -0
- package/dist/tools/handlers/queue-handlers.js.map +1 -0
- package/dist/tools/handlers/radio-handlers.d.ts +5 -0
- package/dist/tools/handlers/radio-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/radio-handlers.js +323 -0
- package/dist/tools/handlers/radio-handlers.js.map +1 -0
- package/dist/tools/handlers/registry.d.ts +26 -0
- package/dist/tools/handlers/registry.d.ts.map +1 -0
- package/dist/tools/handlers/registry.js +77 -0
- package/dist/tools/handlers/registry.js.map +1 -0
- package/dist/tools/handlers/search-handlers.d.ts +5 -0
- package/dist/tools/handlers/search-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/search-handlers.js +125 -0
- package/dist/tools/handlers/search-handlers.js.map +1 -0
- package/dist/tools/handlers/tag-handlers.d.ts +5 -0
- package/dist/tools/handlers/tag-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/tag-handlers.js +155 -0
- package/dist/tools/handlers/tag-handlers.js.map +1 -0
- package/dist/tools/handlers/user-preferences-handlers.d.ts +5 -0
- package/dist/tools/handlers/user-preferences-handlers.d.ts.map +1 -0
- package/dist/tools/handlers/user-preferences-handlers.js +155 -0
- package/dist/tools/handlers/user-preferences-handlers.js.map +1 -0
- package/dist/tools/index.d.ts +19 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +20 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/lastfm-discovery.d.ts +107 -0
- package/dist/tools/lastfm-discovery.d.ts.map +1 -0
- package/dist/tools/lastfm-discovery.js +238 -0
- package/dist/tools/lastfm-discovery.js.map +1 -0
- package/dist/tools/library.d.ts +31 -0
- package/dist/tools/library.d.ts.map +1 -0
- package/dist/tools/library.js +272 -0
- package/dist/tools/library.js.map +1 -0
- package/dist/tools/listening-history.d.ts +51 -0
- package/dist/tools/listening-history.d.ts.map +1 -0
- package/dist/tools/listening-history.js +126 -0
- package/dist/tools/listening-history.js.map +1 -0
- package/dist/tools/lyrics.d.ts +35 -0
- package/dist/tools/lyrics.d.ts.map +1 -0
- package/dist/tools/lyrics.js +222 -0
- package/dist/tools/lyrics.js.map +1 -0
- package/dist/tools/media-library.d.ts +46 -0
- package/dist/tools/media-library.d.ts.map +1 -0
- package/dist/tools/media-library.js +179 -0
- package/dist/tools/media-library.js.map +1 -0
- package/dist/tools/playlist-management.d.ts +80 -0
- package/dist/tools/playlist-management.d.ts.map +1 -0
- package/dist/tools/playlist-management.js +384 -0
- package/dist/tools/playlist-management.js.map +1 -0
- package/dist/tools/queue-management.d.ts +48 -0
- package/dist/tools/queue-management.d.ts.map +1 -0
- package/dist/tools/queue-management.js +83 -0
- package/dist/tools/queue-management.js.map +1 -0
- package/dist/tools/radio-discovery.d.ts +95 -0
- package/dist/tools/radio-discovery.d.ts.map +1 -0
- package/dist/tools/radio-discovery.js +352 -0
- package/dist/tools/radio-discovery.js.map +1 -0
- package/dist/tools/radio-validation.d.ts +49 -0
- package/dist/tools/radio-validation.d.ts.map +1 -0
- package/dist/tools/radio-validation.js +463 -0
- package/dist/tools/radio-validation.js.map +1 -0
- package/dist/tools/radio.d.ts +38 -0
- package/dist/tools/radio.d.ts.map +1 -0
- package/dist/tools/radio.js +315 -0
- package/dist/tools/radio.js.map +1 -0
- package/dist/tools/search.d.ts +54 -0
- package/dist/tools/search.d.ts.map +1 -0
- package/dist/tools/search.js +165 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/tools/tags.d.ts +63 -0
- package/dist/tools/tags.d.ts.map +1 -0
- package/dist/tools/tags.js +260 -0
- package/dist/tools/tags.js.map +1 -0
- package/dist/tools/test.d.ts +50 -0
- package/dist/tools/test.d.ts.map +1 -0
- package/dist/tools/test.js +121 -0
- package/dist/tools/test.js.map +1 -0
- package/dist/tools/user-preferences.d.ts +73 -0
- package/dist/tools/user-preferences.d.ts.map +1 -0
- package/dist/tools/user-preferences.js +231 -0
- package/dist/tools/user-preferences.js.map +1 -0
- package/dist/transformers/song-transformer.d.ts +122 -0
- package/dist/transformers/song-transformer.d.ts.map +1 -0
- package/dist/transformers/song-transformer.js +232 -0
- package/dist/transformers/song-transformer.js.map +1 -0
- package/dist/types/core.d.ts +147 -0
- package/dist/types/core.d.ts.map +1 -0
- package/dist/types/core.js +19 -0
- package/dist/types/core.js.map +1 -0
- package/dist/types/index.d.ts +23 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +19 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/lyrics.d.ts +58 -0
- package/dist/types/lyrics.d.ts.map +1 -0
- package/dist/types/lyrics.js +19 -0
- package/dist/types/lyrics.js.map +1 -0
- package/dist/types/playlists.d.ts +150 -0
- package/dist/types/playlists.d.ts.map +1 -0
- package/dist/types/playlists.js +19 -0
- package/dist/types/playlists.js.map +1 -0
- package/dist/types/radio.d.ts +192 -0
- package/dist/types/radio.d.ts.map +1 -0
- package/dist/types/radio.js +19 -0
- package/dist/types/radio.js.map +1 -0
- package/dist/types/tags.d.ts +72 -0
- package/dist/types/tags.d.ts.map +1 -0
- package/dist/types/tags.js +19 -0
- package/dist/types/tags.js.map +1 -0
- package/dist/utils/cache.d.ts +32 -0
- package/dist/utils/cache.d.ts.map +1 -0
- package/dist/utils/cache.js +84 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/error-formatter.d.ts +108 -0
- package/dist/utils/error-formatter.d.ts.map +1 -0
- package/dist/utils/error-formatter.js +161 -0
- package/dist/utils/error-formatter.js.map +1 -0
- package/dist/utils/logger.d.ts +33 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +52 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/message-manager.d.ts +74 -0
- package/dist/utils/message-manager.d.ts.map +1 -0
- package/dist/utils/message-manager.js +134 -0
- package/dist/utils/message-manager.js.map +1 -0
- package/dist/utils/version.d.ts +5 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/utils/version.js +19 -0
- package/dist/utils/version.js.map +1 -0
- package/package.json +78 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Navidrome MCP Server - Playlist Management Tools
|
|
3
|
+
* Copyright (C) 2025
|
|
4
|
+
*
|
|
5
|
+
* This program is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU Affero General Public License as published
|
|
7
|
+
* by the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
* (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
import type { NavidromeClient } from '../client/navidrome-client.js';
|
|
19
|
+
import type { PlaylistDTO, PlaylistTrackDTO, AddTracksToPlaylistResponse, RemoveTracksFromPlaylistResponse, ReorderPlaylistTrackResponse } from '../types/index.js';
|
|
20
|
+
/**
|
|
21
|
+
* List all playlists accessible to the user
|
|
22
|
+
*/
|
|
23
|
+
export declare function listPlaylists(client: NavidromeClient, args: unknown): Promise<{
|
|
24
|
+
playlists: PlaylistDTO[];
|
|
25
|
+
total: number;
|
|
26
|
+
offset: number;
|
|
27
|
+
limit: number;
|
|
28
|
+
}>;
|
|
29
|
+
/**
|
|
30
|
+
* Get a specific playlist by ID
|
|
31
|
+
*/
|
|
32
|
+
export declare function getPlaylist(client: NavidromeClient, args: unknown): Promise<PlaylistDTO>;
|
|
33
|
+
/**
|
|
34
|
+
* Create a new playlist
|
|
35
|
+
*/
|
|
36
|
+
export declare function createPlaylist(client: NavidromeClient, args: unknown): Promise<PlaylistDTO>;
|
|
37
|
+
/**
|
|
38
|
+
* Update a playlist's metadata
|
|
39
|
+
*/
|
|
40
|
+
export declare function updatePlaylist(client: NavidromeClient, args: unknown): Promise<PlaylistDTO>;
|
|
41
|
+
/**
|
|
42
|
+
* Delete a playlist (owner or admin only)
|
|
43
|
+
*/
|
|
44
|
+
export declare function deletePlaylist(client: NavidromeClient, args: unknown): Promise<{
|
|
45
|
+
success: boolean;
|
|
46
|
+
id: string;
|
|
47
|
+
message: string;
|
|
48
|
+
}>;
|
|
49
|
+
/**
|
|
50
|
+
* Get all tracks in a playlist
|
|
51
|
+
*/
|
|
52
|
+
export declare function getPlaylistTracks(client: NavidromeClient, args: unknown): Promise<{
|
|
53
|
+
tracks: PlaylistTrackDTO[];
|
|
54
|
+
total: number;
|
|
55
|
+
offset: number;
|
|
56
|
+
limit: number;
|
|
57
|
+
playlistId: string;
|
|
58
|
+
format: string;
|
|
59
|
+
m3uContent?: string;
|
|
60
|
+
}>;
|
|
61
|
+
/**
|
|
62
|
+
* Add tracks to a playlist
|
|
63
|
+
*/
|
|
64
|
+
export declare function addTracksToPlaylist(client: NavidromeClient, args: unknown): Promise<AddTracksToPlaylistResponse>;
|
|
65
|
+
/**
|
|
66
|
+
* Batch add multiple sets of tracks to a playlist
|
|
67
|
+
*/
|
|
68
|
+
export declare function batchAddTracksToPlaylist(client: NavidromeClient, args: unknown): Promise<{
|
|
69
|
+
results: AddTracksToPlaylistResponse[];
|
|
70
|
+
summary: string;
|
|
71
|
+
}>;
|
|
72
|
+
/**
|
|
73
|
+
* Remove tracks from a playlist
|
|
74
|
+
*/
|
|
75
|
+
export declare function removeTracksFromPlaylist(client: NavidromeClient, args: unknown): Promise<RemoveTracksFromPlaylistResponse>;
|
|
76
|
+
/**
|
|
77
|
+
* Reorder a track in the playlist
|
|
78
|
+
*/
|
|
79
|
+
export declare function reorderPlaylistTrack(client: NavidromeClient, args: unknown): Promise<ReorderPlaylistTrackResponse>;
|
|
80
|
+
//# sourceMappingURL=playlist-management.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playlist-management.d.ts","sourceRoot":"","sources":["../../src/tools/playlist-management.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAOrE,OAAO,KAAK,EACV,WAAW,EACX,gBAAgB,EAIhB,2BAA2B,EAC3B,gCAAgC,EAEhC,4BAA4B,EAC7B,MAAM,mBAAmB,CAAC;AA2E3B;;GAEG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;IACnF,SAAS,EAAE,WAAW,EAAE,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf,CAAC,CAyBD;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,MAAM,EAAE,eAAe,EAA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AAO,GAAG,OAAO,CAAC,gCAAgC,CAAC,CAsBhI;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAwBxH"}
|
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Navidrome MCP Server - Playlist Management Tools
|
|
3
|
+
* Copyright (C) 2025
|
|
4
|
+
*
|
|
5
|
+
* This program is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU Affero General Public License as published
|
|
7
|
+
* by the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
* (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
import { transformPlaylistsToDTO, transformToPlaylistDTO, formatDuration, } from '../transformers/song-transformer.js';
|
|
19
|
+
import { PlaylistPaginationSchema, PlaylistTracksPaginationSchema, CreatePlaylistSchema, UpdatePlaylistSchema, AddTracksToPlaylistSchema, RemoveTracksFromPlaylistSchema, ReorderPlaylistTrackSchema, PlaylistIdSchema, } from '../schemas/index.js';
|
|
20
|
+
/**
|
|
21
|
+
* Transform raw playlist track data to DTO
|
|
22
|
+
*/
|
|
23
|
+
function transformToPlaylistTrackDTO(rawTrack) {
|
|
24
|
+
const dto = {
|
|
25
|
+
id: rawTrack.id,
|
|
26
|
+
mediaFileId: rawTrack.mediaFileId || String(rawTrack.id),
|
|
27
|
+
playlistId: rawTrack.playlistId,
|
|
28
|
+
title: rawTrack.title || '',
|
|
29
|
+
album: rawTrack.album || '',
|
|
30
|
+
artist: rawTrack.artist || '',
|
|
31
|
+
duration: rawTrack.duration || 0,
|
|
32
|
+
durationFormatted: formatDuration(rawTrack.duration),
|
|
33
|
+
};
|
|
34
|
+
// Add optional fields only if they have values
|
|
35
|
+
if (rawTrack.albumArtist) {
|
|
36
|
+
dto.albumArtist = rawTrack.albumArtist;
|
|
37
|
+
}
|
|
38
|
+
if (rawTrack.bitRate !== undefined) {
|
|
39
|
+
dto.bitRate = rawTrack.bitRate;
|
|
40
|
+
}
|
|
41
|
+
if (rawTrack.path) {
|
|
42
|
+
dto.path = rawTrack.path;
|
|
43
|
+
}
|
|
44
|
+
if (rawTrack.trackNumber !== undefined) {
|
|
45
|
+
dto.trackNumber = rawTrack.trackNumber;
|
|
46
|
+
}
|
|
47
|
+
if (rawTrack.year !== undefined) {
|
|
48
|
+
dto.year = rawTrack.year;
|
|
49
|
+
}
|
|
50
|
+
if (rawTrack.genre) {
|
|
51
|
+
dto.genre = rawTrack.genre;
|
|
52
|
+
}
|
|
53
|
+
return dto;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* List all playlists accessible to the user
|
|
57
|
+
*/
|
|
58
|
+
export async function listPlaylists(client, args) {
|
|
59
|
+
const params = PlaylistPaginationSchema.parse(args);
|
|
60
|
+
try {
|
|
61
|
+
const queryParams = new URLSearchParams({
|
|
62
|
+
_start: params.offset.toString(),
|
|
63
|
+
_end: (params.offset + params.limit).toString(),
|
|
64
|
+
_sort: params.sort,
|
|
65
|
+
_order: params.order,
|
|
66
|
+
});
|
|
67
|
+
const rawPlaylists = await client.request(`/playlist?${queryParams.toString()}`);
|
|
68
|
+
const playlists = transformPlaylistsToDTO(rawPlaylists);
|
|
69
|
+
return {
|
|
70
|
+
playlists,
|
|
71
|
+
total: playlists.length,
|
|
72
|
+
offset: params.offset,
|
|
73
|
+
limit: params.limit,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
throw new Error(`Failed to fetch playlists: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Get a specific playlist by ID
|
|
82
|
+
*/
|
|
83
|
+
export async function getPlaylist(client, args) {
|
|
84
|
+
const params = PlaylistIdSchema.parse(args);
|
|
85
|
+
try {
|
|
86
|
+
const rawPlaylist = await client.request(`/playlist/${params.id}`);
|
|
87
|
+
return transformToPlaylistDTO(rawPlaylist);
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
throw new Error(`Failed to fetch playlist: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Create a new playlist
|
|
95
|
+
*/
|
|
96
|
+
export async function createPlaylist(client, args) {
|
|
97
|
+
const params = CreatePlaylistSchema.parse(args);
|
|
98
|
+
try {
|
|
99
|
+
const requestBody = {
|
|
100
|
+
name: params.name,
|
|
101
|
+
public: params.public,
|
|
102
|
+
};
|
|
103
|
+
if (params.comment !== undefined) {
|
|
104
|
+
requestBody.comment = params.comment;
|
|
105
|
+
}
|
|
106
|
+
const rawPlaylist = await client.request('/playlist', {
|
|
107
|
+
method: 'POST',
|
|
108
|
+
headers: {
|
|
109
|
+
'Content-Type': 'application/json',
|
|
110
|
+
},
|
|
111
|
+
body: JSON.stringify(requestBody),
|
|
112
|
+
});
|
|
113
|
+
const playlist = transformToPlaylistDTO(rawPlaylist);
|
|
114
|
+
// Fix the name if it's not properly returned from API
|
|
115
|
+
if (!playlist.name || playlist.name === 'Unknown Playlist') {
|
|
116
|
+
playlist.name = params.name;
|
|
117
|
+
}
|
|
118
|
+
// Fix the comment if it's not properly returned from API
|
|
119
|
+
if (params.comment && (!playlist.comment || playlist.comment === '')) {
|
|
120
|
+
playlist.comment = params.comment;
|
|
121
|
+
}
|
|
122
|
+
return playlist;
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
throw new Error(`Failed to create playlist: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Update a playlist's metadata
|
|
130
|
+
*/
|
|
131
|
+
export async function updatePlaylist(client, args) {
|
|
132
|
+
const params = UpdatePlaylistSchema.parse(args);
|
|
133
|
+
try {
|
|
134
|
+
const requestBody = {};
|
|
135
|
+
if (params.name !== undefined) {
|
|
136
|
+
requestBody.name = params.name;
|
|
137
|
+
}
|
|
138
|
+
if (params.comment !== undefined) {
|
|
139
|
+
requestBody.comment = params.comment;
|
|
140
|
+
}
|
|
141
|
+
if (params.public !== undefined) {
|
|
142
|
+
requestBody.public = params.public;
|
|
143
|
+
}
|
|
144
|
+
const rawPlaylist = await client.request(`/playlist/${params.id}`, {
|
|
145
|
+
method: 'PUT',
|
|
146
|
+
headers: {
|
|
147
|
+
'Content-Type': 'application/json',
|
|
148
|
+
},
|
|
149
|
+
body: JSON.stringify(requestBody),
|
|
150
|
+
});
|
|
151
|
+
const playlist = transformToPlaylistDTO(rawPlaylist);
|
|
152
|
+
// Fix the name if it was updated but not properly returned from API
|
|
153
|
+
if (params.name && (!playlist.name || playlist.name === 'Unknown Playlist')) {
|
|
154
|
+
playlist.name = params.name;
|
|
155
|
+
}
|
|
156
|
+
// Fix the comment if it was updated but not properly returned from API
|
|
157
|
+
if (params.comment !== undefined && (!playlist.comment || playlist.comment === '')) {
|
|
158
|
+
playlist.comment = params.comment;
|
|
159
|
+
}
|
|
160
|
+
return playlist;
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
throw new Error(`Failed to update playlist: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Delete a playlist (owner or admin only)
|
|
168
|
+
*/
|
|
169
|
+
export async function deletePlaylist(client, args) {
|
|
170
|
+
const params = PlaylistIdSchema.parse(args);
|
|
171
|
+
try {
|
|
172
|
+
await client.request(`/playlist/${params.id}`, {
|
|
173
|
+
method: 'DELETE',
|
|
174
|
+
});
|
|
175
|
+
return {
|
|
176
|
+
success: true,
|
|
177
|
+
id: params.id,
|
|
178
|
+
message: `Successfully deleted playlist with ID: ${params.id}`,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
catch (error) {
|
|
182
|
+
throw new Error(`Failed to delete playlist: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Get all tracks in a playlist
|
|
187
|
+
*/
|
|
188
|
+
export async function getPlaylistTracks(client, args) {
|
|
189
|
+
const params = PlaylistTracksPaginationSchema.parse(args);
|
|
190
|
+
try {
|
|
191
|
+
const queryParams = new URLSearchParams({
|
|
192
|
+
_start: params.offset.toString(),
|
|
193
|
+
_end: (params.offset + params.limit).toString(),
|
|
194
|
+
});
|
|
195
|
+
const headers = {};
|
|
196
|
+
if (params.format === 'm3u') {
|
|
197
|
+
headers['Accept'] = 'audio/x-mpegurl';
|
|
198
|
+
}
|
|
199
|
+
const response = await client.request(`/playlist/${params.playlistId}/tracks?${queryParams.toString()}`, {
|
|
200
|
+
method: 'GET',
|
|
201
|
+
headers,
|
|
202
|
+
});
|
|
203
|
+
if (params.format === 'm3u') {
|
|
204
|
+
return {
|
|
205
|
+
tracks: [],
|
|
206
|
+
total: 0,
|
|
207
|
+
offset: params.offset,
|
|
208
|
+
limit: params.limit,
|
|
209
|
+
playlistId: params.playlistId,
|
|
210
|
+
format: 'm3u',
|
|
211
|
+
m3uContent: response,
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
const tracks = Array.isArray(response)
|
|
215
|
+
? response.map((track) => transformToPlaylistTrackDTO(track))
|
|
216
|
+
: [];
|
|
217
|
+
return {
|
|
218
|
+
tracks,
|
|
219
|
+
total: tracks.length,
|
|
220
|
+
offset: params.offset,
|
|
221
|
+
limit: params.limit,
|
|
222
|
+
playlistId: params.playlistId,
|
|
223
|
+
format: 'json',
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
catch (error) {
|
|
227
|
+
throw new Error(`Failed to fetch playlist tracks: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Add tracks to a playlist
|
|
232
|
+
*/
|
|
233
|
+
export async function addTracksToPlaylist(client, args) {
|
|
234
|
+
const params = AddTracksToPlaylistSchema.parse(args);
|
|
235
|
+
try {
|
|
236
|
+
// Get track count before adding
|
|
237
|
+
const tracksBefore = await getPlaylistTracks(client, {
|
|
238
|
+
playlistId: params.playlistId,
|
|
239
|
+
limit: 500,
|
|
240
|
+
offset: 0
|
|
241
|
+
});
|
|
242
|
+
const countBefore = tracksBefore.tracks.length;
|
|
243
|
+
const requestBody = {};
|
|
244
|
+
if (params.ids !== undefined) {
|
|
245
|
+
requestBody.ids = params.ids;
|
|
246
|
+
}
|
|
247
|
+
if (params.albumIds !== undefined) {
|
|
248
|
+
requestBody.albumIds = params.albumIds;
|
|
249
|
+
}
|
|
250
|
+
if (params.artistIds !== undefined) {
|
|
251
|
+
requestBody.artistIds = params.artistIds;
|
|
252
|
+
}
|
|
253
|
+
if (params.discs !== undefined) {
|
|
254
|
+
requestBody.discs = params.discs;
|
|
255
|
+
}
|
|
256
|
+
const response = await client.request(`/playlist/${params.playlistId}/tracks`, {
|
|
257
|
+
method: 'POST',
|
|
258
|
+
headers: {
|
|
259
|
+
'Content-Type': 'application/json',
|
|
260
|
+
},
|
|
261
|
+
body: JSON.stringify(requestBody),
|
|
262
|
+
});
|
|
263
|
+
// Get track count after adding
|
|
264
|
+
const tracksAfter = await getPlaylistTracks(client, {
|
|
265
|
+
playlistId: params.playlistId,
|
|
266
|
+
limit: 500,
|
|
267
|
+
offset: 0
|
|
268
|
+
});
|
|
269
|
+
const countAfter = tracksAfter.tracks.length;
|
|
270
|
+
// Use actual count difference as fallback if API response is incorrect
|
|
271
|
+
const apiCount = response.added || 0;
|
|
272
|
+
const actualCount = countAfter - countBefore;
|
|
273
|
+
const addedCount = Math.max(apiCount, actualCount);
|
|
274
|
+
const success = addedCount > 0;
|
|
275
|
+
return {
|
|
276
|
+
added: addedCount,
|
|
277
|
+
message: `Successfully added ${addedCount} track${addedCount !== 1 ? 's' : ''} to playlist`,
|
|
278
|
+
success,
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
catch (error) {
|
|
282
|
+
throw new Error(`Failed to add tracks to playlist: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Batch add multiple sets of tracks to a playlist
|
|
287
|
+
*/
|
|
288
|
+
export async function batchAddTracksToPlaylist(client, args) {
|
|
289
|
+
const params = args;
|
|
290
|
+
if (!params.playlistId) {
|
|
291
|
+
throw new Error('Playlist ID is required');
|
|
292
|
+
}
|
|
293
|
+
if (!params.trackSets || !Array.isArray(params.trackSets)) {
|
|
294
|
+
throw new Error('Track sets array is required');
|
|
295
|
+
}
|
|
296
|
+
if (params.trackSets.length === 0) {
|
|
297
|
+
throw new Error('At least one track set must be provided');
|
|
298
|
+
}
|
|
299
|
+
const results = [];
|
|
300
|
+
let totalAdded = 0;
|
|
301
|
+
let successCount = 0;
|
|
302
|
+
let failedCount = 0;
|
|
303
|
+
for (const trackSet of params.trackSets) {
|
|
304
|
+
try {
|
|
305
|
+
const result = await addTracksToPlaylist(client, {
|
|
306
|
+
playlistId: params.playlistId,
|
|
307
|
+
...trackSet
|
|
308
|
+
});
|
|
309
|
+
results.push(result);
|
|
310
|
+
if (result.success) {
|
|
311
|
+
successCount++;
|
|
312
|
+
totalAdded += result.added;
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
failedCount++;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
catch (error) {
|
|
319
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
320
|
+
results.push({
|
|
321
|
+
added: 0,
|
|
322
|
+
message: `Failed to add tracks: ${errorMessage}`,
|
|
323
|
+
success: false
|
|
324
|
+
});
|
|
325
|
+
failedCount++;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
let summary = `Successfully processed ${successCount} of ${params.trackSets.length} track sets. `;
|
|
329
|
+
summary += `Total tracks added: ${totalAdded}.`;
|
|
330
|
+
if (failedCount > 0) {
|
|
331
|
+
summary += ` ${failedCount} sets failed.`;
|
|
332
|
+
}
|
|
333
|
+
return {
|
|
334
|
+
results,
|
|
335
|
+
summary
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Remove tracks from a playlist
|
|
340
|
+
*/
|
|
341
|
+
export async function removeTracksFromPlaylist(client, args) {
|
|
342
|
+
const params = RemoveTracksFromPlaylistSchema.parse(args);
|
|
343
|
+
try {
|
|
344
|
+
const queryParams = new URLSearchParams();
|
|
345
|
+
params.trackIds.forEach(id => queryParams.append('id', id));
|
|
346
|
+
const response = await client.request(`/playlist/${params.playlistId}/tracks?${queryParams.toString()}`, {
|
|
347
|
+
method: 'DELETE',
|
|
348
|
+
});
|
|
349
|
+
const removedIds = response.ids || params.trackIds;
|
|
350
|
+
return {
|
|
351
|
+
ids: removedIds,
|
|
352
|
+
message: `Successfully removed ${removedIds.length} track${removedIds.length !== 1 ? 's' : ''} from playlist`,
|
|
353
|
+
success: removedIds.length > 0,
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
catch (error) {
|
|
357
|
+
throw new Error(`Failed to remove tracks from playlist: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Reorder a track in the playlist
|
|
362
|
+
*/
|
|
363
|
+
export async function reorderPlaylistTrack(client, args) {
|
|
364
|
+
const params = ReorderPlaylistTrackSchema.parse(args);
|
|
365
|
+
try {
|
|
366
|
+
const requestBody = {
|
|
367
|
+
insert_before: params.insert_before.toString(),
|
|
368
|
+
};
|
|
369
|
+
const response = await client.request(`/playlist/${params.playlistId}/tracks/${params.trackId}`, {
|
|
370
|
+
method: 'PUT',
|
|
371
|
+
headers: {
|
|
372
|
+
'Content-Type': 'application/json',
|
|
373
|
+
},
|
|
374
|
+
body: JSON.stringify(requestBody),
|
|
375
|
+
});
|
|
376
|
+
return {
|
|
377
|
+
id: response.id || parseInt(params.trackId, 10),
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
catch (error) {
|
|
381
|
+
throw new Error(`Failed to reorder playlist track: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
//# sourceMappingURL=playlist-management.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playlist-management.js","sourceRoot":"","sources":["../../src/tools/playlist-management.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,cAAc,GAEf,MAAM,qCAAqC,CAAC;AAY7C,OAAO,EACL,wBAAwB,EACxB,8BAA8B,EAC9B,oBAAoB,EACpB,oBAAoB,EACpB,yBAAyB,EACzB,8BAA8B,EAC9B,0BAA0B,EAC1B,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAsB7B;;GAEG;AACH,SAAS,2BAA2B,CAAC,QAA0B;IAC7D,MAAM,GAAG,GAAqB;QAC5B,EAAE,EAAE,QAAQ,CAAC,EAAE;QACf,WAAW,EAAE,QAAQ,CAAC,WAAW,IAAI,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QACxD,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,KAAK,EAAE,QAAQ,CAAC,KAAK,IAAI,EAAE;QAC3B,KAAK,EAAE,QAAQ,CAAC,KAAK,IAAI,EAAE;QAC3B,MAAM,EAAE,QAAQ,CAAC,MAAM,IAAI,EAAE;QA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B,aAAa,MAAM,CAAC,UAAU,WAAW,MAAM,CAAC,OAAO,EAAE,EAAE;YAC/G,MAAM,EAAE,KAAK;YACb,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC;SAClC,CAAC,CAAC;QAEH,OAAO;YACL,EAAE,EAAE,QAAQ,CAAC,EAAE,IAAI,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;SAChD,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,qCAAqC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,CAChG,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Navidrome MCP Server - Queue Management Tools
|
|
3
|
+
* Copyright (C) 2025
|
|
4
|
+
*
|
|
5
|
+
* This program is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU Affero General Public License as published
|
|
7
|
+
* by the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
* (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
import type { NavidromeClient } from '../client/navidrome-client.js';
|
|
19
|
+
export interface QueueTrack {
|
|
20
|
+
id: string;
|
|
21
|
+
title: string;
|
|
22
|
+
artist: string;
|
|
23
|
+
album: string;
|
|
24
|
+
duration: number;
|
|
25
|
+
}
|
|
26
|
+
export interface QueueResult {
|
|
27
|
+
current: number;
|
|
28
|
+
position: number;
|
|
29
|
+
trackCount: number;
|
|
30
|
+
tracks: QueueTrack[];
|
|
31
|
+
updatedAt?: string;
|
|
32
|
+
message?: string;
|
|
33
|
+
queue?: null;
|
|
34
|
+
}
|
|
35
|
+
export interface SetQueueResult {
|
|
36
|
+
success: boolean;
|
|
37
|
+
message: string;
|
|
38
|
+
trackCount: number;
|
|
39
|
+
current: number;
|
|
40
|
+
}
|
|
41
|
+
export interface ClearQueueResult {
|
|
42
|
+
success: boolean;
|
|
43
|
+
message: string;
|
|
44
|
+
}
|
|
45
|
+
export declare function getQueue(client: NavidromeClient, _args: unknown): Promise<QueueResult>;
|
|
46
|
+
export declare function setQueue(client: NavidromeClient, args: unknown): Promise<SetQueueResult>;
|
|
47
|
+
export declare function clearQueue(client: NavidromeClient, _args: unknown): Promise<ClearQueueResult>;
|
|
48
|
+
//# sourceMappingURL=queue-management.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue-management.d.ts","sourceRoot":"","sources":["../../src/tools/queue-management.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAGrE,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,IAAI,CAAC;CACd;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAsB,QAAQ,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,CAgC5F;AAQD,wBAAsB,QAAQ,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,cAAc,CAAC,CAoB9F;AAED,wBAAsB,UAAU,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAWnG"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Navidrome MCP Server - Queue Management Tools
|
|
3
|
+
* Copyright (C) 2025
|
|
4
|
+
*
|
|
5
|
+
* This program is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU Affero General Public License as published
|
|
7
|
+
* by the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
* (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
import { z } from 'zod';
|
|
19
|
+
import { logger } from '../utils/logger.js';
|
|
20
|
+
export async function getQueue(client, _args) {
|
|
21
|
+
logger.info('Getting playback queue');
|
|
22
|
+
const response = await client.request('/queue');
|
|
23
|
+
if (!response || Object.keys(response).length === 0) {
|
|
24
|
+
return {
|
|
25
|
+
current: 0,
|
|
26
|
+
position: 0,
|
|
27
|
+
trackCount: 0,
|
|
28
|
+
tracks: [],
|
|
29
|
+
message: 'Queue is empty',
|
|
30
|
+
queue: null,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const result = {
|
|
34
|
+
current: response.current || 0,
|
|
35
|
+
position: response.position || 0,
|
|
36
|
+
trackCount: response.items?.length || 0,
|
|
37
|
+
tracks: (response.items || []).map((track) => ({
|
|
38
|
+
id: track.id,
|
|
39
|
+
title: track.title || '',
|
|
40
|
+
artist: track.artist || '',
|
|
41
|
+
album: track.album || '',
|
|
42
|
+
duration: track.duration || 0,
|
|
43
|
+
})),
|
|
44
|
+
};
|
|
45
|
+
if (response.updatedAt) {
|
|
46
|
+
result.updatedAt = response.updatedAt;
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
const SetQueueSchema = z.object({
|
|
51
|
+
songIds: z.array(z.string()),
|
|
52
|
+
current: z.number().min(0).optional().default(0),
|
|
53
|
+
position: z.number().min(0).optional().default(0),
|
|
54
|
+
});
|
|
55
|
+
export async function setQueue(client, args) {
|
|
56
|
+
const { songIds, current = 0, position = 0 } = SetQueueSchema.parse(args);
|
|
57
|
+
logger.info(`Setting queue with ${songIds.length} tracks`);
|
|
58
|
+
await client.request('/queue', {
|
|
59
|
+
method: 'POST',
|
|
60
|
+
body: JSON.stringify({
|
|
61
|
+
ids: songIds,
|
|
62
|
+
current,
|
|
63
|
+
position,
|
|
64
|
+
}),
|
|
65
|
+
});
|
|
66
|
+
return {
|
|
67
|
+
success: true,
|
|
68
|
+
message: `Queue set with ${songIds.length} tracks`,
|
|
69
|
+
trackCount: songIds.length,
|
|
70
|
+
current,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
export async function clearQueue(client, _args) {
|
|
74
|
+
logger.info('Clearing playback queue');
|
|
75
|
+
await client.request('/queue', {
|
|
76
|
+
method: 'DELETE',
|
|
77
|
+
});
|
|
78
|
+
return {
|
|
79
|
+
success: true,
|
|
80
|
+
message: 'Queue cleared',
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=queue-management.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue-management.js","sourceRoot":"","sources":["../../src/tools/queue-management.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAgC5C,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,MAAuB,EAAE,KAAc;IACpE,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IAEtC,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAoF,QAAQ,CAAC,CAAC;IAEnI,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpD,OAAO;YACL,OAAO,EAAE,CAAC;YACV,QAAQ,EAAE,CAAC;YACX,UAAU,EAAE,CAAC;YACb,MAAM,EAAE,EAAE;YACV,OAAO,EAAE,gBAAgB;YACzB,KAAK,EAAE,IAAI;SACZ,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAgB;QAC1B,OAAO,EAAE,QAAQ,CAAC,OAAO,IAAI,CAAC;QAC9B,QAAQ,EAAE,QAAQ,CAAC,QAAQ,IAAI,CAAC;QAChC,UAAU,EAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC;QACvC,MAAM,EAAE,CAAC,QAAQ,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,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