ani-cli-npm 2.0.8 → 2.0.9

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 CHANGED
@@ -3,6 +3,8 @@
3
3
  ### An Anime client, writen in nodeJS, to access any* anime without the need for ad filled websites! Just install, search for the anime of your choice, and watch in the video player of your choice.
4
4
  ### Typescript rewrite of the [ani-cli](https://github.com/pystardust/ani-cli) package for linux.
5
5
 
6
+ ![image](https://user-images.githubusercontent.com/74017165/205444723-20520eb1-55dd-4103-811b-07e2cf6c466d.png)
7
+
6
8
 
7
9
  ## Instalation:
8
10
  ### Windows:
@@ -23,7 +25,6 @@ pkg install nodejs
23
25
  ```
24
26
  npx ani-cli-npm@latest
25
27
  ```
26
- ##### Note: At preset (1.0.6), you will need to change the player to browser, and will have to do any downloads through your browser of choice.
27
28
 
28
29
  ### Linux:
29
30
  #### - Install [nodejs](https://nodejs.org/en/download/ with your distrabutions package manager.
@@ -69,6 +70,8 @@ npm run start
69
70
 
70
71
  #### Download folder - The folder in which to download episodes.
71
72
 
73
+ ![image](https://user-images.githubusercontent.com/74017165/205444327-d67c5099-beaf-4895-9c74-c24b79a95e07.png)
74
+
72
75
 
73
76
 
74
77
  <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
@@ -38,7 +38,11 @@ class Anime {
38
38
  this.id = anime_id;
39
39
  if (cache_object == 0) {
40
40
  await this.get_ep_bases(this.id);
41
- (0, cache_1.new_cache)(cache_folder, this);
41
+ (0, cache_1.new_cache)(cache_folder, {
42
+ id: this.id,
43
+ episode_list: this.episode_list,
44
+ most_recent: this.most_recent
45
+ });
42
46
  }
43
47
  else {
44
48
  try {
@@ -51,7 +55,11 @@ class Anime {
51
55
  await this.get_ep_bases(this.id);
52
56
  }
53
57
  }
54
- (0, cache_1.new_cache)(cache_folder, this);
58
+ (0, cache_1.new_cache)(cache_folder, {
59
+ id: this.id,
60
+ episode_list: this.episode_list,
61
+ most_recent: this.most_recent
62
+ });
55
63
  return 0;
56
64
  }
57
65
  async get_episode_link(episode, player = "VLC") {
@@ -144,126 +152,122 @@ class Anime {
144
152
  console.log(await this.get_episode_link(episode, config.player));
145
153
  break;
146
154
  }
147
- config.most_recent.anime_id = this.id;
148
- config.most_recent.episode_number = episode;
149
- this.most_recent = episode;
150
- (0, cache_1.new_cache)(config_dir, this);
151
- (0, load_config_1.write_config)(config_dir, config);
152
- if (episode <= 0) {
153
- switch (await (0, input_1.selection)([
154
- "Next",
155
- "Quit"
156
- ], ["n", "q"])) {
157
- case 0:
158
- await this.play(episode + 1, config, config_dir);
159
- break;
160
- case 1:
161
- break;
162
- }
163
- }
164
- else if (episode >= this.episode_list.length - 2) {
165
- switch (await (0, input_1.selection)([
166
- "Previous",
167
- "Quit"
168
- ], ["p", "q"])) {
169
- case 0:
170
- await this.play(episode - 1, config, config_dir);
171
- break;
172
- case 1:
173
- break;
174
- }
175
- }
176
- else {
177
- switch (await (0, input_1.selection)([
178
- "Next",
179
- "Previous",
180
- "Quit"
181
- ], ["n", "p", "q"])) {
182
- case 0:
183
- await this.play(episode + 1, config, config_dir);
184
- break;
185
- case 1:
186
- await this.play(episode - 1, config, config_dir);
187
- break;
188
- case 2:
189
- break;
190
- }
191
- }
155
+ await this.play(episode, config, config_dir, true);
192
156
  }
193
- async play(episode, config, config_dir) {
157
+ async play(episode, config, config_dir, first = false) {
194
158
  /*
195
159
  # Continues play cascade
196
160
  ## Continues on from play_head()
197
161
  */
198
- console.clear();
199
- console.log(`Playing ${this.id} episode ${episode + 1}`);
200
- if (this.player == 0) {
201
- await open(await this.get_episode_link(episode, "BROWSER"));
202
- }
203
- else if (this.player == 1) {
204
- console.log(await this.get_episode_link(episode));
205
- }
206
- else if (this.player.opts.app == "mpv") {
207
- await this.player.load(await this.get_episode_link(episode));
208
- }
209
- else {
210
- this.player.quit();
211
- this.player = await new PlayerController({
212
- app: 'vlc',
213
- args: ['--fullscreen'],
214
- media: await this.get_episode_link(episode, config.player)
215
- });
216
- // @ts-ignore
217
- await this.player.launch(err => {
218
- if (err)
219
- return console.error(err.message);
220
- });
162
+ if (!first) {
163
+ console.clear();
164
+ console.log(chalk.blue(`Playing ${this.id} episode ${episode + 1}`));
165
+ if (this.player == 0) {
166
+ await open(await this.get_episode_link(episode, "BROWSER"));
167
+ }
168
+ else if (this.player == 1) {
169
+ console.log(await this.get_episode_link(episode));
170
+ }
171
+ else if (this.player.opts.app == "mpv") {
172
+ await this.player.load(await this.get_episode_link(episode));
173
+ }
174
+ else {
175
+ this.player.quit();
176
+ this.player = await new PlayerController({
177
+ app: 'vlc',
178
+ args: ['--fullscreen'],
179
+ media: await this.get_episode_link(episode, config.player)
180
+ });
181
+ // @ts-ignore
182
+ await this.player.launch(err => {
183
+ if (err)
184
+ return console.error(err.message);
185
+ });
186
+ }
221
187
  }
222
188
  config.most_recent.anime_id = this.id;
223
189
  config.most_recent.episode_number = episode;
224
190
  (0, load_config_1.write_config)(config_dir, config);
225
191
  this.most_recent = episode;
226
- (0, cache_1.new_cache)(config_dir, this);
227
- if (episode <= 0) {
228
- switch (await (0, input_1.selection)([
229
- "Next",
230
- "Quit"
231
- ], ["n", "q"])) {
232
- case 0:
233
- await this.play(episode + 1, config, config_dir);
234
- break;
235
- case 1:
236
- break;
192
+ (0, cache_1.new_cache)(config_dir, {
193
+ id: this.id,
194
+ episode_list: this.episode_list,
195
+ most_recent: this.most_recent
196
+ });
197
+ let selected; // Look, I'm sorry, but there is no way I can possibly document this in a sane way. It's a dumb patch.
198
+ do {
199
+ selected = await (0, input_1.selection)((episode <= 0) ? [chalk.yellow("1/n) Next"), chalk.grey("2/p) Previous"), chalk.yellow("3/s) Select"), chalk.green("4/q) Quit")] :
200
+ (episode >= this.episode_list.length - 1) ? [chalk.grey("1/n) Next"), chalk.green("2/p) Previous"), chalk.yellow("3/s) Select"), chalk.green("4/q) Quit")] :
201
+ [chalk.yellow("1/n) Next"), chalk.green("2/p) Previous"), chalk.yellow("3/s) Select"), chalk.green("4/q) Quit")], ["n", "p", "s", "q"], ((thing) => { return (thing); }), ((thing) => { return (thing); }), true);
202
+ if (!(selected != ((episode <= 0) ? 1 : (episode >= this.episode_list.length - 1) ? 0 : -1))) {
203
+ console.log(chalk.red("Invalid choice."));
237
204
  }
238
- }
239
- else if (episode >= this.episode_list.length - 2) {
240
- switch (await (0, input_1.selection)([
241
- "Previous",
242
- "Quit"
243
- ], ["p", "q"])) {
244
- case 0:
205
+ } while (!(selected != ((episode <= 0) ? 1 : (episode >= this.episode_list.length - 1) ? 0 : -1)));
206
+ switch (selected) {
207
+ case 0:
208
+ if (episode >= this.episode_list.length - 1) {
245
209
  await this.play(episode - 1, config, config_dir);
246
- break;
247
- case 1:
248
- break;
249
- }
250
- }
251
- else {
252
- switch (await (0, input_1.selection)([
253
- "Next",
254
- "Previous",
255
- "Quit"
256
- ], ["n", "p", "q"])) {
257
- case 0:
210
+ }
211
+ else {
258
212
  await this.play(episode + 1, config, config_dir);
213
+ }
214
+ break;
215
+ case 1:
216
+ if ((episode >= this.episode_list.length - 1) || (episode <= 0)) {
259
217
  break;
260
- case 1:
261
- await this.play(episode - 1, config, config_dir);
262
- break;
263
- case 2:
264
- break;
265
- }
218
+ }
219
+ await this.play(episode - 1, config, config_dir);
220
+ break;
221
+ case 2:
222
+ if (this.episode_list.length == 1) {
223
+ await this.play(0, config, config_dir);
224
+ }
225
+ else {
226
+ console.log(`Select episode [1-${this.episode_list.length}]`);
227
+ await this.play(await (0, input_1.number_input)(this.episode_list.length, 1) - 1, config, config_dir);
228
+ }
229
+ break;
230
+ case 3:
231
+ break;
266
232
  }
233
+ // if (episode <= 0){
234
+ // switch(await selection([
235
+ // "Next",
236
+ // "Quit"
237
+ // ], ["n", "q"])){
238
+ // case 0:
239
+ // await this.play(episode+1, config, config_dir)
240
+ // break
241
+ // case 1:
242
+ // break
243
+ // }
244
+ // }else if(episode >= this.episode_list.length-2){
245
+ // switch(await selection([
246
+ // "Previous",
247
+ // "Quit"
248
+ // ], ["p", "q"])){
249
+ // case 0:
250
+ // await this.play(episode-1, config, config_dir)
251
+ // break
252
+ // case 1:
253
+ // break
254
+ // }
255
+ // }else{
256
+ // switch(await selection([
257
+ // "Next",
258
+ // "Previous",
259
+ // "Quit"
260
+ // ], ["n", "p", "q"])){
261
+ // case 0:
262
+ // await this.play(episode+1, config, config_dir)
263
+ // break
264
+ // case 1:
265
+ // await this.play(episode-1, config, config_dir)
266
+ // break
267
+ // case 2:
268
+ // break
269
+ // }
270
+ // }
267
271
  }
268
272
  async download(episode, download_folder, final_ep) {
269
273
  /*
package/bin/input.js CHANGED
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.number_input = exports.input = exports.selection = void 0;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
8
  const _prompt = require("simple-input");
9
- async function selection(options, extra_options = [], color1 = ((thing) => { return chalk_1.default.yellow(thing); }), color2 = ((thing) => { return chalk_1.default.green(thing); })) {
9
+ async function selection(options, extra_options = [], color1 = ((thing) => { return chalk_1.default.yellow(thing); }), color2 = ((thing) => { return chalk_1.default.green(thing); }), overwrite = false) {
10
10
  /*
11
11
  selection(options, extra_options, color1, color2)
12
12
 
@@ -24,18 +24,25 @@ async function selection(options, extra_options = [], color1 = ((thing) => { ret
24
24
  recommended for this function to return a chalk.____() parsed string.
25
25
 
26
26
  default: ((thing:string) => {return chalk.yellow(thing)}) and ((thing:string) => {return chalk.green(thing)})
27
+
28
+ - Overwrite: boolean. Please dont use this. I should not be using it. It prints out the raw string instead of adding numbers to them to allow for bogus.
27
29
  */
28
30
  let color = true;
29
31
  for (let x in options) {
30
- if (color) {
31
- console.log(color1((parseInt(x) + 1).toString() +
32
- ((extra_options[x] == undefined) ? "" : "/" + extra_options[x]) +
33
- ") " + options[x].replaceAll("-", " ")));
32
+ if (!overwrite) {
33
+ if (color) {
34
+ console.log(color1((parseInt(x) + 1).toString() +
35
+ ((extra_options[x] == undefined) ? "" : "/" + extra_options[x]) +
36
+ ") " + options[x].replaceAll("-", " ")));
37
+ }
38
+ else {
39
+ console.log(color2((parseInt(x) + 1).toString() +
40
+ ((extra_options[x] == undefined) ? "" : "/" + extra_options[x]) +
41
+ ") " + options[x].replaceAll("-", " ")));
42
+ }
34
43
  }
35
44
  else {
36
- console.log(color2((parseInt(x) + 1).toString() +
37
- ((extra_options[x] == undefined) ? "" : "/" + extra_options[x]) +
38
- ") " + options[x].replaceAll("-", " ")));
45
+ console.log(options[x]);
39
46
  }
40
47
  color = !color;
41
48
  }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ function video_quality_mp4(quality, link) {
3
+ switch (quality) {
4
+ case "best":
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ani-cli-npm",
3
- "version": "2.0.8",
3
+ "version": "2.0.9",
4
4
  "description": "ani-cli tool rewritten as npm package",
5
5
  "main": "bin/index.js",
6
6
  "scripts": {
package/temp ADDED
@@ -0,0 +1,16 @@
1
+ et_video_quality_mp4() {
2
+ case $quality in
3
+ best)
4
+ video_url=$(printf '%s' "$1" | tail -n 1 | cut -d">" -f2) ;;
5
+ worst)
6
+ video_url=$(printf '%s' "$1" | head -n 1 | cut -d">" -f2) ;;
7
+ *)
8
+ video_url=$(printf '%s' "$1" | grep -i "${quality}p" | head -n 1 | cut -d">" -f2)
9
+ if [ -z "$video_url" ]; then
10
+ err "Current video quality is not available (defaulting to best quality)"
11
+ video_url=$(printf '%s' "$1" | tail -n 1 | cut -d">" -f2)
12
+ fi
13
+ ;;
14
+ esac
15
+ printf '%s' "$video_url"
16
+ }