ani-cli-npm 1.3.2 → 1.4.0

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))
@@ -216,8 +214,28 @@ async function episode_list(anime_id){
216
214
  return json
217
215
  }
218
216
 
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.")
217
+ function download(link, file_name){
218
+ 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.")
219
+ let option = {
220
+ filename: link.includes("m3u8") ? file_name.replace("mp4", "m3u8") : file_name,
221
+ dir: config.download_folder,
222
+ onDone: (info)=>{
223
+ console.log(colors.Green, `\n -- Download finished -- \nLocation: ${info.path}\nSize: ${Math.round(info.size/100000)*10} Bytes`);
224
+ return 0;
225
+ },
226
+ onError: (err) => {
227
+ console.log(colors.Red, 'error', err);
228
+ },
229
+ onProgress: (curr, total) => {
230
+ process.stdout.clearLine(0);
231
+ process.stdout.cursorTo(0);
232
+ process.stdout.write(('\x1b[32m -- progress '+ (curr / total * 100).toFixed(2) + '% -- \x1b[0m'));
233
+ },
234
+ }
235
+ console.log(colors.White, `${option.dir}/${option.filename}`)
236
+
237
+ return dl(link, option);
238
+
221
239
  }
222
240
 
223
241
  async function selection(options, prompt, extra_options = []){
@@ -311,7 +329,7 @@ async function generate_link(provider, id){
311
329
  }
312
330
  }
313
331
 
