ani-cli-npm 2.0.4 → 2.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/README.MD +3 -1
- package/bin/Anime.js +40 -31
- package/bin/download.js +1 -20
- package/bin/index.js +8 -5
- package/bin/load_config.js +3 -2
- package/package.json +1 -1
package/README.MD
CHANGED
|
@@ -36,6 +36,7 @@ npx ani-cli-npm@latest
|
|
|
36
36
|
```
|
|
37
37
|
git clone https://github.com/Bumpkin-Pi/ani-cli-npm.git
|
|
38
38
|
cd ani-cli-npm
|
|
39
|
+
npm i
|
|
39
40
|
npm run build
|
|
40
41
|
npm run start
|
|
41
42
|
```
|
|
@@ -69,4 +70,5 @@ npm run start
|
|
|
69
70
|
#### Download folder - The folder in which to download episodes.
|
|
70
71
|
|
|
71
72
|
|
|
72
|
-
|
|
73
|
+
|
|
74
|
+
<a href="https://www.buymeacoffee.com/bumpkinpi" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>
|
package/bin/Anime.js
CHANGED
|
@@ -34,7 +34,6 @@ class Anime {
|
|
|
34
34
|
anime_id:
|
|
35
35
|
*/
|
|
36
36
|
let cache_object = (0, cache_1.search_cache)(cache_folder, anime_id);
|
|
37
|
-
console.log(cache_object);
|
|
38
37
|
this.id = anime_id;
|
|
39
38
|
if (cache_object == 0) {
|
|
40
39
|
await this.get_ep_bases(this.id);
|
|
@@ -82,7 +81,9 @@ class Anime {
|
|
|
82
81
|
lines = "{" + lines.slice(lines.indexOf(",") + 1, lines.length) + "}";
|
|
83
82
|
let json = JSON.parse(lines);
|
|
84
83
|
for (const value of Object.entries(json)) {
|
|
85
|
-
|
|
84
|
+
if (typeof value[1] == "string") {
|
|
85
|
+
this.episode_list.push(value[1]);
|
|
86
|
+
}
|
|
86
87
|
}
|
|
87
88
|
}
|
|
88
89
|
async play_head(episode, config, config_dir) {
|
|
@@ -153,7 +154,7 @@ class Anime {
|
|
|
153
154
|
break;
|
|
154
155
|
}
|
|
155
156
|
}
|
|
156
|
-
else if (episode >= this.episode_list.length -
|
|
157
|
+
else if (episode >= this.episode_list.length - 2) {
|
|
157
158
|
switch (await (0, input_1.selection)([
|
|
158
159
|
"Previous",
|
|
159
160
|
"Quit"
|
|
@@ -226,7 +227,7 @@ class Anime {
|
|
|
226
227
|
break;
|
|
227
228
|
}
|
|
228
229
|
}
|
|
229
|
-
else if (episode >= this.episode_list.length -
|
|
230
|
+
else if (episode >= this.episode_list.length - 2) {
|
|
230
231
|
switch (await (0, input_1.selection)([
|
|
231
232
|
"Previous",
|
|
232
233
|
"Quit"
|
|
@@ -255,38 +256,46 @@ class Anime {
|
|
|
255
256
|
}
|
|
256
257
|
}
|
|
257
258
|
}
|
|
258
|
-
async download(episode, download_folder) {
|
|
259
|
+
async download(episode, download_folder, final_ep) {
|
|
259
260
|
/*
|
|
260
261
|
## Downloads an episode (counting from 0) to download_folder, with progress bar.
|
|
261
262
|
*/
|
|
262
|
-
|
|
263
|
-
let ep_link = await this.get_episode_link(episode);
|
|
264
|
-
let file_name = `${this.id}-${episode + 1}.mp4`;
|
|
265
|
-
if (ep_link.includes(".m3u8"))
|
|
266
|
-
console.log(chalk.red("Warning: Animixplay will download an m3u8 file. This will require some extra steps to play. It is advised to use a 3rd party website or tool to download these from the link."));
|
|
267
|
-
// @ts-ignore
|
|
268
|
-
let option = {
|
|
269
|
-
filename: ep_link.includes("m3u8") ? file_name.replace("mp4", "m3u8") : file_name,
|
|
270
|
-
dir: download_folder,
|
|
271
|
-
// @ts-ignore
|
|
272
|
-
onDone: (info) => {
|
|
273
|
-
// @ts-ignore
|
|
274
|
-
console.log(chalk.green(`\n -- Download finished -- \nLocation: ${info.path}. Size: ${Math.round(info.size / 100000) * 10} Bytes\n`) + ">");
|
|
275
|
-
return 0;
|
|
276
|
-
},
|
|
263
|
+
try {
|
|
277
264
|
// @ts-ignore
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
265
|
+
let ep_link = await this.get_episode_link(episode);
|
|
266
|
+
let file_name = `${this.id}-${episode + 1}.mp4`;
|
|
267
|
+
if (ep_link.includes(".m3u8"))
|
|
268
|
+
console.log(chalk.red("Warning: Animixplay will download an m3u8 file. This will require some extra steps to play. It is advised to use a 3rd party website or tool to download these from the link."));
|
|
281
269
|
// @ts-ignore
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
270
|
+
let option = {
|
|
271
|
+
filename: (ep_link.includes("m3u8") ? file_name.replace("mp4", "m3u8") : file_name),
|
|
272
|
+
dir: download_folder,
|
|
273
|
+
onDone: (final_ep > episode) ? ((info) => {
|
|
274
|
+
// @ts-ignore
|
|
275
|
+
console.log(chalk.green(`\n -- 1Download finished -- \nLocation: ${info.path}. Size: ${Math.round(info.size / 100000) * 10} Bytes\n`));
|
|
276
|
+
this.download(episode + 1, download_folder, final_ep);
|
|
277
|
+
}) : ((info) => {
|
|
278
|
+
// @ts-ignore
|
|
279
|
+
console.log(chalk.green(`\n -- 2Download finished -- \n${info.path}. Size: ${Math.round(info.size / 100000) * 10} Bytes\n`));
|
|
280
|
+
}),
|
|
281
|
+
// @ts-ignore
|
|
282
|
+
onError: (err) => {
|
|
283
|
+
console.log(chalk.red('error', err));
|
|
284
|
+
this.download(episode, download_folder, final_ep);
|
|
285
|
+
},
|
|
286
|
+
// @ts-ignore
|
|
287
|
+
onProgress: (curr, total) => {
|
|
288
|
+
process.stdout.clearLine(0);
|
|
289
|
+
process.stdout.cursorTo(0);
|
|
290
|
+
process.stdout.write("\x1b[32m -- " + (curr / total * 100).toFixed(2) + "% " + "#".repeat(Math.ceil((curr / total) * ((process.stdout.columns - 20) / 1.5))) + "~".repeat(Math.ceil(((process.stdout.columns - 20) / 1.5) - (curr / total) * ((process.stdout.columns - 20) / 1.5))) + " -- \x1b[0m");
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
//console.log((`${option.dir}/${option.filename}`))
|
|
294
|
+
return await dl(ep_link, option);
|
|
295
|
+
}
|
|
296
|
+
catch {
|
|
297
|
+
this.download(episode, download_folder, final_ep);
|
|
298
|
+
}
|
|
290
299
|
}
|
|
291
300
|
}
|
|
292
301
|
exports.Anime = Anime;
|
package/bin/download.js
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.download = void 0;
|
|
7
4
|
const search_anime_1 = require("./search_anime");
|
|
8
5
|
const Anime_1 = require("./Anime");
|
|
9
6
|
const input_1 = require("./input");
|
|
10
|
-
const libs_1 = require("./libs");
|
|
11
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
12
7
|
async function download(cache_folder, config) {
|
|
13
8
|
try {
|
|
14
9
|
console.clear();
|
|
@@ -31,21 +26,7 @@ async function download(cache_folder, config) {
|
|
|
31
26
|
console.log(`Select end episode [${start_ep_number}-${download.episode_list.length}]`);
|
|
32
27
|
end_ep_number = await (0, input_1.number_input)(download.episode_list.length, start_ep_number) - 1;
|
|
33
28
|
}
|
|
34
|
-
|
|
35
|
-
do {
|
|
36
|
-
for (let x in to_do) {
|
|
37
|
-
try {
|
|
38
|
-
await download.download(to_do[x] - 1, config.download_folder);
|
|
39
|
-
to_do.splice(Number(x), 1);
|
|
40
|
-
}
|
|
41
|
-
catch {
|
|
42
|
-
console.log(chalk_1.default.red("Failed to download episode " + to_do[x]));
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if (to_do[0] !== undefined) { //TODO fix buggy downloads
|
|
46
|
-
console.log(chalk_1.default.red("Failed to download episodes: " + to_do) + "\nRetrying...");
|
|
47
|
-
}
|
|
48
|
-
} while (to_do[0] !== undefined);
|
|
29
|
+
await download.download(start_ep_number - 1, config.download_folder, end_ep_number);
|
|
49
30
|
}
|
|
50
31
|
catch {
|
|
51
32
|
return 1;
|
package/bin/index.js
CHANGED
|
@@ -18,9 +18,10 @@ const download_1 = require("./download");
|
|
|
18
18
|
const fs_1 = __importDefault(require("fs"));
|
|
19
19
|
const app_data_folder = (0, appdata_path_1.default)();
|
|
20
20
|
const cache_folder = app_data_folder + "/ani-cli-npm";
|
|
21
|
+
(0, load_config_1.make_config_dir)(cache_folder, true);
|
|
21
22
|
console.clear();
|
|
22
23
|
async function main() {
|
|
23
|
-
let config = (0, load_config_1.load_config)(
|
|
24
|
+
let config = (0, load_config_1.load_config)(cache_folder);
|
|
24
25
|
console.log(chalk.magenta("Ani-cli-npm!\n"));
|
|
25
26
|
if (config.most_recent.anime_id !== "") {
|
|
26
27
|
console.log(chalk.grey(`Most recently played: ${config.most_recent.anime_id} episode ${config.most_recent.episode_number + 1}\n`));
|
|
@@ -48,10 +49,12 @@ async function main() {
|
|
|
48
49
|
}
|
|
49
50
|
else {
|
|
50
51
|
console.log(`Select episode [1-${anime.episode_list.length}]`);
|
|
51
|
-
episode_number = await (0, input_1.number_input)(anime.episode_list.length)
|
|
52
|
+
episode_number = await (0, input_1.number_input)(anime.episode_list.length);
|
|
53
|
+
}
|
|
54
|
+
await anime.play_head(episode_number - 1, config, cache_folder);
|
|
55
|
+
if (anime.player != 1 && anime.player != 0) {
|
|
56
|
+
await anime.player.quit();
|
|
52
57
|
}
|
|
53
|
-
await anime.play_head(episode_number, config, cache_folder);
|
|
54
|
-
await anime.player.quit();
|
|
55
58
|
await main();
|
|
56
59
|
break;
|
|
57
60
|
case 1: // Continue
|
|
@@ -74,7 +77,6 @@ async function main() {
|
|
|
74
77
|
if (code == 1) {
|
|
75
78
|
console.log(chalk.red("Error downloading episodes"));
|
|
76
79
|
}
|
|
77
|
-
await main();
|
|
78
80
|
break;
|
|
79
81
|
case 3: // Options
|
|
80
82
|
let temp = structuredClone(config);
|
|
@@ -107,6 +109,7 @@ async function main() {
|
|
|
107
109
|
case 4: // Quit
|
|
108
110
|
console.log("Exit");
|
|
109
111
|
}
|
|
112
|
+
return 0;
|
|
110
113
|
// await search()
|
|
111
114
|
}
|
|
112
115
|
main();
|
package/bin/load_config.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.write_config = exports.load_config = void 0;
|
|
26
|
+
exports.make_config_dir = exports.write_config = exports.load_config = void 0;
|
|
27
27
|
const fs = __importStar(require("fs"));
|
|
28
28
|
function make_config_dir(cache_dir, debug) {
|
|
29
29
|
try {
|
|
@@ -36,9 +36,10 @@ function make_config_dir(cache_dir, debug) {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
+
exports.make_config_dir = make_config_dir;
|
|
39
40
|
function write_config(cache_dir, config) {
|
|
40
41
|
try {
|
|
41
|
-
make_config_dir(cache_dir, config.debug_mode)
|
|
42
|
+
//make_config_dir(cache_dir, config.debug_mode)
|
|
42
43
|
fs.writeFileSync(cache_dir + "/config.conf", JSON.stringify(config));
|
|
43
44
|
}
|
|
44
45
|
catch {
|