ani-cli-npm 1.2.0 → 1.3.0
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/.idea/inspectionProfiles/Project_Default.xml +10 -0
- package/bin/ani-cli-npm.conf +1 -0
- package/bin/index.js +113 -32
- package/package.json +2 -1
@@ -0,0 +1,10 @@
|
|
1
|
+
<component name="InspectionProjectProfileManager">
|
2
|
+
<profile version="1.0">
|
3
|
+
<option name="myName" value="Project Default" />
|
4
|
+
<inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
5
|
+
<Languages>
|
6
|
+
<language minSize="76" name="JavaScript" />
|
7
|
+
</Languages>
|
8
|
+
</inspection_tool>
|
9
|
+
</profile>
|
10
|
+
</component>
|
@@ -0,0 +1 @@
|
|
1
|
+
{"proxy":"","user_agent":"Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/100.0"}
|
package/bin/index.js
CHANGED
@@ -17,6 +17,54 @@ const fetch = require('node-fetch');
|
|
17
17
|
const PlayerController = require("media-player-controller")
|
18
18
|
const open = require("open")
|
19
19
|
const prompt = require("simple-input");
|
20
|
+
const getAppDataPath = require("appdata-path")
|
21
|
+
const fs = require("fs")
|
22
|
+
|
23
|
+
let config = {
|
24
|
+
player: "BROWSER",
|
25
|
+
proxy: "",
|
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
|
+
}
|
32
|
+
}
|
33
|
+
|
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")
|
57
|
+
}
|
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")
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
20
68
|
|
21
69
|
|
22
70
|
const gogohd_url="https://gogohd.net/"
|
@@ -31,11 +79,7 @@ const colors = {
|
|
31
79
|
Cyan: "\x1b[36m%s\x1b[0m",
|
32
80
|
White: "\x1b[37m%s\x1b[0m"
|
33
81
|
}
|
34
|
-
|
35
|
-
player: "MPV",
|
36
|
-
proxy: "",
|
37
|
-
user_agent: 'Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/100.0'
|
38
|
-
}
|
82
|
+
|
39
83
|
|
40
84
|
//const HttpsProxyAgent = require('https-proxy-agent');
|
41
85
|
//let proxyAgent = new HttpsProxyAgent(config.proxy);
|
@@ -43,7 +87,7 @@ let config = {
|
|
43
87
|
|
44
88
|
async function config_(temp){
|
45
89
|
console.clear()
|
46
|
-
console.log(colors.Blue, "ANI-CLI-NPM \n")
|
90
|
+
console.log(colors.Blue, "ANI-CLI-NPM \n")
|
47
91
|
console.log(colors.Yellow, "Config:\n")
|
48
92
|
console.log(colors.Cyan, `1) Player; ${temp.player}`)
|
49
93
|
console.log(colors.Cyan, `2) Proxy; ${temp.proxy}`)
|
@@ -119,7 +163,14 @@ async function curl(url, method="GET", redirect = false){
|
|
119
163
|
|
120
164
|
}
|
121
165
|
|
122
|
-
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) {
|
123
174
|
let escapeRegex = (str) => str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
|
124
175
|
return new RegExp("^" + rule.split("*").map(escapeRegex).join(".*") + "$").test(str);
|
125
176
|
}
|
@@ -130,7 +181,7 @@ async function search_anime(search){
|
|
130
181
|
let lines = []
|
131
182
|
for (x in html){
|
132
183
|
html[x] = html[x].replaceAll(/ /g,'').replaceAll(/\t/g,'')
|
133
|
-
if (
|
184
|
+
if (RegexParse(html[x], filter)){
|
134
185
|
html[x] = html[x].slice(html[x].indexOf("/category/")+10);
|
135
186
|
html[x] = html[x].slice(0, html[x].indexOf("\"title="));
|
136
187
|
lines.push(html[x])
|
@@ -149,7 +200,7 @@ async function episode_list(anime_id){
|
|
149
200
|
let lines = ""
|
150
201
|
|
151
202
|
for (let x in html){
|
152
|
-
if(
|
203
|
+
if(RegexParse(html[x], "*<div id=\"epslistplace\"*")){
|
153
204
|
lines = (html[x])
|
154
205
|
}
|
155
206
|
}
|
@@ -229,7 +280,7 @@ async function generate_link(provider, id){
|
|
229
280
|
html = html.split("\n")
|
230
281
|
let fb_id = ""
|
231
282
|
for (x in html){
|
232
|
-
if (
|
283
|
+
if (RegexParse(html[x], "*<li class=\"linkserver\" data-status=\"1\" data-video=\"https://fembed9hd.com/v/*")){
|
233
284
|
fb_id = html[x].slice(html[x].indexOf("/v/")+3, html[x].indexOf("\">X"))
|
234
285
|
break
|
235
286
|
}
|
@@ -251,16 +302,20 @@ async function generate_link(provider, id){
|
|
251
302
|
buffer = new Buffer(id+"LTXs3GrU8we9O"+enc_id)
|
252
303
|
let ani_id = buffer.toString("base64")
|
253
304
|
buffer = Buffer.from((await curl(`${base_url}/api/live${ani_id}`, "GET", true)).split("#")[1], "base64")
|
254
|
-
if (config.player === "
|
255
|
-
return
|
305
|
+
if (config.player === "BROWSER"){
|
306
|
+
return `${base_url}/api/live${ani_id}`
|
256
307
|
}
|
308
|
+
return buffer.toString("utf-8") //TODO m3u8 player
|
257
309
|
|
258
|
-
|
310
|
+
|
259
311
|
}
|
260
312
|
}
|
261
313
|
|
262
|
-
async function post_play(link, anime
|
314
|
+
async function post_play(link, anime){
|
263
315
|
while (true){
|
316
|
+
config.most_recent = anime
|
317
|
+
write_config()
|
318
|
+
|
264
319
|
console.log(colors.Yellow, `Playing episode ${anime.episode_number+1} of ${anime.anime_id.replaceAll("-", " ")}\n`)
|
265
320
|
console.log(colors.Cyan, "1/l) Show Link")
|
266
321
|
console.log(colors.Cyan, "2/n) Next Episode")
|
@@ -282,7 +337,7 @@ async function post_play(link, anime, player="VLC"){
|
|
282
337
|
}
|
283
338
|
anime.episode_number += 1
|
284
339
|
link = await get_video_link(anime.episodes[anime.episode_number])
|
285
|
-
await play(link, anime
|
340
|
+
await play(link, anime)
|
286
341
|
process.exit()
|
287
342
|
break
|
288
343
|
//EVEN MORE NEEDLESS QUIT STATEMENTS!!!!!!
|
@@ -295,7 +350,7 @@ async function post_play(link, anime, player="VLC"){
|
|
295
350
|
}
|
296
351
|
anime.episode_number -= 1
|
297
352
|
link = await get_video_link(anime.episodes[anime.episode_number])
|
298
|
-
await play(link, anime
|
353
|
+
await play(link, anime)
|
299
354
|
process.exit()
|
300
355
|
break
|
301
356
|
case "q":
|
@@ -308,10 +363,10 @@ async function post_play(link, anime, player="VLC"){
|
|
308
363
|
}
|
309
364
|
}
|
310
365
|
|
311
|
-
async function play(link, anime
|
366
|
+
async function play(link, anime){
|
312
367
|
console.clear()
|
313
368
|
console.log(colors.Blue, "ANI-CLI-NPM \n")
|
314
|
-
if (player === "VLC"){
|
369
|
+
if (config.player === "VLC"){
|
315
370
|
console.log(colors.Yellow, "Loading VLC... ")
|
316
371
|
let player = new PlayerController({
|
317
372
|
app: 'vlc',
|
@@ -325,12 +380,12 @@ async function play(link, anime, player="VLC"){
|
|
325
380
|
process.exit()
|
326
381
|
|
327
382
|
|
328
|
-
}else if (player === "BROWSER"){
|
383
|
+
}else if (config.player === "BROWSER"){
|
329
384
|
console.log(colors.Yellow, "Opening video in browser... ")
|
330
385
|
open(link)
|
331
|
-
await post_play(link, anime
|
386
|
+
await post_play(link, anime)
|
332
387
|
process.exit()
|
333
|
-
}else if (player === "MPV"){
|
388
|
+
}else if (config.player === "MPV"){
|
334
389
|
console.log(colors.Yellow, "Loading MPV... ")
|
335
390
|
let player = new PlayerController({
|
336
391
|
app: 'mpv',
|
@@ -340,7 +395,7 @@ async function play(link, anime, player="VLC"){
|
|
340
395
|
await player.launch(err => {
|
341
396
|
if(err) return console.error(err.message);
|
342
397
|
});
|
343
|
-
await post_play(link, anime
|
398
|
+
await post_play(link, anime)
|
344
399
|
process.exit()
|
345
400
|
}
|
346
401
|
}
|
@@ -376,11 +431,11 @@ async function search(){
|
|
376
431
|
switch (choice){
|
377
432
|
case "p":
|
378
433
|
case "1":
|
379
|
-
await play(link, anime
|
434
|
+
await play(link, anime)
|
380
435
|
break
|
381
436
|
case "d":
|
382
437
|
case "2":
|
383
|
-
download(link, anime.anime_id+anime.episode_number+".mp4")
|
438
|
+
await download(link, anime.anime_id+anime.episode_number+".mp4")
|
384
439
|
break
|
385
440
|
case "l":
|
386
441
|
case "3":
|
@@ -394,21 +449,42 @@ async function search(){
|
|
394
449
|
}
|
395
450
|
|
396
451
|
|
397
|
-
|
398
452
|
console.clear()
|
399
|
-
|
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
|
+
}
|
400
458
|
async function main(){
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
459
|
+
if (config.player === "VLC"){
|
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")
|
461
|
+
}
|
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"])
|
405
471
|
switch (choice){
|
406
472
|
case "s":
|
407
473
|
case "1":
|
408
474
|
await search()
|
409
475
|
break
|
410
476
|
case "c":
|
411
|
-
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":
|
412
488
|
let temp = structuredClone(config);
|
413
489
|
let exit_code;
|
414
490
|
while (true) {
|
@@ -428,10 +504,15 @@ async function main(){
|
|
428
504
|
break
|
429
505
|
}
|
430
506
|
}
|
507
|
+
try{
|
508
|
+
fs.writeFileSync(getAppDataPath()+"/ani-cli-npm.conf", JSON.stringify(config))
|
509
|
+
}catch{
|
510
|
+
console.log(colors.Red, "Error writing to .conf file.")
|
511
|
+
}
|
431
512
|
await main()
|
432
513
|
break
|
433
514
|
case "q":
|
434
|
-
case
|
515
|
+
case 4:
|
435
516
|
console.log(colors.Black, "Exiting...")
|
436
517
|
process.exit()
|
437
518
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "ani-cli-npm",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.3.0",
|
4
4
|
"description": "ani-cli tool rewritten as npm package",
|
5
5
|
"main": "index.js",
|
6
6
|
"scripts": {
|
@@ -24,6 +24,7 @@
|
|
24
24
|
"multiply": "bin/index.js"
|
25
25
|
},
|
26
26
|
"dependencies": {
|
27
|
+
"appdata-path": "^1.0.0",
|
27
28
|
"media-player-controller": "^1.5.3",
|
28
29
|
"node-fetch": "^2.6.6",
|
29
30
|
"open": "^8.4.0",
|