314
- async function post_play(link, anime){
332
+ async function post_play(link, anime, player = null){
315
333
  while (true){
316
334
  config.most_recent = anime
317
335
  write_config()
@@ -320,41 +338,43 @@ async function post_play(link, anime){
320
338
  console.log(colors.Cyan, "1/l) Show Link")
321
339
  console.log(colors.Cyan, "2/n) Next Episode")
322
340
  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"])){
341
+ console.log(colors.Cyan, "4/d) Download")
342
+ console.log(colors.Cyan, "5/q) Quit")
343
+ switch (await selection(5, "select;", ["l", "n", "p", "d", "q"])){
325
344
  case "l":
326
345
  case "1":
327
- console.clear()
328
- console.log(colors.Blue, "ANI-CLI-NPM \n")
329
346
  console.log(colors.Yellow, "Link: "+link)
330
347
  break
331
348
  case "n":
332
349
  case "2":
333
350
  if (anime.episode_number > anime.episodes.length-2){
334
- console.clear()
335
351
  console.log(colors.Red, "Damn, all out of episodes?")
336
352
  break
337
353
  }
338
354
  anime.episode_number += 1
339
355
  link = await get_video_link(anime.episodes[anime.episode_number])
340
- await play(link, anime)
356
+ await play(link, anime, player)
341
357
  process.exit()
342
358
  break
343
359
  //EVEN MORE NEEDLESS QUIT STATEMENTS!!!!!!
344
360
  case "p":
345
361
  case "3":
346
362
  if (anime.episode_number < 2){
347
- console.clear()
348
363
  console.log(colors.Red, "Error; Episode 0 is only available for premium members")
349
364
  break
350
365
  }
351
366
  anime.episode_number -= 1
352
367
  link = await get_video_link(anime.episodes[anime.episode_number])
353
- await play(link, anime)
368
+ await play(link, anime, player)
354
369
  process.exit()
355
370
  break
356
- case "q":
371
+ case "d":
357
372
  case "4":
373
+ console.log(colors.Yellow, "Beware of the dysfunctional await clause.")
374
+ await download(link, anime.anime_id+(anime.episode_number+1)+".mp4")
375
+ break
376
+ case "q":
377
+ case "5":
358
378
  console.clear()
359
379
  await main()
360
380
  process.exit()
@@ -363,20 +383,34 @@ async function post_play(link, anime){
363
383
  }
364
384
  }
365
385
 
366
- async function play(link, anime){
386
+ async function play(link, anime, player){
367
387
  console.clear()
368
388
  console.log(colors.Blue, "ANI-CLI-NPM \n")
369
389
  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)
390
+ if (!player){
391
+ console.log(colors.Yellow, "Loading VLC... ")
392
+ player = new PlayerController({
393
+ app: 'vlc',
394
+ args: ['--fullscreen'],
395
+ media: link
396
+ });
397
+ await player.launch(err => {
398
+ if (err) return console.error(err.message);
399
+ });
400
+ }else{
401
+ player.quit()
402
+ console.log(colors.Yellow, "Loading VLC... ")
403
+ player = new PlayerController({
404
+ app: 'vlc',
405
+ args: ['--fullscreen'],
406
+ media: link
407
+ });
408
+ await player.launch(err => {
409
+ if (err) return console.error(err.message);
410
+ });
411
+ }
412
+
413
+ await post_play(link, anime, player)
380
414
  process.exit()
381
415
 
382
416
 
@@ -386,16 +420,21 @@ async function play(link, anime){
386
420
  await post_play(link, anime)
387
421
  process.exit()
388
422
  }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)
423
+ if (!player){
424
+ console.log(colors.Yellow, "Loading MPV... ")
425
+ player = new PlayerController({
426
+ app: 'mpv',
427
+ args: ['--fullscreen'],
428
+ media: link
429
+ });
430
+ await player.launch(err => {
431
+ if (err) return console.error(err.message);
432
+ });
433
+ }else{
434
+ player.load(link)
435
+ }
436
+
437
+ await post_play(link, anime, player)
399
438
  process.exit()
400
439
  }
401
440
  }
@@ -409,8 +448,6 @@ async function search(){
409
448
 
410
449
  console.log(colors.Blue, "Indexing video...")
411
450
  let link = await get_video_link(anime.episodes[anime.episode_number])
412
- console.clear()
413
- console.log(colors.Blue, "ANI-CLI-NPM \n")
414
451
  if (!link){
415
452
  console.log(colors.Red, "Np link for this episode found?")
416
453
  console.log(colors.Yellow, "^ at current this is due to not all of the required video repos being implemented.")
@@ -425,19 +462,37 @@ async function search(){
425
462
  console.log(colors.Cyan, "2/d) Download")
426
463
  console.log(colors.Cyan, "3/l) Show Link")
427
464
  console.log(colors.Cyan, "4/q) quit")
428
- choice = (await selection(4, "select;", "p", "d", "l", "q"))
465
+ choice = (await selection(4, "select;", ["p", "d", "l", "q"]))
429
466
  switch (choice){
430
467
  case "p":
431
468
  case "1":
432
- await play(link, anime)
469
+ await play(link, anime, null)
433
470
  break
434
471
  case "d":
435
472
  case "2":
436
- await download(link, anime.anime_id+anime.episode_number+".mp4")
473
+ await download(link, anime.anime_id+(anime.episode_number+1)+".mp4")
437
474
  break
438
475
  case "l":
439
476
  case "3":
440
477
  console.log(colors.Yellow, "Link: "+link)
478
+ console.log(colors.Cyan, "\n1/p) Play")
479
+ console.log(colors.Cyan, "2/d) Download")
480
+ console.log(colors.Cyan, "3/q) quit")
481
+ choice = (await selection(3, "select;", ["p", "d", "q"]))
482
+ switch (choice){
483
+ case "p":
484
+ case "1":
485
+ await play(link, anime, null)
486
+ break
487
+ case "d":
488
+ case "2":
489
+ await download(link, anime.anime_id+anime.episode_number+".mp4")
490
+ break
491
+ case "q":
492
+ case "3":
493
+ await main()
494
+ process.exit()
495
+ }
441
496
  break
442
497
  case "q":
443
498
  case "4":
@@ -517,5 +572,4 @@ async function main(){
517
572
  }
518
573
 
519
574
 
520
- main()
521
-
575
+ 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.0",
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