ani-cli-npm 2.0.6 → 2.0.7
Sign up to get free protection for your applications and to get access to all the features.
- package/bin/Anime.js +9 -0
- package/bin/index.js +2 -2
- package/bin/input.js +9 -4
- package/package.json +1 -1
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
@@ -48,8 +48,8 @@ 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);
|
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
53
|
}
|
54
54
|
await anime.play_head(episode_number - 1, config, cache_folder);
|
55
55
|
if (anime.player != 1 && anime.player != 0) {
|
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
|
-
|
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
|
}
|