ani-cli-npm 1.3.2 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
package/bin/index.js CHANGED
@@ -19,6 +19,10 @@ const open = require("open")
19
19
  const prompt = require("simple-input");
20
20
  const getAppDataPath = require("appdata-path")
21
21
  const fs = require("fs")
22
+ const downloadsFolder = require('downloads-folder');
23
+ const dl = require("download-file-with-progressbar");
24
+
25
+
22
26
 
23
27
  let config = {
24
28
  player: "BROWSER",
@@ -28,7 +32,8 @@ let config = {
28
32
  episode_number: 0,
29
33
  anime_id: "",
30
34
  episodes: []
31
- }
35
+ },
36
+ download_folder: downloadsFolder()
32
37
  }
33
38
 
34
39
 
@@ -36,18 +41,11 @@ function read_config(){
36
41
  try{
37
42
  try {
38
43
  config = JSON.parse(fs.readFileSync(getAppDataPath() + "/ani-cli-npm.conf")) //getAppDataPath()
39
- if (!config.hasOwnProperty("player")) {
40
- config.player = "BROWSER"
41
- }
42
- if (!config.hasOwnProperty("user_agent")) {
43
- config.user_agent = "Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/100.0"
44
- }
45
- if (!config.hasOwnProperty("proxy")) {
46
- config.user_agent = ""
47
- }
48
- if (!config.hasOwnProperty("most_recent")) {
49
- config.most_recent = null
50
- }
44
+ if (!config.hasOwnProperty("player")) config.player = "BROWSER";
45
+ if (!config.hasOwnProperty("user_agent")) config.user_agent = "Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/100.0";
46
+ if (!config.hasOwnProperty("proxy")) config.user_agent = "";
47
+ if (!config.hasOwnProperty("most_recent")) config.most_recent = null;
48
+ if(!config.download_folder) config.download_folder = downloadsFolder();
51
49
  fs.writeFileSync(getAppDataPath() + "/ani-cli-npm.conf", JSON.stringify(config))
52
50
  } catch {
53
51
  fs.writeFileSync(getAppDataPath() + "/ani-cli-npm.conf", JSON.stringify(config))
@@ -92,8 +90,9 @@ async function config_(temp){
92
90
  console.log(colors.Cyan, `1) Player; ${temp.player}`)
93
91
  console.log(colors.Cyan, `2) Proxy; ${temp.proxy}`)
94
92
  console.log(colors.Cyan, `3) User agent; ${temp.user_agent}`)
95
- console.log(colors.Cyan, "4) Save and exit")
96
- console.log(colors.Cyan, "5) Exit without saving changes")
93
+ console.log(colors.Cyan, `4) Download folder; ${config.download_folder}`)
94
+ console.log(colors.Cyan, "5) Save and exit")
95
+ console.log(colors.Cyan, "6) Exit without saving changes")
97
96
  let choice = parseInt(await input(""));
98
97
  switch (choice){
99
98
  case 1:
@@ -120,8 +119,11 @@ async function config_(temp){
120
119
  temp.user_agent = await(input("New User agent;"))
121
120
  return temp, 0
122
121
  case 4:
123
- return temp, 1
122
+ temp.download_folder = await(input("New download folder: "))
123
+ return temp, 0
124
124
  case 5:
125
+ return temp, 1
126
+ case 6:
125
127
  return temp, 2
126
128
  }
127
129
  }
@@ -216,8 +218,28 @@ async function episode_list(anime_id){
216
218
  return json
217
219
  }
218
220
 
219
- async function download(url, name){
220
- console.log(colors.Red, "Feature not implemented yet. Sorry for any inconvenience.\nIf you need to download a video, request the link, then download it via your internet browser of choice.")
221
+ function download(link, file_name){
222
+ console.log(colors.Red, "Warning: Animixplay will download an m3u8 file. This will require some extra steps to play. It is advised to use a 3rd party website or tool to download these from the link.")
223
+ let option = {
224
+ filename: link.includes("m3u8") ? file_name.replace("mp4", "m3u8") : file_name,
225
+ dir: config.download_folder,
226
+ onDone: (info)=>{
227
+ console.log(colors.Green, `\n -- Download finished -- \nLocation: ${info.path}\nSize: ${Math.round(info.size/100000)*10} Bytes`);
228
+ return 0;
229
+ },
230
+ onError: (err) => {
231
+ console.log(colors.Red, 'error', err);
232
+ },
233
+ onProgress: (curr, total) => {
234
+ process.stdout.clearLine(0);
235
+ process.stdout.cursorTo(0);
236
+ process.stdout.write(('\x1b[32m -- progress '+ (curr / total * 100).toFixed(2) + '% -- \x1b[0m'));
237
+ },
238
+ }
239
+ console.log(colors.White, `${option.dir}/${option.filename}`)
240
+
241
+ return dl(link, option);
242
+
221
243
  }
222
244
 
223
245
  async function selection(options, prompt, extra_options = []){
@@ -311,7 +333,7 @@ async function generate_link(provider, id){
311
333
  }
312
334
  }
313
335
 
314
- async function post_play(link, anime){
336
+ async function post_play(link, anime, player = null){
315
337
  while (true){
316
338
  config.most_recent = anime
317
339
  write_config()
@@ -320,41 +342,44 @@ async function post_play(link, anime){
320
342
  console.log(colors.Cyan, "1/l) Show Link")
321
343
  console.log(colors.Cyan, "2/n) Next Episode")
322
344
  console.log(colors.Cyan, "3/p) Prev Episode")
323
- console.log(colors.Cyan, "4/q) Quit")
324
- switch (await selection(4, "select;", ["l", "n", "p", "q"])){
345
+ console.log(colors.Cyan, "4/d) Download")
346
+ console.log(colors.Cyan, "5/q) Quit")
347
+ switch (await selection(5, "select;", ["l", "n", "p", "d", "q"])){
325
348
  case "l":
326
349
  case "1":
327
- console.clear()
328
- console.log(colors.Blue, "ANI-CLI-NPM \n")
329
350
  console.log(colors.Yellow, "Link: "+link)
330
351
  break
331
352
  case "n":
332
353
  case "2":
333
354
  if (anime.episode_number > anime.episodes.length-2){
334
- console.clear()
335
355
  console.log(colors.Red, "Damn, all out of episodes?")
336
356
  break
337
357
  }
338
358
  anime.episode_number += 1
339
359
  link = await get_video_link(anime.episodes[anime.episode_number])
340
- await play(link, anime)
360
+ await play(link, anime, player)
341
361
  process.exit()
342
362
  break
343
363
  //EVEN MORE NEEDLESS QUIT STATEMENTS!!!!!!
344
364
  case "p":
345
365
  case "3":
346
366
  if (anime.episode_number < 2){
347
- console.clear()
348
367
  console.log(colors.Red, "Error; Episode 0 is only available for premium members")
349
368
  break
350
369
  }
351
370
  anime.episode_number -= 1
352
371
  link = await get_video_link(anime.episodes[anime.episode_number])
353
- await play(link, anime)
372
+ await play(link, anime, player)
354
373
  process.exit()
355
374
  break
356
- case "q":
375
+ case "d":
357
376
  case "4":
377
+ console.log(colors.Yellow, "Beware of the dysfunctional await clause.")
378
+ await download(link, anime.anime_id+(anime.episode_number+1)+".mp4")
379
+ post_play(link, anime, player)
380
+ break
381
+ case "q":
382
+ case "5":
358
383
  console.clear()
359
384
  await main()
360
385
  process.exit()
@@ -363,20 +388,34 @@ async function post_play(link, anime){
363
388
  }
364
389
  }
365
390
 
366
- async function play(link, anime){
391
+ async function play(link, anime, player){
367
392
  console.clear()
368
393
  console.log(colors.Blue, "ANI-CLI-NPM \n")
369
394
  if (config.player === "VLC"){
370
- console.log(colors.Yellow, "Loading VLC... ")
371
- let player = new PlayerController({
372
- app: 'vlc',
373
- args: ['--fullscreen'],
374
- media: link
375
- });
376
- await player.launch(err => {
377
- if(err) return console.error(err.message);
378
- });
379
- await post_play(link, anime)
395
+ if (!player){
396
+ console.log(colors.Yellow, "Loading VLC... ")
397
+ player = new PlayerController({
398
+ app: 'vlc',
399
+ args: ['--fullscreen'],
400
+ media: link
401
+ });
402
+ await player.launch(err => {
403
+ if (err) return console.error(err.message);
404
+ });
405
+ }else{
406
+ player.quit()
407
+ console.log(colors.Yellow, "Loading VLC... ")
408
+ player = new PlayerController({
409
+ app: 'vlc',
410
+ args: ['--fullscreen'],
411
+ media: link
412
+ });
413
+ await player.launch(err => {
414
+ if (err) return console.error(err.message);
415
+ });
416
+ }
417
+
418
+ await post_play(link, anime, player)
380
419
  process.exit()
381
420
 
382
421
 
@@ -386,16 +425,21 @@ async function play(link, anime){
386
425
  await post_play(link, anime)
387
426
  process.exit()
388
427
  }else if (config.player === "MPV"){
389
- console.log(colors.Yellow, "Loading MPV... ")
390
- let player = new PlayerController({
391
- app: 'mpv',
392
- args: ['--fullscreen'],
393
- media: link
394
- });
395
- await player.launch(err => {
396
- if(err) return console.error(err.message);
397
- });
398
- await post_play(link, anime)
428
+ if (!player){
429
+ console.log(colors.Yellow, "Loading MPV... ")
430
+ player = new PlayerController({
431
+ app: 'mpv',
432
+ args: ['--fullscreen'],
433
+ media: link
434
+ });
435
+ await player.launch(err => {
436
+ if (err) return console.error(err.message);
437
+ });
438
+ }else{
439
+ player.load(link)
440
+ }
441
+
442
+ await post_play(link, anime, player)
399
443
  process.exit()
400
444
  }
401
445
  }
@@ -409,8 +453,6 @@ async function search(){
409
453
 
410
454
  console.log(colors.Blue, "Indexing video...")
411
455
  let link = await get_video_link(anime.episodes[anime.episode_number])
412
- console.clear()
413
- console.log(colors.Blue, "ANI-CLI-NPM \n")
414
456
  if (!link){
415
457
  console.log(colors.Red, "Np link for this episode found?")
416
458
  console.log(colors.Yellow, "^ at current this is due to not all of the required video repos being implemented.")
@@ -425,19 +467,37 @@ async function search(){
425
467
  console.log(colors.Cyan, "2/d) Download")
426
468
  console.log(colors.Cyan, "3/l) Show Link")
427
469
  console.log(colors.Cyan, "4/q) quit")
428
- choice = (await selection(4, "select;", "p", "d", "l", "q"))
470
+ choice = (await selection(4, "select;", ["p", "d", "l", "q"]))
429
471
  switch (choice){
430
472
  case "p":
431
473
  case "1":
432
- await play(link, anime)
474
+ await play(link, anime, null)
433
475
  break
434
476
  case "d":
435
477
  case "2":
436
- await download(link, anime.anime_id+anime.episode_number+".mp4")
478
+ await download(link, anime.anime_id+(anime.episode_number+1)+".mp4")
437
479
  break
438
480
  case "l":
439
481
  case "3":
440
482
  console.log(colors.Yellow, "Link: "+link)
483
+ console.log(colors.Cyan, "\n1/p) Play")
484
+ console.log(colors.Cyan, "2/d) Download")
485
+ console.log(colors.Cyan, "3/q) quit")
486
+ choice = (await selection(3, "select;", ["p", "d", "q"]))
487
+ switch (choice){
488
+ case "p":
489
+ case "1":
490
+ await play(link, anime, null)
491
+ break
492
+ case "d":
493
+ case "2":
494
+ await download(link, anime.anime_id+anime.episode_number+".mp4")
495
+ break
496
+ case "q":
497
+ case "3":
498
+ await main()
499
+ process.exit()
500
+ }
441
501
  break
442
502
  case "q":
443
503
  case "4":
@@ -465,7 +525,7 @@ async function main(){
465
525
  }
466
526
  console.log(colors.Cyan, "3/C) Config")
467
527
  console.log(colors.Cyan, "4/q) Quit")
468
- let choice = await selection(3, "select;", ["s", "c", "C", "q"])
528
+ let choice = await selection(4, "select;", ["s", "c", "C", "q"])
469
529
  switch (choice){
470
530
  case "s":
471
531
  case "1":
@@ -517,5 +577,4 @@ async function main(){
517
577
  }
518
578
 
519
579
 
520
- main()
521
-
580
+ main()
package/image.png ADDED
Binary file
package/mpv.js CHANGED
@@ -1,9 +1,19 @@
1
- const PlayerController = require("media-player-controller")
1
+ const dl = require('download-file-with-progressbar');
2
2
 
3
- let player = new PlayerController({
4
- app: 'mpv',
5
- args: ['--fullscreen'],
6
- });
3
+ option = {
4
+ filename: 'video.mp4',
5
+ dir: '.',
6
+ onDone: (info)=>{
7
+ console.log('done', info);
8
+ },
9
+ onError: (err) => {
10
+ console.log('error', err);
11
+ },
12
+ onProgress: (curr, total) => {
13
+ process.stdout.clearLine(0);
14
+ process.stdout.cursorTo(0);
15
+ process.stdout.write(('\x1b[32m -- progress '+ (curr / total * 100).toFixed(2) + '% -- \x1b[0m'));
16
+ },
17
+ }
7
18
 
8
-
9
- player.load("https://wwwx13.gogocdn.stream/videos/hls/l7dItSAxiTBxQMRxKVtoHQ/1669069114/114212/012ef98641ababee475564c70e8ebc93/ep.43.1662459121.m3u8")
19
+ var dd = dl('https://fvs.io/redirector?token=YWJSTUxWYW51UUFQS0dEVlZITHBKejQwbkZkOXJYSWdidnFkU3B1RnVPaVlPclhXbjRlNTVwQS9tclB0Rm1ZUzlNV1FIM2RJM2hOZXkyZmMycHFFUU5Hc0hHZCtHU2MxTWN2andnS2xWUGl3bjVVSnBibUhueTRJVTRuT1Jnbk5TRjRQRVFITERJL0svTVI1QkpTVG10Z0FNQnQvTWZxQ3FCZz06SUVYYjJQMzNUSjhGdE8zQmx5QjdmUT09H57e', option);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ani-cli-npm",
3
- "version": "1.3.2",
3
+ "version": "1.4.1",
4
4
  "description": "ani-cli tool rewritten as npm package",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -16,7 +16,11 @@
16
16
  "anime",
17
17
  "ani-cli",
18
18
  "anime",
19
- "client"
19
+ "client",
20
+ "weeb",
21
+ "sad-weeb",
22
+ "video",
23
+ "download"
20
24
  ],
21
25
  "author": "bumpkin-pi",
22
26
  "license": "ISC",
@@ -25,6 +29,8 @@
25
29
  },
26
30
  "dependencies": {
27
31
  "appdata-path": "^1.0.0",
32
+ "download-file-with-progressbar": "^1.2.3",
33
+ "downloads-folder": "^3.0.3",
28
34
  "media-player-controller": "^1.5.3",
29
35
  "node-fetch": "^2.6.6",
30
36
  "open": "^8.4.0",
package/video.mp4 ADDED
Binary file