@involvex/youtube-music-cli 0.0.12 → 0.0.14

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/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ ## [0.0.14](https://github.com/involvex/youtube-music-cli/compare/v0.0.13...v0.0.14) (2026-02-18)
2
+
3
+ ### Features
4
+
5
+ - **download:** add download feature with configuration and shortcuts ([a616c4c](https://github.com/involvex/youtube-music-cli/commit/a616c4c2443cb6f7d929268fd08453708255503c))
6
+
7
+ ## [0.0.13](https://github.com/involvex/youtube-music-cli/compare/v0.0.12...v0.0.13) (2026-02-18)
8
+
9
+ ### Features
10
+
11
+ - **download:** add cover art and improved file organization ([1d48f7d](https://github.com/involvex/youtube-music-cli/commit/1d48f7de3a4787e9341697b4c6f44a50a43e752c))
12
+
13
+ ### BREAKING CHANGES
14
+
15
+ - **download:** The output file structure has changed from flat directory
16
+ to nested artist/album directories. Existing workflows expecting the old
17
+ structure will need to be updated.
18
+
1
19
  ## [0.0.12](https://github.com/involvex/youtube-music-cli/compare/v0.0.11...v0.0.12) (2026-02-18)
2
20
 
3
21
  ## [0.0.11](https://github.com/involvex/youtube-music-cli/compare/v0.0.10...v0.0.11) (2026-02-18)
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
2
  // Search view layout
3
3
  import { useNavigation } from "../../hooks/useNavigation.js";
4
4
  import { useYouTubeMusic } from "../../hooks/useYouTubeMusic.js";
@@ -108,7 +108,7 @@ function SearchLayout() {
108
108
  dispatch({ category: 'SET_SEARCH_QUERY', query: '' });
109
109
  };
110
110
  }, [dispatch]);
111
- return (_jsxs(Box, { flexDirection: "column", gap: 1, children: [_jsxs(Box, { borderStyle: "single", borderColor: theme.colors.secondary, paddingX: 1, children: [_jsx(Text, { bold: true, color: theme.colors.primary, children: "Search" }), _jsxs(Text, { color: theme.colors.dim, children: [' ', "| Limit: ", navState.searchLimit, " (Use [ or ] to adjust)"] })] }), _jsx(SearchBar, { isActive: isTyping && !isSearching, onInput: input => {
111
+ return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { color: theme.colors.dim, children: ["Limit: ", navState.searchLimit, " (Use [ or ] to adjust)"] }), _jsx(SearchBar, { isActive: isTyping && !isSearching, onInput: input => {
112
112
  void performSearch(input);
113
113
  } }), (isLoading || isSearching) && (_jsx(Text, { color: theme.colors.accent, children: "Searching..." })), error && _jsx(Text, { color: theme.colors.error, children: error }), !isLoading && navState.hasSearched && (_jsx(SearchResults, { results: results, selectedIndex: navState.selectedResult, isActive: !isTyping, onMixCreated: handleMixCreated, onDownloadStatus: handleDownloadStatus })), !isLoading && navState.hasSearched && results.length === 0 && !error && (_jsx(Text, { color: theme.colors.dim, children: "No results found" })), actionMessage && (_jsx(Text, { color: theme.colors.accent, children: actionMessage })), _jsx(Text, { color: theme.colors.dim, children: isTyping
114
114
  ? 'Type to search, Enter to start, Esc to clear'
@@ -48,8 +48,8 @@ function SearchBar({ onInput, isActive = true }) {
48
48
  useKeyBinding(['tab'], cycleType);
49
49
  useKeyBinding(['escape'], clearSearch);
50
50
  useKeyboardBlocker(isActive);
51
- return (_jsxs(Box, { flexDirection: "column", borderStyle: "single", borderColor: theme.colors.secondary, padding: 1, children: [_jsxs(Box, { marginBottom: 1, children: [_jsx(Text, { color: theme.colors.dim, children: "Type: " }), searchTypes.map((type, index) => (_jsxs(Text, { color: navState.searchType === type
51
+ return (_jsxs(Box, { flexDirection: "column", borderStyle: "single", borderColor: theme.colors.secondary, paddingX: 1, children: [_jsxs(Box, { children: [_jsx(Text, { color: theme.colors.dim, children: "Type: " }), searchTypes.map((type, index) => (_jsxs(Text, { color: navState.searchType === type
52
52
  ? theme.colors.primary
53
- : theme.colors.dim, bold: navState.searchType === type, children: [type, index < searchTypes.length - 1 && ' '] }, type))), _jsx(Text, { color: theme.colors.dim, children: " (Tab to switch)" })] }), isActive && (_jsxs(Box, { children: [_jsx(Text, { color: theme.colors.primary, children: "Search: " }), _jsx(TextInput, { value: input, onChange: setInput, onSubmit: handleSubmit, placeholder: "Type to search...", focus: isActive })] })), !isActive && (_jsxs(Box, { children: [_jsx(Text, { color: theme.colors.primary, children: "Search: " }), _jsx(Text, { color: theme.colors.dim, children: input || 'Type to search...' })] })), _jsx(Text, { color: theme.colors.dim, children: "Type to search, Enter to search, Tab to change type, Esc to clear" })] }));
53
+ : theme.colors.dim, bold: navState.searchType === type, children: [type, index < searchTypes.length - 1 && ' '] }, type))), _jsx(Text, { color: theme.colors.dim, children: " (Tab to switch)" })] }), isActive && (_jsxs(Box, { children: [_jsx(Text, { color: theme.colors.primary, children: "Search: " }), _jsx(TextInput, { value: input, onChange: setInput, onSubmit: handleSubmit, placeholder: "Type to search...", focus: isActive })] })), !isActive && (_jsxs(Box, { children: [_jsx(Text, { color: theme.colors.primary, children: "Search: " }), _jsx(Text, { color: theme.colors.dim, children: input || 'Type to search...' })] }))] }));
54
54
  }
55
55
  export default React.memo(SearchBar);
@@ -1,4 +1,4 @@
1
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  // Search results component
3
3
  import React from 'react';
4
4
  import { Box, Text } from 'ink';
@@ -7,7 +7,7 @@ import { useNavigation } from "../../hooks/useNavigation.js";
7
7
  import { useKeyBinding } from "../../hooks/useKeyboard.js";
8
8
  import { usePlayer } from "../../hooks/usePlayer.js";
9
9
  import { usePlaylist } from "../../hooks/usePlaylist.js";
10
- import { KEYBINDINGS, VIEW } from "../../utils/constants.js";
10
+ import { KEYBINDINGS } from "../../utils/constants.js";
11
11
  import { truncate } from "../../utils/format.js";
12
12
  import { useCallback, useRef, useEffect, useState } from 'react';
13
13
  import { logger } from "../../services/logger/logger.service.js";
@@ -211,12 +211,9 @@ function SearchResults({ results, selectedIndex, isActive = true, onMixCreated,
211
211
  if (firstTrack) {
212
212
  playerDispatch({ category: 'PLAY', track: firstTrack });
213
213
  }
214
- // Navigate to player view so the user lands on the queue/player
215
- dispatch({ category: 'NAVIGATE', view: VIEW.PLAYER });
216
- mixCreatedRef.current?.(`Created mix "${playlist.name}" with ${uniqueTracks.length} tracks — playing now.`);
214
+ mixCreatedRef.current?.(`Created mix "${playlist.name}" with ${uniqueTracks.length} tracks playing now (Esc to go back).`);
217
215
  }, [
218
216
  createPlaylist,
219
- dispatch,
220
217
  isActive,
221
218
  musicService,
222
219
  playerDispatch,
@@ -273,11 +270,11 @@ function SearchResults({ results, selectedIndex, isActive = true, onMixCreated,
273
270
  }
274
271
  // Calculate responsive truncation
275
272
  const maxTitleWidth = Math.max(20, Math.floor(columns * 0.4));
276
- return (_jsxs(Box, { flexDirection: "column", gap: 1, children: [_jsxs(Text, { color: theme.colors.dim, bold: true, children: ["Results (", results.length, ")"] }), _jsx(Box, { paddingX: 1, children: _jsxs(Text, { color: theme.colors.dim, bold: true, children: ['#'.padEnd(6), " ", 'Type'.padEnd(10), " ", 'Title'.padEnd(maxTitleWidth)] }) }), results.map((result, index) => {
277
- const isSelected = index === selectedIndex;
278
- const data = result.data;
279
- const title = 'title' in data ? data.title : 'name' in data ? data.name : 'Unknown';
280
- return (_jsxs(Box, { paddingX: 1, borderStyle: isSelected ? 'double' : undefined, borderColor: isSelected ? theme.colors.primary : undefined, children: [_jsx(Text, { color: isSelected ? theme.colors.primary : theme.colors.dim, bold: isSelected, children: (isSelected ? '> ' : ' ') + (index + 1).toString().padEnd(4) }), _jsx(Text, { color: isSelected ? theme.colors.primary : theme.colors.dim, bold: isSelected, children: result.type.toUpperCase().padEnd(10) }), _jsx(Text, { color: isSelected ? theme.colors.primary : theme.colors.text, bold: isSelected, children: truncate(title, maxTitleWidth) })] }, index));
281
- })] }));
273
+ return (_jsx(Box, { flexDirection: "column", children: results.map((result, index) => {
274
+ const isSelected = index === selectedIndex;
275
+ const data = result.data;
276
+ const title = 'title' in data ? data.title : 'name' in data ? data.name : 'Unknown';
277
+ return (_jsxs(Box, { paddingX: 1, backgroundColor: isSelected ? theme.colors.secondary : undefined, children: [_jsx(Text, { color: isSelected ? theme.colors.primary : theme.colors.dim, bold: isSelected, children: (isSelected ? '> ' : ' ') + (index + 1).toString().padEnd(4) }), _jsx(Text, { color: isSelected ? theme.colors.primary : theme.colors.dim, bold: isSelected, children: result.type.toUpperCase().padEnd(10) }), _jsx(Text, { color: isSelected ? theme.colors.primary : theme.colors.text, bold: isSelected, children: truncate(title, maxTitleWidth) })] }, index));
278
+ }) }));
282
279
  }
283
280
  export default React.memo(SearchResults);
@@ -30,8 +30,10 @@ declare class DownloadService {
30
30
  private fetchAudio;
31
31
  private ensureFfmpeg;
32
32
  private convertAudio;
33
+ private buildMetadataArgs;
33
34
  private runFfmpeg;
34
35
  private recordViaYtDlp;
36
+ private downloadCoverArt;
35
37
  private recordViaMpv;
36
38
  }
37
39
  export declare function getDownloadService(): DownloadService;
@@ -76,11 +76,13 @@ class DownloadService {
76
76
  for (const track of tracks) {
77
77
  const destination = this.getDestinationPath(track, directory, format);
78
78
  const tempSource = `${destination}.source`;
79
+ const tempCover = `${destination}.cover.jpg`;
79
80
  try {
80
81
  logger.info('DownloadService', 'Starting track download', {
81
82
  videoId: track.videoId,
82
83
  title: track.title,
83
84
  });
85
+ mkdirSync(path.dirname(destination), { recursive: true });
84
86
  if (existsSync(destination)) {
85
87
  result.skipped++;
86
88
  logger.debug('DownloadService', 'Skipping existing file', {
@@ -113,7 +115,8 @@ class DownloadService {
113
115
  await this.recordViaMpv(track.videoId, tempSource);
114
116
  }
115
117
  }
116
- await this.convertAudio(tempSource, destination, format);
118
+ const hasCover = await this.downloadCoverArt(track.videoId, tempCover);
119
+ await this.convertAudio(tempSource, destination, format, track, hasCover ? tempCover : undefined);
117
120
  result.downloaded++;
118
121
  logger.info('DownloadService', 'Track download complete', {
119
122
  videoId: track.videoId,
@@ -134,6 +137,9 @@ class DownloadService {
134
137
  if (existsSync(tempSource)) {
135
138
  unlinkSync(tempSource);
136
139
  }
140
+ if (existsSync(tempCover)) {
141
+ unlinkSync(tempCover);
142
+ }
137
143
  }
138
144
  }
139
145
  return result;
@@ -155,8 +161,11 @@ class DownloadService {
155
161
  }
156
162
  getDestinationPath(track, directory, format) {
157
163
  const artist = track.artists[0]?.name ?? 'Unknown Artist';
158
- const baseName = this.sanitizeFilename(`${artist} - ${track.title}`);
159
- return path.join(directory, `${baseName}.${format}`);
164
+ const album = track.album?.name ?? 'Singles';
165
+ const artistDir = this.sanitizeFilename(artist) || 'Unknown Artist';
166
+ const albumDir = this.sanitizeFilename(album) || 'Singles';
167
+ const fileName = this.sanitizeFilename(track.title) || track.videoId;
168
+ return path.join(directory, artistDir, albumDir, `${fileName}.${format}`);
160
169
  }
161
170
  sanitizeFilename(value) {
162
171
  return value.replace(/[<>:"/\\|?*\u0000-\u001F]/g, '_').trim();
@@ -186,32 +195,52 @@ class DownloadService {
186
195
  throw new Error('ffmpeg is required for downloads. Install ffmpeg and ensure it is available in PATH.');
187
196
  }
188
197
  }
189
- async convertAudio(sourcePath, destinationPath, format) {
198
+ async convertAudio(sourcePath, destinationPath, format, track, coverPath) {
199
+ const metadataArgs = this.buildMetadataArgs(track);
190
200
  if (format === 'mp3') {
191
- await this.runFfmpeg([
192
- '-y',
193
- '-i',
194
- sourcePath,
195
- '-vn',
196
- '-codec:a',
197
- 'libmp3lame',
198
- '-q:a',
199
- '2',
200
- destinationPath,
201
- ]);
201
+ const args = ['-y', '-i', sourcePath];
202
+ if (coverPath) {
203
+ args.push('-i', coverPath, '-map', '0:a:0', '-map', '1:v:0');
204
+ }
205
+ else {
206
+ args.push('-map', '0:a:0', '-vn');
207
+ }
208
+ args.push('-codec:a', 'libmp3lame', '-q:a', '2', ...metadataArgs);
209
+ if (coverPath) {
210
+ args.push('-codec:v', 'mjpeg', '-disposition:v:0', 'attached_pic', '-metadata:s:v', 'title=Album cover', '-metadata:s:v', 'comment=Cover (front)');
211
+ }
212
+ args.push(destinationPath);
213
+ await this.runFfmpeg(args);
202
214
  return;
203
215
  }
204
- await this.runFfmpeg([
205
- '-y',
206
- '-i',
207
- sourcePath,
208
- '-vn',
209
- '-codec:a',
210
- 'aac',
211
- '-b:a',
212
- '192k',
213
- destinationPath,
214
- ]);
216
+ const args = ['-y', '-i', sourcePath];
217
+ if (coverPath) {
218
+ args.push('-i', coverPath, '-map', '0:a:0', '-map', '1:v:0');
219
+ }
220
+ else {
221
+ args.push('-map', '0:a:0', '-vn');
222
+ }
223
+ args.push('-codec:a', 'aac', '-b:a', '192k', ...metadataArgs);
224
+ if (coverPath) {
225
+ args.push('-codec:v', 'mjpeg', '-disposition:v:0', 'attached_pic');
226
+ }
227
+ args.push(destinationPath);
228
+ await this.runFfmpeg(args);
229
+ }
230
+ buildMetadataArgs(track) {
231
+ const artist = track.artists
232
+ .map(row => row.name)
233
+ .filter(Boolean)
234
+ .join(', ') || 'Unknown Artist';
235
+ const album = track.album?.name || 'Singles';
236
+ return [
237
+ '-metadata',
238
+ `title=${track.title}`,
239
+ '-metadata',
240
+ `artist=${artist}`,
241
+ '-metadata',
242
+ `album=${album}`,
243
+ ];
215
244
  }
216
245
  async runFfmpeg(args) {
217
246
  await new Promise((resolve, reject) => {
@@ -264,6 +293,28 @@ class DownloadService {
264
293
  });
265
294
  });
266
295
  }
296
+ async downloadCoverArt(videoId, outputPath) {
297
+ const candidates = [
298
+ `https://i.ytimg.com/vi/${videoId}/maxresdefault.jpg`,
299
+ `https://i.ytimg.com/vi/${videoId}/hqdefault.jpg`,
300
+ ];
301
+ for (const url of candidates) {
302
+ try {
303
+ const response = await fetch(url);
304
+ if (!response.ok)
305
+ continue;
306
+ const image = Buffer.from(await response.arrayBuffer());
307
+ if (image.length === 0)
308
+ continue;
309
+ writeFileSync(outputPath, image);
310
+ return true;
311
+ }
312
+ catch {
313
+ continue;
314
+ }
315
+ }
316
+ return false;
317
+ }
267
318
  async recordViaMpv(videoId, outputPath) {
268
319
  const watchUrl = `https://www.youtube.com/watch?v=${videoId}`;
269
320
  await new Promise((resolve, reject) => {
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@involvex/youtube-music-cli",
3
- "version": "0.0.12",
3
+ "version": "0.0.14",
4
4
  "description": "- A Commandline music player for youtube-music",
5
5
  "repository": {
6
6
  "type": "git",
package/readme.md CHANGED
@@ -25,6 +25,8 @@ A powerful Terminal User Interface (TUI) music player for YouTube Music
25
25
  - 🔌 **Plugin System** - Extend functionality with plugins
26
26
  - ⌨️ **Keyboard-Driven** - Efficient vim-style navigation
27
27
  - 🖥️ **Headless Mode** - Run without TUI for scripting
28
+ - 💾 **Downloads** - Save tracks/playlists/artists with `Shift+D`
29
+ - 🏷️ **Metadata Tagging** - Auto-tag title/artist/album with optional cover art
28
30
 
29
31
  ## Prerequisites
30
32
 
@@ -194,6 +196,12 @@ youtube-music-cli play dQw4w9WgXcQ --shuffle
194
196
  | `Enter` | Select |
195
197
  | `Esc` | Back |
196
198
 
199
+ ### Downloads
200
+
201
+ | Key | Action |
202
+ | --------- | ------------------------------------------------------- |
203
+ | `Shift+D` | Download selected song/artist/playlist or playlist view |
204
+
197
205
  ## Plugins
198
206
 
199
207
  Extend youtube-music-cli with plugins!
@@ -259,7 +267,10 @@ Config is stored in `~/.youtube-music-cli/config.json`:
259
267
  "volume": 70,
260
268
  "shuffle": false,
261
269
  "repeat": "off",
262
- "streamQuality": "high"
270
+ "streamQuality": "high",
271
+ "downloadsEnabled": false,
272
+ "downloadDirectory": "D:/Music/youtube-music-cli",
273
+ "downloadFormat": "mp3"
263
274
  }
264
275
  ```
265
276
 
@@ -271,6 +282,15 @@ Config is stored in `~/.youtube-music-cli/config.json`:
271
282
  | `medium` | 128kbps - Balanced |
272
283
  | `high` | 256kbps+ - Best quality |
273
284
 
285
+ ### Download Settings
286
+
287
+ - Enable/disable downloads in **Settings** (`,`).
288
+ - Set your download directory in **Settings → Download Folder**.
289
+ - Choose format in **Settings → Download Format** (`mp3` or `m4a`).
290
+ - Downloads are saved as:
291
+ - `<downloadDirectory>/<artist>/<album>/<title>.mp3` (or `.m4a`)
292
+ - MP3/M4A files are tagged with metadata (`title`, `artist`, `album`) and include cover art when available.
293
+
274
294
  ## Troubleshooting
275
295
 
276
296
  ### mpv not found
@@ -350,3 +370,11 @@ MIT © [Involvex](https://github.com/involvex)
350
370
  Made with ❤️ for music lovers
351
371
 
352
372
  </div>
373
+
374
+ ## Supporting
375
+
376
+ **[☕ Buymeacoffee](https://buymeacoffee.com/involvex)**
377
+
378
+ **[🪙 Paypal](https://paypal.me/involvex)**
379
+
380
+ **⌨️ [Github Sponsors](https://github.com/sponsors/involvex)**