ani-cli-npm 2.0.5 → 2.0.7

Sign up to get free protection for your applications and to get access to all the features.
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") {
@@ -81,7 +86,9 @@ class Anime {
81
86
  lines = "{" + lines.slice(lines.indexOf(",") + 1, lines.length) + "}";
82
87
  let json = JSON.parse(lines);
83
88
  for (const value of Object.entries(json)) {
84
- this.episode_list.push(value[1]);
89
+ if (typeof value[1] == "string") {
90
+ this.episode_list.push(value[1]);
91
+ }
85
92
  }
86
93
  }
87
94
  async play_head(episode, config, config_dir) {
@@ -139,6 +146,8 @@ class Anime {
139
146
  }
140
147
  config.most_recent.anime_id = this.id;
141
148
  config.most_recent.episode_number = episode;
149
+ this.most_recent = episode;
150
+ (0, cache_1.new_cache)(config_dir, this);
142
151
  (0, load_config_1.write_config)(config_dir, config);
143
152
  if (episode <= 0) {
144
153
  switch (await (0, input_1.selection)([
@@ -152,7 +161,7 @@ class Anime {
152
161
  break;
153
162
  }
154
163
  }
155
- else if (episode >= this.episode_list.length - 1) {
164
+ else if (episode >= this.episode_list.length - 2) {
156
165
  switch (await (0, input_1.selection)([
157
166
  "Previous",
158
167
  "Quit"
@@ -213,6 +222,8 @@ class Anime {
213
222
  config.most_recent.anime_id = this.id;
214
223
  config.most_recent.episode_number = episode;
215
224
  (0, load_config_1.write_config)(config_dir, config);
225
+ this.most_recent = episode;
226
+ (0, cache_1.new_cache)(config_dir, this);
216
227
  if (episode <= 0) {
217
228
  switch (await (0, input_1.selection)([
218
229
  "Next",
@@ -225,7 +236,7 @@ class Anime {
225
236
  break;
226
237
  }
227
238
  }
228
- else if (episode >= this.episode_list.length - 1) {
239
+ else if (episode >= this.episode_list.length - 2) {
229
240
  switch (await (0, input_1.selection)([
230
241
  "Previous",
231
242
  "Quit"
package/bin/index.js CHANGED
@@ -48,11 +48,13 @@ async function main() {
48
48
  episode_number = 0;
49
49
  }
50
50
  else {
51
- console.log(`Select episode [1-${anime.episode_list.length}]`);
52
- episode_number = await (0, input_1.number_input)(anime.episode_list.length) - 1;
51
+ console.log(`Select episode [1-${anime.episode_list.length}] ${(anime.most_recent != 0) ? `Or C to continue from ep${anime.most_recent + 1}` : ""}`);
52
+ 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
+ }
54
+ await anime.play_head(episode_number - 1, config, cache_folder);
55
+ if (anime.player != 1 && anime.player != 0) {
56
+ await anime.player.quit();
53
57
  }
54
- await anime.play_head(episode_number, config, cache_folder);
55
- await anime.player.quit();
56
58
  await main();
57
59
  break;
58
60
  case 1: // Continue
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ani-cli-npm",
3
- "version": "2.0.5",
3
+ "version": "2.0.7",
4
4
  "description": "ani-cli tool rewritten as npm package",
5
5
  "main": "bin/index.js",
6
6
  "scripts": {
package/naruto-dub-1.m3u8 DELETED
@@ -1,9 +0,0 @@
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
package/naruto-dub-2.m3u8 DELETED
@@ -1,9 +0,0 @@
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
package/naruto-dub-3.m3u8 DELETED
@@ -1,9 +0,0 @@
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