ani-cli-npm 2.0.4 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
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
- ## Happy watching :)
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);
@@ -255,38 +254,46 @@ class Anime {
255
254
  }
256
255
  }
257
256
  }
258
- async download(episode, download_folder) {
257
+ async download(episode, download_folder, final_ep) {
259
258
  /*
260
259
  ## Downloads an episode (counting from 0) to download_folder, with progress bar.
261
260
  */
262
- // @ts-ignore
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,
261
+ try {
271
262
  // @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
- },
277
- // @ts-ignore
278
- onError: (err) => {
279
- console.log(chalk.red('error', err));
280
- },
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."));
281
267
  // @ts-ignore
282
- onProgress: (curr, total) => {
283
- process.stdout.clearLine(0);
284
- process.stdout.cursorTo(0);
285
- 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");
286
- }
287
- };
288
- //console.log((`${option.dir}/${option.filename}`))
289
- return await dl(ep_link, option);
268
+ let option = {
269
+ filename: (ep_link.includes("m3u8") ? file_name.replace("mp4", "m3u8") : file_name),
270
+ dir: download_folder,
271
+ onDone: (final_ep > episode) ? ((info) => {
272
+ // @ts-ignore
273
+ console.log(chalk.green(`\n -- 1Download finished -- \nLocation: ${info.path}. Size: ${Math.round(info.size / 100000) * 10} Bytes\n`));
274
+ this.download(episode + 1, download_folder, final_ep);
275
+ }) : ((info) => {
276
+ // @ts-ignore
277
+ console.log(chalk.green(`\n -- 2Download finished -- \n${info.path}. Size: ${Math.round(info.size / 100000) * 10} Bytes\n`));
278
+ }),
279
+ // @ts-ignore
280
+ onError: (err) => {
281
+ console.log(chalk.red('error', err));
282
+ this.download(episode, download_folder, final_ep);
283
+ },
284
+ // @ts-ignore
285
+ onProgress: (curr, total) => {
286
+ process.stdout.clearLine(0);
287
+ process.stdout.cursorTo(0);
288
+ 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");
289
+ }
290
+ };
291
+ //console.log((`${option.dir}/${option.filename}`))
292
+ return await dl(ep_link, option);
293
+ }
294
+ catch {
295
+ this.download(episode, download_folder, final_ep);
296
+ }
290
297
  }
291
298
  }
292
299
  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
- let to_do = (0, libs_1.range)(start_ep_number, end_ep_number + 1);
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)(app_data_folder);
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`));
@@ -74,7 +75,6 @@ async function main() {
74
75
  if (code == 1) {
75
76
  console.log(chalk.red("Error downloading episodes"));
76
77
  }
77
- await main();
78
78
  break;
79
79
  case 3: // Options
80
80
  let temp = structuredClone(config);
@@ -107,6 +107,7 @@ async function main() {
107
107
  case 4: // Quit
108
108
  console.log("Exit");
109
109
  }
110
+ return 0;
110
111
  // await search()
111
112
  }
112
113
  main();
@@ -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 {
@@ -0,0 +1,9 @@
1
+ #EXTM3U
2
+ #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=120532,RESOLUTION=640x360,NAME="360p"
3
+ ep.1.1657688701.360.m3u8
4
+ #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=195379,RESOLUTION=854x480,NAME="480p"
5
+ ep.1.1657688701.480.m3u8
6
+ #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=418741,RESOLUTION=1280x720,NAME="720p"
7
+ ep.1.1657688701.720.m3u8
8
+ #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=903363,RESOLUTION=1920x1080,NAME="1080p"
9
+ ep.1.1657688701.1080.m3u8
@@ -0,0 +1,9 @@
1
+ #EXTM3U
2
+ #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=112046,RESOLUTION=640x360,NAME="360p"
3
+ ep.2.1657689264.360.m3u8
4
+ #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=180246,RESOLUTION=854x480,NAME="480p"
5
+ ep.2.1657689264.480.m3u8
6
+ #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=382280,RESOLUTION=1280x720,NAME="720p"
7
+ ep.2.1657689264.720.m3u8
8
+ #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=829748,RESOLUTION=1920x1080,NAME="1080p"
9
+ ep.2.1657689264.1080.m3u8
@@ -0,0 +1,9 @@
1
+ #EXTM3U
2
+ #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=113161,RESOLUTION=640x360,NAME="360p"
3
+ ep.3.1657689714.360.m3u8
4
+ #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=177223,RESOLUTION=854x480,NAME="480p"
5
+ ep.3.1657689714.480.m3u8
6
+ #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=372889,RESOLUTION=1280x720,NAME="720p"
7
+ ep.3.1657689714.720.m3u8
8
+ #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=798185,RESOLUTION=1920x1080,NAME="1080p"
9
+ ep.3.1657689714.1080.m3u8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ani-cli-npm",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "ani-cli tool rewritten as npm package",
5
5
  "main": "bin/index.js",
6
6
  "scripts": {