@lunarity/nebula-fetch-cli 0.0.3 → 0.1.0
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 +21 -0
- package/README.md +44 -2
- package/dist/index.cjs +64251 -0
- package/package.json +31 -14
- package/bun.lockb +0 -0
- package/commands/youtube.ts +0 -51
- package/dist/index.js +0 -151755
- package/index.ts +0 -57
- package/tsconfig.json +0 -32
- package/utils/validators.ts +0 -45
package/package.json
CHANGED
|
@@ -1,39 +1,56 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunarity/nebula-fetch-cli",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"module": "index.ts",
|
|
3
|
+
"version": "0.1.0",
|
|
5
4
|
"description": "CLI tool for downloading media from different platforms",
|
|
6
5
|
"type": "module",
|
|
7
|
-
"main": "dist/index.
|
|
6
|
+
"main": "dist/index.cjs",
|
|
8
7
|
"devDependencies": {
|
|
9
|
-
"@types/
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
"@types/node": "^22.0.0",
|
|
9
|
+
"@types/turndown": "^5.0.6",
|
|
10
|
+
"tsup": "^8.0.0",
|
|
11
|
+
"tsx": "^4.0.0",
|
|
12
12
|
"typescript": "^5.0.0"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@ybd-project/ytdl-core": "latest",
|
|
16
15
|
"chalk": "^5.3.0",
|
|
17
|
-
"
|
|
16
|
+
"cheerio": "^1.2.0",
|
|
17
|
+
"commander": "^12.1.0",
|
|
18
|
+
|
|
19
|
+
"turndown": "^7.2.2",
|
|
20
|
+
"youtube-dl-exec": "^3.0.30"
|
|
18
21
|
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
19
25
|
"bin": {
|
|
20
|
-
"nebula-fetch": "./dist/index.
|
|
26
|
+
"nebula-fetch": "./dist/index.cjs"
|
|
21
27
|
},
|
|
22
28
|
"scripts": {
|
|
23
|
-
"build": "
|
|
24
|
-
"dev": "
|
|
25
|
-
"
|
|
29
|
+
"build": "tsup && chmod +x ./dist/index.cjs",
|
|
30
|
+
"dev": "tsx index.ts",
|
|
31
|
+
"prepublishOnly": "pnpm run build"
|
|
32
|
+
},
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=18"
|
|
26
35
|
},
|
|
27
36
|
"keywords": [
|
|
28
37
|
"cli",
|
|
29
38
|
"media",
|
|
30
39
|
"download",
|
|
31
|
-
"youtube"
|
|
40
|
+
"youtube",
|
|
41
|
+
"scrape",
|
|
42
|
+
"yt-dlp"
|
|
32
43
|
],
|
|
33
44
|
"author": "Krzysztof Oszczapiński",
|
|
34
45
|
"license": "MIT",
|
|
35
46
|
"repository": {
|
|
36
47
|
"type": "git",
|
|
37
48
|
"url": "git+https://github.com/LUNARITYai/nebula-fetch-cli.git"
|
|
49
|
+
},
|
|
50
|
+
"pnpm": {
|
|
51
|
+
"onlyBuiltDependencies": [
|
|
52
|
+
"esbuild",
|
|
53
|
+
"youtube-dl-exec"
|
|
54
|
+
]
|
|
38
55
|
}
|
|
39
|
-
}
|
|
56
|
+
}
|
package/bun.lockb
DELETED
|
Binary file
|
package/commands/youtube.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
|
|
4
|
-
import { YtdlCore, toPipeableStream } from "@ybd-project/ytdl-core";
|
|
5
|
-
import chalk from "chalk";
|
|
6
|
-
|
|
7
|
-
interface DownloadOptions {
|
|
8
|
-
url: string;
|
|
9
|
-
audioOnly?: boolean;
|
|
10
|
-
verbose?: boolean;
|
|
11
|
-
outputPath?: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export async function downloadYoutube(options: DownloadOptions): Promise<void> {
|
|
15
|
-
const { url, audioOnly = false, verbose = false, outputPath } = options;
|
|
16
|
-
|
|
17
|
-
try {
|
|
18
|
-
console.log(chalk.cyan("🔍 Fetching video information..."));
|
|
19
|
-
const ytdl = new YtdlCore({});
|
|
20
|
-
let videoTitle = "";
|
|
21
|
-
|
|
22
|
-
await ytdl.getBasicInfo(url).then((info) => {
|
|
23
|
-
console.log(chalk.cyan(`🎬 Video title: ${info.videoDetails.title}`));
|
|
24
|
-
console.log(
|
|
25
|
-
chalk.cyan(
|
|
26
|
-
`🎬 Video author: ${info.videoDetails.author?.name || "Unknown"}`
|
|
27
|
-
)
|
|
28
|
-
);
|
|
29
|
-
if (verbose) {
|
|
30
|
-
console.log(JSON.stringify(info.videoDetails, null, 2));
|
|
31
|
-
}
|
|
32
|
-
videoTitle = info.videoDetails.title.replace(/[^\w\s]/gi, "_");
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
const stream = await ytdl.download(url, {
|
|
36
|
-
filter: audioOnly ? "audioonly" : "videoandaudio",
|
|
37
|
-
quality: "highest",
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const outputFilePath =
|
|
41
|
-
outputPath ||
|
|
42
|
-
path.join(process.cwd(), `${videoTitle}.${audioOnly ? "mp3" : "mp4"}`);
|
|
43
|
-
toPipeableStream(stream).pipe(fs.createWriteStream(outputFilePath));
|
|
44
|
-
|
|
45
|
-
console.log(chalk.green.bold(`✅ Download finished: ${outputFilePath}`));
|
|
46
|
-
} catch (error) {
|
|
47
|
-
if (error instanceof Error) {
|
|
48
|
-
console.error(chalk.red.bold("❌ Error:", error.message));
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|