ani-cli-npm 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- package/bin/index.js +89 -36
- package/package.json +1 -1
package/bin/index.js
CHANGED
@@ -23,25 +23,50 @@ const fs = require("fs")
|
|
23
23
|
let config = {
|
24
24
|
player: "BROWSER",
|
25
25
|
proxy: "",
|
26
|
-
user_agent: "Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/100.0"
|
26
|
+
user_agent: "Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/100.0",
|
27
|
+
most_recent: {
|
28
|
+
episode_number: 0,
|
29
|
+
anime_id: "",
|
30
|
+
episodes: []
|
31
|
+
}
|
27
32
|
}
|
28
33
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
34
|
+
|
35
|
+
function read_config(){
|
36
|
+
try{
|
37
|
+
try {
|
38
|
+
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
|
+
}
|
51
|
+
fs.writeFileSync(getAppDataPath() + "/ani-cli-npm.conf", JSON.stringify(config))
|
52
|
+
} catch {
|
53
|
+
fs.writeFileSync(getAppDataPath() + "/ani-cli-npm.conf", JSON.stringify(config))
|
54
|
+
}
|
55
|
+
}catch{
|
56
|
+
console.log(colors.Red, "Failed to read config file")
|
36
57
|
}
|
37
|
-
|
38
|
-
|
58
|
+
}
|
59
|
+
|
60
|
+
function write_config(){
|
61
|
+
try{
|
62
|
+
fs.writeFileSync(getAppDataPath() + "/ani-cli-npm.conf", JSON.stringify(config))
|
63
|
+
}catch{
|
64
|
+
console.log(colors.Red, "Failed to write to config file")
|
39
65
|
}
|
40
|
-
fs.writeFileSync(getAppDataPath()+"/ani-cli-npm.conf", JSON.stringify(config))
|
41
|
-
}catch{
|
42
|
-
fs.writeFileSync(getAppDataPath()+"/ani-cli-npm.conf", JSON.stringify(config))
|
43
66
|
}
|
44
67
|
|
68
|
+
|
69
|
+
|
45
70
|
const gogohd_url="https://gogohd.net/"
|
46
71
|
const base_url="https://animixplay.to"
|
47
72
|
const colors = {
|
@@ -138,7 +163,14 @@ async function curl(url, method="GET", redirect = false){
|
|
138
163
|
|
139
164
|
}
|
140
165
|
|
141
|
-
function
|
166
|
+
async function _continue(){
|
167
|
+
let link = await get_video_link(config.most_recent.episodes[config.most_recent.episode_number])
|
168
|
+
await play(link, config.most_recent)
|
169
|
+
process.exit()
|
170
|
+
}
|
171
|
+
|
172
|
+
|
173
|
+
function RegexParse(str, rule) {
|
142
174
|
let escapeRegex = (str) => str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
|
143
175
|
return new RegExp("^" + rule.split("*").map(escapeRegex).join(".*") + "$").test(str);
|
144
176
|
}
|
@@ -149,7 +181,7 @@ async function search_anime(search){
|
|
149
181
|
let lines = []
|
150
182
|
for (x in html){
|
151
183
|
html[x] = html[x].replaceAll(/ /g,'').replaceAll(/\t/g,'')
|
152
|
-
if (
|
184
|
+
if (RegexParse(html[x], filter)){
|
153
185
|
html[x] = html[x].slice(html[x].indexOf("/category/")+10);
|
154
186
|
html[x] = html[x].slice(0, html[x].indexOf("\"title="));
|
155
187
|
lines.push(html[x])
|
@@ -168,7 +200,7 @@ async function episode_list(anime_id){
|
|
168
200
|
let lines = ""
|
169
201
|
|
170
202
|
for (let x in html){
|
171
|
-
if(
|
203
|
+
if(RegexParse(html[x], "*<div id=\"epslistplace\"*")){
|
172
204
|
lines = (html[x])
|
173
205
|
}
|
174
206
|
}
|
@@ -248,7 +280,7 @@ async function generate_link(provider, id){
|
|
248
280
|
html = html.split("\n")
|
249
281
|
let fb_id = ""
|
250
282
|
for (x in html){
|
251
|
-
if (
|
283
|
+
if (RegexParse(html[x], "*<li class=\"linkserver\" data-status=\"1\" data-video=\"https://fembed9hd.com/v/*")){
|
252
284
|
fb_id = html[x].slice(html[x].indexOf("/v/")+3, html[x].indexOf("\">X"))
|
253
285
|
break
|
254
286
|
}
|
@@ -279,8 +311,11 @@ async function generate_link(provider, id){
|
|
279
311
|
}
|
280
312
|
}
|
281
313
|
|
282
|
-
async function post_play(link, anime
|
314
|
+
async function post_play(link, anime){
|
283
315
|
while (true){
|
316
|
+
config.most_recent = anime
|
317
|
+
write_config()
|
318
|
+
|
284
319
|
console.log(colors.Yellow, `Playing episode ${anime.episode_number+1} of ${anime.anime_id.replaceAll("-", " ")}\n`)
|
285
320
|
console.log(colors.Cyan, "1/l) Show Link")
|
286
321
|
console.log(colors.Cyan, "2/n) Next Episode")
|
@@ -302,7 +337,7 @@ async function post_play(link, anime, player="VLC"){
|
|
302
337
|
}
|
303
338
|
anime.episode_number += 1
|
304
339
|
link = await get_video_link(anime.episodes[anime.episode_number])
|
305
|
-
await play(link, anime
|
340
|
+
await play(link, anime)
|
306
341
|
process.exit()
|
307
342
|
break
|
308
343
|
//EVEN MORE NEEDLESS QUIT STATEMENTS!!!!!!
|
@@ -315,7 +350,7 @@ async function post_play(link, anime, player="VLC"){
|
|
315
350
|
}
|
316
351
|
anime.episode_number -= 1
|
317
352
|
link = await get_video_link(anime.episodes[anime.episode_number])
|
318
|
-
await play(link, anime
|
353
|
+
await play(link, anime)
|
319
354
|
process.exit()
|
320
355
|
break
|
321
356
|
case "q":
|
@@ -328,10 +363,10 @@ async function post_play(link, anime, player="VLC"){
|
|
328
363
|
}
|
329
364
|
}
|
330
365
|
|
331
|
-
async function play(link, anime
|
366
|
+
async function play(link, anime){
|
332
367
|
console.clear()
|
333
368
|
console.log(colors.Blue, "ANI-CLI-NPM \n")
|
334
|
-
if (player === "VLC"){
|
369
|
+
if (config.player === "VLC"){
|
335
370
|
console.log(colors.Yellow, "Loading VLC... ")
|
336
371
|
let player = new PlayerController({
|
337
372
|
app: 'vlc',
|
@@ -345,12 +380,12 @@ async function play(link, anime, player="VLC"){
|
|
345
380
|
process.exit()
|
346
381
|
|
347
382
|
|
348
|
-
}else if (player === "BROWSER"){
|
383
|
+
}else if (config.player === "BROWSER"){
|
349
384
|
console.log(colors.Yellow, "Opening video in browser... ")
|
350
385
|
open(link)
|
351
|
-
await post_play(link, anime
|
386
|
+
await post_play(link, anime)
|
352
387
|
process.exit()
|
353
|
-
}else if (player === "MPV"){
|
388
|
+
}else if (config.player === "MPV"){
|
354
389
|
console.log(colors.Yellow, "Loading MPV... ")
|
355
390
|
let player = new PlayerController({
|
356
391
|
app: 'mpv',
|
@@ -360,7 +395,7 @@ async function play(link, anime, player="VLC"){
|
|
360
395
|
await player.launch(err => {
|
361
396
|
if(err) return console.error(err.message);
|
362
397
|
});
|
363
|
-
await post_play(link, anime
|
398
|
+
await post_play(link, anime)
|
364
399
|
process.exit()
|
365
400
|
}
|
366
401
|
}
|
@@ -396,11 +431,11 @@ async function search(){
|
|
396
431
|
switch (choice){
|
397
432
|
case "p":
|
398
433
|
case "1":
|
399
|
-
await play(link, anime
|
434
|
+
await play(link, anime)
|
400
435
|
break
|
401
436
|
case "d":
|
402
437
|
case "2":
|
403
|
-
download(link, anime.anime_id+anime.episode_number+".mp4")
|
438
|
+
await download(link, anime.anime_id+anime.episode_number+".mp4")
|
404
439
|
break
|
405
440
|
case "l":
|
406
441
|
case "3":
|
@@ -414,24 +449,42 @@ async function search(){
|
|
414
449
|
}
|
415
450
|
|
416
451
|
|
417
|
-
|
418
452
|
console.clear()
|
419
|
-
|
453
|
+
read_config()
|
454
|
+
console.log(colors.Blue, "Welcome to Ani-Cli-npm\n")
|
455
|
+
if (config.most_recent.episode_number !== 0){
|
456
|
+
console.log(colors.White, `Most recently played: ${config.most_recent.anime_id}, ep${config.most_recent.episode_number+1}`)
|
457
|
+
}
|
420
458
|
async function main(){
|
421
459
|
if (config.player === "VLC"){
|
422
460
|
console.log(colors.Red, "Warning; if you do not have mpv video player installed, you will have to change your video player to either vlc or browser in config.\n")
|
423
461
|
}
|
424
|
-
console.log(colors.Cyan, "
|
425
|
-
|
426
|
-
|
427
|
-
|
462
|
+
console.log(colors.Cyan, "\n1/s) Search")
|
463
|
+
if (config.most_recent.episode_number !== 0){
|
464
|
+
console.log(colors.Cyan, "2/c) Continue")
|
465
|
+
}else{
|
466
|
+
console.log(colors.White, "2/c) Continue")
|
467
|
+
}
|
468
|
+
console.log(colors.Cyan, "3/C) Config")
|
469
|
+
console.log(colors.Cyan, "4/q) Quit")
|
470
|
+
let choice = await selection(3, "select;", ["s", "c", "C", "q"])
|
428
471
|
switch (choice){
|
429
472
|
case "s":
|
430
473
|
case "1":
|
431
474
|
await search()
|
432
475
|
break
|
433
476
|
case "c":
|
434
|
-
case
|
477
|
+
case 2:
|
478
|
+
if (config.most_recent.episode_number !== 0){
|
479
|
+
await _continue()
|
480
|
+
}else{
|
481
|
+
console.log(colors.White, "No episodes watched recently")
|
482
|
+
await main()
|
483
|
+
}
|
484
|
+
|
485
|
+
break
|
486
|
+
case "C":
|
487
|
+
case "3":
|
435
488
|
let temp = structuredClone(config);
|
436
489
|
let exit_code;
|
437
490
|
while (true) {
|
@@ -459,7 +512,7 @@ async function main(){
|
|
459
512
|
await main()
|
460
513
|
break
|
461
514
|
case "q":
|
462
|
-
case
|
515
|
+
case 4:
|
463
516
|
console.log(colors.Black, "Exiting...")
|
464
517
|
process.exit()
|
465
518
|
}
|