ani-cli-npm 1.0.2 → 1.0.3
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/bin/index.js +175 -35
- package/package.json +2 -1
package/bin/index.js
CHANGED
@@ -1,14 +1,26 @@
|
|
1
1
|
#! /usr/bin/env node
|
2
2
|
|
3
|
+
const {emitWarning} = process;
|
4
|
+
|
5
|
+
process.emitWarning = (warning, ...args) => {
|
6
|
+
if (args[0] === 'ExperimentalWarning') {
|
7
|
+
return;
|
8
|
+
}
|
9
|
+
|
10
|
+
if (args[0] && typeof args[0] === 'object' && args[0].type === 'ExperimentalWarning') {
|
11
|
+
return;
|
12
|
+
}
|
13
|
+
|
14
|
+
return emitWarning(warning, ...args);
|
15
|
+
};
|
16
|
+
|
3
17
|
const VLC = require('vlc-simple-player');
|
18
|
+
const open = require("open")
|
4
19
|
const prompt = require("simple-input");
|
5
20
|
const fs = require("fs");
|
6
|
-
//const HttpsProxyAgent = require('https-proxy-agent');
|
7
|
-
//const proxyAgent = new HttpsProxyAgent("68.183.230.116:3951");
|
8
21
|
|
9
22
|
const gogohd_url="https://gogohd.net/"
|
10
23
|
const base_url="https://animixplay.to"
|
11
|
-
|
12
24
|
const colors = {
|
13
25
|
Black: "\x1b[30m%s\x1b[0m",
|
14
26
|
Red: "\x1b[31m%s\x1b[0m",
|
@@ -19,12 +31,56 @@ const colors = {
|
|
19
31
|
Cyan: "\x1b[36m%s\x1b[0m",
|
20
32
|
White: "\x1b[37m%s\x1b[0m"
|
21
33
|
}
|
22
|
-
|
23
34
|
let config = {
|
24
|
-
|
25
|
-
|
35
|
+
player: "VLC",
|
36
|
+
proxy: "",
|
37
|
+
user_agent: 'Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/100.0'
|
26
38
|
}
|
27
39
|
|
40
|
+
const HttpsProxyAgent = require('https-proxy-agent');
|
41
|
+
let proxyAgent = new HttpsProxyAgent(config.proxy);
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
async function config_(temp){
|
47
|
+
console.clear()
|
48
|
+
console.log(colors.Blue, "ANI-CLI-NPM \n")
|
49
|
+
console.log(colors.Yellow, "Config:\n")
|
50
|
+
console.log(colors.Cyan, `1) Player; ${temp.player}`)
|
51
|
+
console.log(colors.Cyan, `2) Proxy; ${temp.proxy}`)
|
52
|
+
console.log(colors.Cyan, `3) User agent; ${temp.user_agent}`)
|
53
|
+
console.log(colors.Cyan, "4) Save and Quit")
|
54
|
+
console.log(colors.Cyan, "5) Quit without saving changes")
|
55
|
+
let choice = parseInt(await input(""));
|
56
|
+
switch (choice){
|
57
|
+
case 1:
|
58
|
+
console.log(colors.Cyan, `1) VLC (default)`)
|
59
|
+
console.log(colors.Cyan, `2) Browser`)
|
60
|
+
let player = parseInt(await(input("New Player;")))
|
61
|
+
switch (player){
|
62
|
+
case 1:
|
63
|
+
temp.player = "VLC"
|
64
|
+
break
|
65
|
+
case 2:
|
66
|
+
temp.player = "BROWSER"
|
67
|
+
break
|
68
|
+
}
|
69
|
+
return temp,0
|
70
|
+
case 2:
|
71
|
+
temp.proxy = (await(input("New Proxy;"))).replace(" ", "")
|
72
|
+
return temp, 0
|
73
|
+
case 3:
|
74
|
+
temp.user_agent = await(input("New User agent;"))
|
75
|
+
return temp, 0
|
76
|
+
case 4:
|
77
|
+
return temp, 1
|
78
|
+
case 5:
|
79
|
+
return temp, 2
|
80
|
+
}
|
81
|
+
}
|
82
|
+
|
83
|
+
|
28
84
|
async function input(message){
|
29
85
|
if (message){
|
30
86
|
console.log(colors.Magenta,message)
|
@@ -32,11 +88,12 @@ async function input(message){
|
|
32
88
|
return await prompt(">")
|
33
89
|
}
|
34
90
|
|
91
|
+
|
35
92
|
async function curl(url, method="GET"){
|
36
93
|
await fetch(url, {
|
37
|
-
|
94
|
+
"agent": proxyAgent,
|
38
95
|
"headers": {
|
39
|
-
'User-Agent':
|
96
|
+
'User-Agent': config.user_agent,
|
40
97
|
"X-Requested-With": "XMLHttpRequest"
|
41
98
|
},
|
42
99
|
"referrerPolicy": "origin",
|
@@ -67,8 +124,7 @@ function matchRuleShort(str, rule) {
|
|
67
124
|
|
68
125
|
async function search_anime(search){
|
69
126
|
let filter = "*<ahref=\"/category/*\"title=\"*\">"
|
70
|
-
|
71
|
-
let html = (await curl("https://gogoanime.lu//search.html?keyword="+search)).split("\n")
|
127
|
+
let html = (await curl("https://gogoanime.dk//search.html?keyword="+search)).split("\n")
|
72
128
|
let lines = []
|
73
129
|
for (x in html){
|
74
130
|
html[x] = html[x].replace(/ /g,'').replace(/\t/g,'')
|
@@ -78,7 +134,10 @@ async function search_anime(search){
|
|
78
134
|
lines.push(html[x])
|
79
135
|
}
|
80
136
|
}
|
81
|
-
lines
|
137
|
+
if (!lines[0]){
|
138
|
+
lines.pop()
|
139
|
+
}
|
140
|
+
|
82
141
|
|
83
142
|
return lines
|
84
143
|
}
|
@@ -125,12 +184,13 @@ async function selection(options, prompt){
|
|
125
184
|
|
126
185
|
|
127
186
|
async function process_search(query) {
|
128
|
-
console.log("Searching: "+query)
|
187
|
+
console.log(colors.Yellow, "Searching: "+query)
|
129
188
|
|
130
189
|
let search_results = await search_anime(query)
|
131
190
|
if (!search_results[0]) {
|
132
|
-
console.log("No results.")
|
133
|
-
|
191
|
+
console.log(colors.Red, "No results.")
|
192
|
+
await main()
|
193
|
+
process.exit()
|
134
194
|
} else {
|
135
195
|
for (x in search_results) {
|
136
196
|
console.log(colors.Cyan,`${parseInt(x)+1})${" ".repeat(((search_results.length).toString().length+1)-((parseInt(x)+1).toString().length))}${search_results[x].replaceAll("-", " ")}`)
|
@@ -139,8 +199,10 @@ async function process_search(query) {
|
|
139
199
|
|
140
200
|
let anime_id = search_results[await selection(search_results.length, "Please select an anime.")-1]
|
141
201
|
let episodes = await episode_list(anime_id)
|
142
|
-
let episode_number =
|
143
|
-
|
202
|
+
let episode_number = 0;
|
203
|
+
if (episodes.length > 1){
|
204
|
+
episode_number = (await selection(episodes.length, `Please select an episode (1-${episodes.length}).`))-1
|
205
|
+
}
|
144
206
|
return {
|
145
207
|
anime_id: anime_id,
|
146
208
|
episodes: episodes,
|
@@ -153,21 +215,24 @@ async function get_video_link(episode_dpage){
|
|
153
215
|
let id = episode_dpage.replace("//gogohd.net/streaming.php?id=","")
|
154
216
|
id = id.slice(0, id.indexOf("="))
|
155
217
|
|
156
|
-
|
157
|
-
return await generate_link(1, html)
|
218
|
+
return await generate_link(1,id)
|
158
219
|
}
|
159
220
|
|
160
221
|
|
161
|
-
async function generate_link(provider,
|
222
|
+
async function generate_link(provider, id){
|
223
|
+
let html = ""
|
224
|
+
let provider_name = ""
|
162
225
|
switch (provider) {
|
163
226
|
case 1:
|
164
|
-
|
165
|
-
|
227
|
+
html = await curl(`${gogohd_url}streaming.php?id=${id}`)
|
228
|
+
provider_name = 'Xstreamcdn'
|
229
|
+
console.log(colors.Yellow, `Fetching ${provider_name} links...`)
|
166
230
|
html = html.split("\n")
|
167
231
|
let fb_id = ""
|
168
232
|
for (x in html){
|
169
233
|
if (matchRuleShort(html[x], "*<li class=\"linkserver\" data-status=\"1\" data-video=\"https://fembed9hd.com/v/*")){
|
170
234
|
fb_id = html[x].slice(html[x].indexOf("/v/")+3, html[x].indexOf("\">X"))
|
235
|
+
break
|
171
236
|
}
|
172
237
|
}
|
173
238
|
if (!fb_id){
|
@@ -180,45 +245,103 @@ async function generate_link(provider, html){
|
|
180
245
|
post = post.slice(post.indexOf(",\"data\":[{\"file\":\"")+18, post.length)
|
181
246
|
post = post.slice(0, post.indexOf("\"")).replaceAll("\\/","/")
|
182
247
|
return post
|
248
|
+
/*case 2:
|
249
|
+
provider_name = 'Animixplay'
|
250
|
+
console.log(`${base_url}/api/live/${"TkRBMk9EVT1MVFhzM0dyVTh3ZTlPVGtSQk1rOUVWVDA9"}`)
|
251
|
+
console.log(colors.Yellow, `Fetching ${provider_name} links...`)
|
252
|
+
let refr="$base_url"
|
253
|
+
let links = []
|
254
|
+
html = (await curl(`${base_url}/api/live/${"Some variable?"}`)).split("\n") // this needs fixed for alot of bigger titles to work.
|
255
|
+
for (x in html){
|
256
|
+
console.log(html[x])
|
257
|
+
}
|
258
|
+
*/
|
259
|
+
|
260
|
+
|
183
261
|
}
|
184
262
|
}
|
185
263
|
|
186
264
|
|
187
|
-
async function
|
265
|
+
async function get_video_quality_m3u8(){
|
266
|
+
console.log(colors.Red, "Not sure how you even got to this function? Its not implemented yet.")
|
267
|
+
}
|
268
|
+
|
269
|
+
|
270
|
+
async function play(link, anime, player="VLC"){
|
188
271
|
console.clear()
|
272
|
+
console.log(colors.Blue, "ANI-CLI-NPM \n")
|
189
273
|
if (player === "VLC"){
|
190
274
|
console.log(colors.Yellow, "Loading VLC... ")
|
191
275
|
let player = new VLC(link)
|
192
|
-
console.log(colors.
|
193
|
-
console.log("VLC;")
|
276
|
+
console.log(colors.Blue, `Playing episode ${anime.episode_number+1} of ${anime.anime_id.replaceAll("-", " ")}`)
|
194
277
|
console.log(colors.Cyan, "1) Show Link")
|
195
278
|
console.log(colors.Cyan, "2) Quit")
|
196
279
|
choice = parseInt(await input("select;"))
|
197
280
|
switch (choice){
|
198
281
|
case 1:
|
282
|
+
console.clear()
|
283
|
+
console.log(colors.Blue, "ANI-CLI-NPM \n")
|
284
|
+
console.log
|
199
285
|
console.log(colors.Yellow, "Link: "+link)
|
200
286
|
break
|
201
287
|
case 2:
|
202
288
|
process.exit()
|
203
289
|
break
|
204
290
|
}
|
205
|
-
|
206
|
-
|
291
|
+
console.log(colors.Cyan, "1) Quit")
|
292
|
+
choice = parseInt(await input("select;"))
|
293
|
+
switch (choice){
|
294
|
+
case 1:
|
295
|
+
process.exit()
|
296
|
+
break
|
297
|
+
}
|
298
|
+
}else if (player === "BROWSER"){
|
299
|
+
console.log(colors.Yellow, "Opening video in browser... ")
|
300
|
+
open(link)
|
301
|
+
console.log(colors.Yellow, `Playing episode ${anime.episode_number+1} of ${anime.anime_id.replace("-", " ")}\n`)
|
302
|
+
console.log(colors.Cyan, "1) Show Link")
|
303
|
+
console.log(colors.Cyan, "2) Quit")
|
304
|
+
choice = parseInt(await input("select;"))
|
305
|
+
switch (choice){
|
306
|
+
case 1:
|
307
|
+
console.clear()
|
308
|
+
console.log(colors.Blue, "ANI-CLI-NPM \n")
|
309
|
+
console.log(colors.Yellow, "Link: "+link)
|
310
|
+
break
|
311
|
+
case 2:
|
312
|
+
process.exit()
|
313
|
+
break
|
314
|
+
}
|
315
|
+
console.log(colors.Cyan, "1) Quit")
|
316
|
+
choice = parseInt(await input("select;"))
|
317
|
+
switch (choice){
|
318
|
+
case 1:
|
319
|
+
process.exit()
|
320
|
+
break
|
321
|
+
}
|
207
322
|
}
|
208
323
|
}
|
209
324
|
|
325
|
+
|
210
326
|
async function search(){
|
211
327
|
console.clear()
|
212
|
-
|
328
|
+
console.log(colors.Blue, "ANI-CLI-NPM \n")
|
329
|
+
console.log(colors.Magenta, "Search...")
|
213
330
|
let choice = await input("")
|
214
331
|
let anime = await process_search(choice)
|
215
|
-
|
216
332
|
console.log("\n")
|
217
333
|
|
218
334
|
console.log(colors.Blue, "Indexing video...")
|
219
335
|
let link = await get_video_link(anime.episodes[anime.episode_number])
|
220
336
|
console.clear()
|
221
|
-
|
337
|
+
console.log(colors.Blue, "ANI-CLI-NPM \n")
|
338
|
+
if (!link){
|
339
|
+
console.log(colors.Red, "Np link for this episode found?")
|
340
|
+
console.log(colors.Yellow, "^ at current this is due to not all of the required video repos being implemented.")
|
341
|
+
console.log(colors.Yellow, "Sorry for any inconvenience, this should soon by implemented. We appreciate your patience.")
|
342
|
+
process.exit()
|
343
|
+
}
|
344
|
+
console.log(colors.Blue, `Episode ${anime.episode_number+1} of ${anime.anime_id.replace("-", " ")} found.\n`)
|
222
345
|
console.log(colors.Cyan, "1) Play")
|
223
346
|
console.log(colors.Cyan, "2) Download")
|
224
347
|
console.log(colors.Cyan, "3) Show Link")
|
@@ -226,7 +349,7 @@ async function search(){
|
|
226
349
|
choice = parseInt(await input("select;"))
|
227
350
|
switch (choice){
|
228
351
|
case 1:
|
229
|
-
await play(link, config.player)
|
352
|
+
await play(link, anime, config.player)
|
230
353
|
break
|
231
354
|
case 2:
|
232
355
|
download(link, anime.anime_id+anime.episode_number+".mp4")
|
@@ -237,15 +360,12 @@ async function search(){
|
|
237
360
|
case 4:
|
238
361
|
process.exit()
|
239
362
|
}
|
240
|
-
|
241
|
-
|
242
|
-
|
243
363
|
}
|
244
364
|
|
245
365
|
|
366
|
+
console.clear()
|
367
|
+
console.log(colors.Blue, "Welcome to Ani-Cli-npm")
|
246
368
|
async function main(){
|
247
|
-
console.clear()
|
248
|
-
console.log(colors.Blue, "Welcome to Ani-Cli-npm")
|
249
369
|
console.log(colors.Cyan, "1) Search")
|
250
370
|
console.log(colors.Cyan, "2) config")
|
251
371
|
console.log(colors.Cyan, "3) quit")
|
@@ -256,6 +376,26 @@ async function main(){
|
|
256
376
|
await search()
|
257
377
|
break
|
258
378
|
case 2:
|
379
|
+
let temp = structuredClone(config);
|
380
|
+
let exit_code;
|
381
|
+
while (true) {
|
382
|
+
temp, exit_code = await config_(temp)
|
383
|
+
if (exit_code === 1) {
|
384
|
+
config = temp
|
385
|
+
proxyAgent = new HttpsProxyAgent(config.proxy);
|
386
|
+
console.clear()
|
387
|
+
console.log(colors.Blue, "ANI-CLI-NPM \n")
|
388
|
+
console.log(colors.Yellow, "Config changed.")
|
389
|
+
break
|
390
|
+
} else if (exit_code === 2) {
|
391
|
+
temp = config
|
392
|
+
console.clear()
|
393
|
+
console.log(colors.Blue, "ANI-CLI-NPM \n")
|
394
|
+
console.log(colors.Yellow, "Config changes disregarded.")
|
395
|
+
break
|
396
|
+
}
|
397
|
+
}
|
398
|
+
await main()
|
259
399
|
break
|
260
400
|
case 3:
|
261
401
|
console.log(colors.Black, "Exiting...")
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "ani-cli-npm",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.3",
|
4
4
|
"description": "ani-cli tool rewritten as npm package",
|
5
5
|
"main": "index.js",
|
6
6
|
"scripts": {
|
@@ -21,6 +21,7 @@
|
|
21
21
|
"dependencies": {
|
22
22
|
"http-proxy-agent": "^5.0.0",
|
23
23
|
"https-proxy-agent": "^5.0.1",
|
24
|
+
"open": "^8.4.0",
|
24
25
|
"simple-input": "^1.0.1",
|
25
26
|
"vlc-simple-player": "^0.5.1"
|
26
27
|
}
|