ani-cli-npm 2.0.8 → 2.0.10

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") {
@@ -114,7 +122,8 @@ class Anime {
114
122
  this.player = await new PlayerController({
115
123
  app: 'mpv',
116
124
  args: ['--fullscreen'],
117
- media: await this.get_episode_link(episode, config.player)
125
+ media: await this.get_episode_link(episode, config.player),
126
+ ipcPath: config.mpv_socket_path
118
127
  });
119
128
  // @ts-ignore
120
129
  await this.player.launch(err => {
@@ -144,126 +153,122 @@ class Anime {
144
153
  console.log(await this.get_episode_link(episode, config.player));
145
154
  break;
146
155
  }
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
- }
156
+ await this.play(episode, config, config_dir, true);
192
157
  }
193
- async play(episode, config, config_dir) {
158
+ async play(episode, config, config_dir, first = false) {
194
159
  /*
195
160
  # Continues play cascade
196
161
  ## Continues on from play_head()
197
162
  */
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
- });
163
+ if (!first) {
164
+ console.clear();
165
+ console.log(chalk.blue(`Playing ${this.id} episode ${episode + 1}`));
166
+ if (this.player == 0) {
167
+ await open(await this.get_episode_link(episode, "BROWSER"));
168
+ }
169
+ else if (this.player == 1) {
170
+ console.log(await this.get_episode_link(episode));
171
+ }
172
+ else if (this.player.opts.app == "mpv") {
173
+ await this.player.load(await this.get_episode_link(episode));
174
+ }
175
+ else {
176
+ this.player.quit();
177
+ this.player = await new PlayerController({
178
+ app: 'vlc',
179
+ args: ['--fullscreen'],
180
+ media: await this.get_episode_link(episode, config.player)
181
+ });
182
+ // @ts-ignore
183
+ await this.player.launch(err => {
184
+ if (err)
185
+ return console.error(err.message);
186
+ });
187
+ }
221
188
  }
222
189
  config.most_recent.anime_id = this.id;
223
190
  config.most_recent.episode_number = episode;
224
191
  (0, load_config_1.write_config)(config_dir, config);
225
192
  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;
193
+ (0, cache_1.new_cache)(config_dir, {
194
+ id: this.id,
195
+ episode_list: this.episode_list,
196
+ most_recent: this.most_recent
197
+ });
198
+ 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.
199
+ do {
200
+ 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")] :
201
+ (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")] :
202
+ [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);
203
+ if (!(selected != ((episode <= 0) ? 1 : (episode >= this.episode_list.length - 1) ? 0 : -1))) {
204
+ console.log(chalk.red("Invalid choice."));
237
205
  }
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:
206
+ } while (!(selected != ((episode <= 0) ? 1 : (episode >= this.episode_list.length - 1) ? 0 : -1)));
207
+ switch (selected) {
208
+ case 0:
209
+ if (episode >= this.episode_list.length - 1) {
245
210
  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:
211
+ }
212
+ else {
258
213
  await this.play(episode + 1, config, config_dir);
214
+ }
215
+ break;
216
+ case 1:
217
+ if ((episode >= this.episode_list.length - 1) || (episode <= 0)) {
259
218
  break;
260
- case 1:
261
- await this.play(episode - 1, config, config_dir);
262
- break;
263
- case 2:
264
- break;
265
- }
219
+ }
220
+ await this.play(episode - 1, config, config_dir);
221
+ break;
222
+ case 2:
223
+ if (this.episode_list.length == 1) {
224
+ await this.play(0, config, config_dir);
225
+ }
226
+ else {
227
+ console.log(`Select episode [1-${this.episode_list.length}]`);
228
+ await this.play(await (0, input_1.number_input)(this.episode_list.length, 1) - 1, config, config_dir);
229
+ }
230
+ break;
231
+ case 3:
232
+ break;
266
233
  }
234
+ // if (episode <= 0){
235
+ // switch(await selection([
236
+ // "Next",
237
+ // "Quit"
238
+ // ], ["n", "q"])){
239
+ // case 0:
240
+ // await this.play(episode+1, config, config_dir)
241
+ // break
242
+ // case 1:
243
+ // break
244
+ // }
245
+ // }else if(episode >= this.episode_list.length-2){
246
+ // switch(await selection([
247
+ // "Previous",
248
+ // "Quit"
249
+ // ], ["p", "q"])){
250
+ // case 0:
251
+ // await this.play(episode-1, config, config_dir)
252
+ // break
253
+ // case 1:
254
+ // break
255
+ // }
256
+ // }else{
257
+ // switch(await selection([
258
+ // "Next",
259
+ // "Previous",
260
+ // "Quit"
261
+ // ], ["n", "p", "q"])){
262
+ // case 0:
263
+ // await this.play(episode+1, config, config_dir)
264
+ // break
265
+ // case 1:
266
+ // await this.play(episode-1, config, config_dir)
267
+ // break
268
+ // case 2:
269
+ // break
270
+ // }
271
+ // }
267
272
  }
268
273
  async download(episode, download_folder, final_ep) {
269
274
  /*
@@ -15,6 +15,7 @@ async function config_(temp) {
15
15
  "Proxy; " + temp.proxy,
16
16
  "User agent; " + temp.user_agent,
17
17
  "Downloads folder; " + temp.download_folder,
18
+ "mpv socket connection file; " + temp.mpv_socket_path,
18
19
  "Save and exit",
19
20
  "Exit without saving"
20
21
  ], [], ((item) => { return chalk.cyan(item); }), ((item) => { return chalk.cyan(item); }));
@@ -58,9 +59,14 @@ async function config_(temp) {
58
59
  // @ts-ignore
59
60
  return temp, 0;
60
61
  case 4:
62
+ console.log(chalk.cyan("New socket file"));
63
+ temp.mpv_socket_path = await ((0, input_1.input)());
61
64
  // @ts-ignore
62
- return temp, 1;
65
+ return temp, 0;
63
66
  case 5:
67
+ // @ts-ignore
68
+ return temp, 1;
69
+ case 6:
64
70
  // @ts-ignore
65
71
  return temp, 2;
66
72
  }
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
  }
@@ -57,7 +57,8 @@ function load_config(cache_dir) {
57
57
  anime_id: ""
58
58
  },
59
59
  download_folder: ".",
60
- debug_mode: false
60
+ debug_mode: false,
61
+ mpv_socket_path: "",
61
62
  };
62
63
  if (fs.existsSync(cache_dir + "/config.conf")) {
63
64
  // @ts-ignore
@@ -83,6 +84,9 @@ function load_config(cache_dir) {
83
84
  // @ts-ignore
84
85
  if (tmp.download_folder !== undefined)
85
86
  config.download_folder = tmp.download_folder;
87
+ // @ts-ignore
88
+ if (tmp.mpv_socket_path !== undefined)
89
+ config.mpv_socket_path = tmp.mpv_socket_path;
86
90
  }
87
91
  write_config(cache_dir, config);
88
92
  return config;
@@ -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.10",
4
4
  "description": "ani-cli tool rewritten as npm package",
5
5
  "main": "bin/index.js",
6
6
  "scripts": {