npmytd 1.0.4 → 1.0.6
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/package.json +1 -1
- package/src/cli.js +19 -0
- package/src/downloader.js +1 -1
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -4,8 +4,27 @@ import ytdl from 'ytdl-core';
|
|
|
4
4
|
import chalk from 'chalk';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import { sanitizeFilename } from './utils.js';
|
|
7
|
+
import fs from 'fs/promises'; // Added import
|
|
7
8
|
|
|
8
9
|
async function main() {
|
|
10
|
+
let packageVersion;
|
|
11
|
+
try {
|
|
12
|
+
const packageJsonPath = path.resolve('./package.json');
|
|
13
|
+
const packageJsonContent = await fs.readFile(packageJsonPath, 'utf8');
|
|
14
|
+
const packageData = JSON.parse(packageJsonContent);
|
|
15
|
+
packageVersion = packageData.version;
|
|
16
|
+
} catch (error) {
|
|
17
|
+
console.error(chalk.red('Error reading package.json:', error.message));
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Check for --version or -v arguments
|
|
22
|
+
const args = process.argv.slice(2); // Get arguments after 'node cli.js'
|
|
23
|
+
if (args.includes('--version') || args.includes('-v')) {
|
|
24
|
+
console.log(packageVersion);
|
|
25
|
+
process.exit(0);
|
|
26
|
+
}
|
|
27
|
+
|
|
9
28
|
console.log(chalk.bold.hex('#FF0000')(`
|
|
10
29
|
Welcome to NPMYTD - YouTube Downloader CLI!`));
|
|
11
30
|
|
package/src/downloader.js
CHANGED
|
@@ -138,7 +138,7 @@ Download of audio stream completed. Starting conversion to MP3...`));
|
|
|
138
138
|
if (err) {
|
|
139
139
|
console.error(chalk.red(`ffmpeg is not installed or not found in your system's PATH.`));
|
|
140
140
|
console.error(chalk.red('Please install ffmpeg to convert to MP3.'));
|
|
141
|
-
console.error(chalk.red(
|
|
141
|
+
console.error(chalk.red(`You can download it from https://ffmpeg.org/download.html and ensure it's accessible in your PATH.`));
|
|
142
142
|
reject(new Error('ffmpeg not found.'));
|
|
143
143
|
return;
|
|
144
144
|
}
|