ani-cli-npm 1.0.1 → 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 -38
- package/package.json +2 -2
package/bin/index.js
CHANGED
@@ -1,16 +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 downloadsFolder = require('downloads-folder');
|
7
|
-
//const HttpsProxyAgent = require('https-proxy-agent');
|
8
|
-
//const proxyAgent = new HttpsProxyAgent("68.183.230.116:3951");
|
9
21
|
|
10
|
-
const download_dir = downloadsFolder()
|
11
22
|
const gogohd_url="https://gogohd.net/"
|
12
23
|
const base_url="https://animixplay.to"
|
13
|
-
|
14
24
|
const colors = {
|
15
25
|
Black: "\x1b[30m%s\x1b[0m",
|
16
26
|
Red: "\x1b[31m%s\x1b[0m",
|
@@ -21,13 +31,56 @@ const colors = {
|
|
21
31
|
Cyan: "\x1b[36m%s\x1b[0m",
|
22
32
|
White: "\x1b[37m%s\x1b[0m"
|
23
33
|
}
|
24
|
-
|
25
34
|
let config = {
|
26
|
-
|
27
|
-
|
28
|
-
|
35
|
+
player: "VLC",
|
36
|
+
proxy: "",
|
37
|
+
user_agent: 'Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/100.0'
|
29
38
|
}
|
30
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
|
+
|
31
84
|
async function input(message){
|
32
85
|
if (message){
|
33
86
|
console.log(colors.Magenta,message)
|
@@ -35,11 +88,12 @@ async function input(message){
|
|
35
88
|
return await prompt(">")
|
36
89
|
}
|
37
90
|
|
91
|
+
|
38
92
|
async function curl(url, method="GET"){
|
39
93
|
await fetch(url, {
|
40
|
-
|
94
|
+
"agent": proxyAgent,
|
41
95
|
"headers": {
|
42
|
-
'User-Agent':
|
96
|
+
'User-Agent': config.user_agent,
|
43
97
|
"X-Requested-With": "XMLHttpRequest"
|
44
98
|
},
|
45
99
|
"referrerPolicy": "origin",
|
@@ -70,8 +124,7 @@ function matchRuleShort(str, rule) {
|
|
70
124
|
|
71
125
|
async function search_anime(search){
|
72
126
|
let filter = "*<ahref=\"/category/*\"title=\"*\">"
|
73
|
-
|
74
|
-
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")
|
75
128
|
let lines = []
|
76
129
|
for (x in html){
|
77
130
|
html[x] = html[x].replace(/ /g,'').replace(/\t/g,'')
|
@@ -81,7 +134,10 @@ async function search_anime(search){
|
|
81
134
|
lines.push(html[x])
|
82
135
|
}
|
83
136
|
}
|
84
|
-
lines
|
137
|
+
if (!lines[0]){
|
138
|
+
lines.pop()
|
139
|
+
}
|
140
|
+
|
85
141
|
|
86
142
|
return lines
|
87
143
|
}
|
@@ -128,12 +184,13 @@ async function selection(options, prompt){
|
|
128
184
|
|
129
185
|
|
130
186
|
async function process_search(query) {
|
131
|
-
console.log("Searching: "+query)
|
187
|
+
console.log(colors.Yellow, "Searching: "+query)
|
132
188
|
|
133
189
|
let search_results = await search_anime(query)
|
134
190
|
if (!search_results[0]) {
|
135
|
-
console.log("No results.")
|
136
|
-
|
191
|
+
console.log(colors.Red, "No results.")
|
192
|
+
await main()
|
193
|
+
process.exit()
|
137
194
|
} else {
|
138
195
|
for (x in search_results) {
|
139
196
|
console.log(colors.Cyan,`${parseInt(x)+1})${" ".repeat(((search_results.length).toString().length+1)-((parseInt(x)+1).toString().length))}${search_results[x].replaceAll("-", " ")}`)
|
@@ -142,8 +199,10 @@ async function process_search(query) {
|
|
142
199
|
|
143
200
|
let anime_id = search_results[await selection(search_results.length, "Please select an anime.")-1]
|
144
201
|
let episodes = await episode_list(anime_id)
|
145
|
-
let episode_number =
|
146
|
-
|
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
|
+
}
|
147
206
|
return {
|
148
207
|
anime_id: anime_id,
|
149
208
|
episodes: episodes,
|
@@ -156,21 +215,24 @@ async function get_video_link(episode_dpage){
|
|
156
215
|
let id = episode_dpage.replace("//gogohd.net/streaming.php?id=","")
|
157
216
|
id = id.slice(0, id.indexOf("="))
|
158
217
|
|
159
|
-
|
160
|
-
return await generate_link(1, html)
|
218
|
+
return await generate_link(1,id)
|
161
219
|
}
|
162
220
|
|
163
221
|
|
164
|
-
async function generate_link(provider,
|
222
|
+
async function generate_link(provider, id){
|
223
|
+
let html = ""
|
224
|
+
let provider_name = ""
|
165
225
|
switch (provider) {
|
166
226
|
case 1:
|
167
|
-
|
168
|
-
|
227
|
+
html = await curl(`${gogohd_url}streaming.php?id=${id}`)
|
228
|
+
provider_name = 'Xstreamcdn'
|
229
|
+
console.log(colors.Yellow, `Fetching ${provider_name} links...`)
|
169
230
|
html = html.split("\n")
|
170
231
|
let fb_id = ""
|
171
232
|
for (x in html){
|
172
233
|
if (matchRuleShort(html[x], "*<li class=\"linkserver\" data-status=\"1\" data-video=\"https://fembed9hd.com/v/*")){
|
173
234
|
fb_id = html[x].slice(html[x].indexOf("/v/")+3, html[x].indexOf("\">X"))
|
235
|
+
break
|
174
236
|
}
|
175
237
|
}
|
176
238
|
if (!fb_id){
|
@@ -183,45 +245,103 @@ async function generate_link(provider, html){
|
|
183
245
|
post = post.slice(post.indexOf(",\"data\":[{\"file\":\"")+18, post.length)
|
184
246
|
post = post.slice(0, post.indexOf("\"")).replaceAll("\\/","/")
|
185
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
|
+
|
186
261
|
}
|
187
262
|
}
|
188
263
|
|
189
264
|
|
190
|
-
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"){
|
191
271
|
console.clear()
|
272
|
+
console.log(colors.Blue, "ANI-CLI-NPM \n")
|
192
273
|
if (player === "VLC"){
|
193
274
|
console.log(colors.Yellow, "Loading VLC... ")
|
194
275
|
let player = new VLC(link)
|
195
|
-
console.log(colors.
|
196
|
-
console.log("VLC;")
|
276
|
+
console.log(colors.Blue, `Playing episode ${anime.episode_number+1} of ${anime.anime_id.replaceAll("-", " ")}`)
|
197
277
|
console.log(colors.Cyan, "1) Show Link")
|
198
278
|
console.log(colors.Cyan, "2) Quit")
|
199
279
|
choice = parseInt(await input("select;"))
|
200
280
|
switch (choice){
|
201
281
|
case 1:
|
282
|
+
console.clear()
|
283
|
+
console.log(colors.Blue, "ANI-CLI-NPM \n")
|
284
|
+
console.log
|
202
285
|
console.log(colors.Yellow, "Link: "+link)
|
203
286
|
break
|
204
287
|
case 2:
|
205
288
|
process.exit()
|
206
289
|
break
|
207
290
|
}
|
208
|
-
|
209
|
-
|
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
|
+
}
|
210
322
|
}
|
211
323
|
}
|
212
324
|
|
325
|
+
|
213
326
|
async function search(){
|
214
327
|
console.clear()
|
215
|
-
|
328
|
+
console.log(colors.Blue, "ANI-CLI-NPM \n")
|
329
|
+
console.log(colors.Magenta, "Search...")
|
216
330
|
let choice = await input("")
|
217
331
|
let anime = await process_search(choice)
|
218
|
-
|
219
332
|
console.log("\n")
|
220
333
|
|
221
334
|
console.log(colors.Blue, "Indexing video...")
|
222
335
|
let link = await get_video_link(anime.episodes[anime.episode_number])
|
223
336
|
console.clear()
|
224
|
-
|
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`)
|
225
345
|
console.log(colors.Cyan, "1) Play")
|
226
346
|
console.log(colors.Cyan, "2) Download")
|
227
347
|
console.log(colors.Cyan, "3) Show Link")
|
@@ -229,7 +349,7 @@ async function search(){
|
|
229
349
|
choice = parseInt(await input("select;"))
|
230
350
|
switch (choice){
|
231
351
|
case 1:
|
232
|
-
await play(link, config.player)
|
352
|
+
await play(link, anime, config.player)
|
233
353
|
break
|
234
354
|
case 2:
|
235
355
|
download(link, anime.anime_id+anime.episode_number+".mp4")
|
@@ -240,15 +360,12 @@ async function search(){
|
|
240
360
|
case 4:
|
241
361
|
process.exit()
|
242
362
|
}
|
243
|
-
|
244
|
-
|
245
|
-
|
246
363
|
}
|
247
364
|
|
248
365
|
|
366
|
+
console.clear()
|
367
|
+
console.log(colors.Blue, "Welcome to Ani-Cli-npm")
|
249
368
|
async function main(){
|
250
|
-
console.clear()
|
251
|
-
console.log(colors.Blue, "Welcome to Ani-Cli-npm")
|
252
369
|
console.log(colors.Cyan, "1) Search")
|
253
370
|
console.log(colors.Cyan, "2) config")
|
254
371
|
console.log(colors.Cyan, "3) quit")
|
@@ -259,6 +376,26 @@ async function main(){
|
|
259
376
|
await search()
|
260
377
|
break
|
261
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()
|
262
399
|
break
|
263
400
|
case 3:
|
264
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": {
|
@@ -19,9 +19,9 @@
|
|
19
19
|
"multiply": "bin/index.js"
|
20
20
|
},
|
21
21
|
"dependencies": {
|
22
|
-
"downloads-folder": "^3.0.3",
|
23
22
|
"http-proxy-agent": "^5.0.0",
|
24
23
|
"https-proxy-agent": "^5.0.1",
|
24
|
+
"open": "^8.4.0",
|
25
25
|
"simple-input": "^1.0.1",
|
26
26
|
"vlc-simple-player": "^0.5.1"
|
27
27
|
}
|