ani-cli-npm 2.0.6 → 2.0.8

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/bin/Anime.js CHANGED
@@ -22,6 +22,7 @@ class Anime {
22
22
  */
23
23
  id = "";
24
24
  episode_list = [];
25
+ most_recent = 0;
25
26
  player = 0;
26
27
  async init(anime_id, cache_folder) {
27
28
  /*
@@ -42,11 +43,15 @@ class Anime {
42
43
  else {
43
44
  try {
44
45
  this.episode_list = cache_object.episode_list;
46
+ if (cache_object.most_recent != undefined) {
47
+ this.most_recent = cache_object.most_recent;
48
+ }
45
49
  }
46
50
  catch {
47
51
  await this.get_ep_bases(this.id);
48
52
  }
49
53
  }
54
+ (0, cache_1.new_cache)(cache_folder, this);
50
55
  return 0;
51
56
  }
52
57
  async get_episode_link(episode, player = "VLC") {
@@ -141,6 +146,8 @@ class Anime {
141
146
  }
142
147
  config.most_recent.anime_id = this.id;
143
148
  config.most_recent.episode_number = episode;
149
+ this.most_recent = episode;
150
+ (0, cache_1.new_cache)(config_dir, this);
144
151
  (0, load_config_1.write_config)(config_dir, config);
145
152
  if (episode <= 0) {
146
153
  switch (await (0, input_1.selection)([
@@ -215,6 +222,8 @@ class Anime {
215
222
  config.most_recent.anime_id = this.id;
216
223
  config.most_recent.episode_number = episode;
217
224
  (0, load_config_1.write_config)(config_dir, config);
225
+ this.most_recent = episode;
226
+ (0, cache_1.new_cache)(config_dir, this);
218
227
  if (episode <= 0) {
219
228
  switch (await (0, input_1.selection)([
220
229
  "Next",
package/bin/index.js CHANGED
@@ -15,7 +15,6 @@ const load_config_1 = require("./load_config");
15
15
  const input_1 = require("./input");
16
16
  const change_config_1 = require("./change_config");
17
17
  const download_1 = require("./download");
18
- const fs_1 = __importDefault(require("fs"));
19
18
  const app_data_folder = (0, appdata_path_1.default)();
20
19
  const cache_folder = app_data_folder + "/ani-cli-npm";
21
20
  (0, load_config_1.make_config_dir)(cache_folder, true);
@@ -48,8 +47,8 @@ async function main() {
48
47
  episode_number = 0;
49
48
  }
50
49
  else {
51
- console.log(`Select episode [1-${anime.episode_list.length}]`);
52
- episode_number = await (0, input_1.number_input)(anime.episode_list.length);
50
+ console.log(`Select episode [1-${anime.episode_list.length}] ${(anime.most_recent != 0) ? `Or C to continue from ep${anime.most_recent + 1}` : ""}`);
51
+ episode_number = await (0, input_1.number_input)(anime.episode_list.length, 1, (anime.most_recent != 0) ? ["c"] : [], (anime.most_recent != 0) ? [anime.most_recent + 1] : []);
53
52
  }
54
53
  await anime.play_head(episode_number - 1, config, cache_folder);
55
54
  if (anime.player != 1 && anime.player != 0) {
@@ -88,7 +87,13 @@ async function main() {
88
87
  config = temp;
89
88
  //proxyAgent = new HttpsProxyAgent(config.proxy);
90
89
  console.clear();
91
- console.log(chalk.yellow("Config changed."));
90
+ try {
91
+ (0, load_config_1.write_config)(cache_folder, config);
92
+ console.log(chalk.yellow("Config changed."));
93
+ }
94
+ catch {
95
+ console.log(chalk.red("Error writing to .conf file."));
96
+ }
92
97
  break;
93
98
  }
94
99
  else if (exit_code === 2) {
@@ -98,12 +103,6 @@ async function main() {
98
103
  break;
99
104
  }
100
105
  }
101
- try {
102
- fs_1.default.writeFileSync(cache_folder + "/config.conf", JSON.stringify(config));
103
- }
104
- catch {
105
- console.log(chalk.red("Error writing to .conf file."));
106
- }
107
106
  await main();
108
107
  break;
109
108
  case 4: // Quit
package/bin/input.js CHANGED
@@ -30,12 +30,12 @@ async function selection(options, extra_options = [], color1 = ((thing) => { ret
30
30
  if (color) {
31
31
  console.log(color1((parseInt(x) + 1).toString() +
32
32
  ((extra_options[x] == undefined) ? "" : "/" + extra_options[x]) +
33
- ") " + options[x]));
33
+ ") " + options[x].replaceAll("-", " ")));
34
34
  }
35
35
  else {
36
36
  console.log(color2((parseInt(x) + 1).toString() +
37
37
  ((extra_options[x] == undefined) ? "" : "/" + extra_options[x]) +
38
- ") " + options[x]));
38
+ ") " + options[x].replaceAll("-", " ")));
39
39
  }
40
40
  color = !color;
41
41
  }
@@ -59,12 +59,17 @@ async function input() {
59
59
  return await _prompt(">");
60
60
  }
61
61
  exports.input = input;
62
- async function number_input(max, min = 1) {
62
+ async function number_input(max, min = 1, extra_options = [], extra_option_values = []) {
63
63
  let selector;
64
64
  let selection;
65
65
  do {
66
66
  selector = await _prompt(">");
67
- selection = parseInt(selector);
67
+ if (extra_options.includes(selector.toLowerCase())) {
68
+ selection = extra_option_values[extra_options.indexOf(selector)];
69
+ }
70
+ else {
71
+ selection = parseInt(selector);
72
+ }
68
73
  if (selector == "") {
69
74
  selection = min;
70
75
  }
@@ -40,7 +40,7 @@ exports.make_config_dir = make_config_dir;
40
40
  function write_config(cache_dir, config) {
41
41
  try {
42
42
  //make_config_dir(cache_dir, config.debug_mode)
43
- fs.writeFileSync(cache_dir + "/config.conf", JSON.stringify(config));
43
+ fs.writeFileSync(cache_dir + "/config.conf", JSON.stringify(config), "utf-8");
44
44
  }
45
45
  catch {
46
46
  console.log(("Failed to write to config file."));
@@ -59,9 +59,9 @@ function load_config(cache_dir) {
59
59
  download_folder: ".",
60
60
  debug_mode: false
61
61
  };
62
- if (fs.existsSync(cache_dir + "/ani-cli-npm/config.conf")) {
62
+ if (fs.existsSync(cache_dir + "/config.conf")) {
63
63
  // @ts-ignore
64
- let tmp = JSON.parse(fs.readFileSync(cache_dir + "/ani-cli-npm/config.conf"), "utf8");
64
+ let tmp = JSON.parse(fs.readFileSync(cache_dir + "/config.conf"), "utf8");
65
65
  // @ts-ignore
66
66
  if (tmp.player !== undefined)
67
67
  config.player = tmp.player;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ani-cli-npm",
3
- "version": "2.0.6",
3
+ "version": "2.0.8",
4
4
  "description": "ani-cli tool rewritten as npm package",
5
5
  "main": "bin/index.js",
6
6
  "scripts": {