playlist_remove
Remove a specific file from a saved playlist by specifying its position using a 0-based index. This tool helps manage media playback by deleting unwanted items from playlists in the mpv media player.
Instructions
Remove a file from a saved playlist by index (0-based).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Playlist name | |
| index | Yes | 0-based index to remove |
Implementation Reference
- index.js:654-680 (handler)The logic that handles the playlist_remove tool, including removing the file from the saved playlist and updating the live mpv playlist.
case "playlist_remove": { const files = readPlaylist(args.name); if (args.index < 0 || args.index >= files.length) return fail(`Index ${args.index} out of range (0–${files.length - 1})`); const removed = files.splice(args.index, 1); writePlaylist(args.name, files); // Also remove from live mpv queue if running if (await isMpvRunning()) { const currentPos = await getProperty("playlist-pos").catch(() => null); const plCount = await getProperty("playlist-count").catch(() => 0); // Find matching entry in mpv's live playlist let liveIndex = null; for (let i = 0; i < plCount; i++) { const entry = await getProperty(`playlist/${i}/filename`).catch(() => null); if (entry && (entry === removed[0] || entry.replace(/\\/g, "/") === removed[0].replace(/\\/g, "/"))) { liveIndex = i; break; } } if (liveIndex !== null) { await mpv("playlist-remove", [liveIndex]); // If we removed the currently playing track, mpv auto-advances; // make sure it's playing (not paused) if (liveIndex === currentPos) { await setProperty("pause", false); } - index.js:463-470 (registration)The tool registration definition for playlist_remove.
name: "playlist_remove", description: "Remove a file from a saved playlist by index (0-based).", inputSchema: { type: "object", properties: { name: { type: "string", description: "Playlist name" }, index: { type: "number", description: "0-based index to remove" }, },