ani-cli-npm 1.0.6 → 1.1.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/bin/index.js CHANGED
@@ -1,426 +1,425 @@
1
- #! /usr/bin/env node
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
-
17
- const VLC = require('vlc-simple-player');
18
- const open = require("open")
19
- const prompt = require("simple-input");
20
- const fs = require("fs");
21
- //const HttpsProxyAgent = require('https-proxy-agent');
22
- //const proxyAgent = new HttpsProxyAgent("68.183.230.116:3951");
23
-
24
- const gogohd_url="https://gogohd.net/"
25
- const base_url="https://animixplay.to"
26
- const colors = {
27
- Black: "\x1b[30m%s\x1b[0m",
28
- Red: "\x1b[31m%s\x1b[0m",
29
- Green: "\x1b[32m%s\x1b[0m",
30
- Yellow: "\x1b[33m%s\x1b[0m",
31
- Blue: "\x1b[34m%s\x1b[0m",
32
- Magenta: "\x1b[35m%s\x1b[0m",
33
- Cyan: "\x1b[36m%s\x1b[0m",
34
- White: "\x1b[37m%s\x1b[0m"
35
- }
36
- let config = {
37
- player: "VLC",
38
- proxy: "",
39
- user_agent: 'Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/100.0'
40
- }
41
-
42
- const HttpsProxyAgent = require('https-proxy-agent');
43
- let proxyAgent = new HttpsProxyAgent(config.proxy);
44
-
45
-
46
-
47
-
48
- async function config_(temp){
49
- console.clear()
50
- console.log(colors.Blue, "ANI-CLI-NPM \n")
51
- console.log(colors.Yellow, "Config:\n")
52
- console.log(colors.Cyan, `1) Player; ${temp.player}`)
53
- console.log(colors.Cyan, `2) Proxy; ${temp.proxy}`)
54
- console.log(colors.Cyan, `3) User agent; ${temp.user_agent}`)
55
- console.log(colors.Cyan, "4) Save and exit")
56
- console.log(colors.Cyan, "5) Exit without saving changes")
57
- let choice = parseInt(await input(""));
58
- switch (choice){
59
- case 1:
60
- console.log(colors.Cyan, `1) VLC (default)`)
61
- console.log(colors.Cyan, `2) Browser`)
62
- let player = parseInt(await(input("New Player;")))
63
- switch (player){
64
- case 1:
65
- temp.player = "VLC"
66
- break
67
- case 2:
68
- temp.player = "BROWSER"
69
- break
70
- }
71
- return temp,0
72
- case 2:
73
- temp.proxy = (await(input("New Proxy;"))).replaceAll(" ", "")
74
- return temp, 0
75
- case 3:
76
- temp.user_agent = await(input("New User agent;"))
77
- return temp, 0
78
- case 4:
79
- return temp, 1
80
- case 5:
81
- return temp, 2
82
- }
83
- }
84
-
85
-
86
- async function input(message){
87
- if (message){
88
- console.log(colors.Magenta,message)
89
- }
90
- return await prompt(">")
91
- }
92
-
93
-
94
- async function curl(url, method="GET"){
95
- try{
96
- await fetch(url, {
97
- //"agent": proxyAgent,
98
- "headers": {
99
- 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/100.0',
100
- "X-Requested-With": "XMLHttpRequest"
101
- },
102
- "referrerPolicy": "origin",
103
- "body": null,
104
- "method": method,
105
- "proxy": "68.183.230.116:3951"
106
- }).then(function (response) {
107
- return response.text();
108
- }).then(function (html) {
109
- fs.writeFileSync("./temp.txt", html, function(err) {
110
- if(err) {
111
- return console.log(err);
112
- }
113
- });
114
- }).catch(async function(err) {
115
- console.warn(colors.Red, `Something went wrong connecting to ${url}.`);
116
- await search();
117
- process.exit()
118
- });
119
-
120
- return fs.readFileSync("./temp.txt").toString()
121
- }catch{
122
- console.log(colors.Red, "Something went wrong in curl()")
123
- await main()
124
- }
125
-
126
- }
127
-
128
-
129
- function matchRuleShort(str, rule) {
130
- let escapeRegex = (str) => str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
131
- return new RegExp("^" + rule.split("*").map(escapeRegex).join(".*") + "$").test(str);
132
- }
133
-
134
-
135
- async function search_anime(search){
136
- let filter = "*<ahref=\"/category/*\"title=\"*\">"
137
- let html = (await curl("https://gogoanime.dk//search.html?keyword="+search)).split("\n")
138
- let lines = []
139
- for (x in html){
140
- html[x] = html[x].replaceAll(/ /g,'').replaceAll(/\t/g,'')
141
- if (matchRuleShort(html[x], filter)){
142
- html[x] = html[x].slice(html[x].indexOf("/category/")+10);
143
- html[x] = html[x].slice(0, html[x].indexOf("\"title="));
144
- lines.push(html[x])
145
- }
146
- }
147
- if (!lines[0]){
148
- lines.pop()
149
- }
150
-
151
-
152
- return lines
153
- }
154
-
155
-
156
- async function episode_list(anime_id){
157
- let html = (await curl(base_url+"/v1/"+anime_id)).split("\n")
158
- let lines = ""
159
-
160
- for (let x in html){
161
- if(matchRuleShort(html[x], "*<div id=\"epslistplace\"*")){
162
- lines = (html[x])
163
- }
164
- }
165
-
166
- lines = lines.slice(55, lines.length).replace("}</div>", "")
167
- lines = "{" + lines.slice(lines.indexOf(",")+1, lines.length) + "}"
168
- lines = JSON.parse(lines)
169
-
170
- let json = []
171
- for (x in lines){
172
- json.push(lines[x])
173
- }
174
- return json
175
- }
176
-
177
-
178
- async function download(url, name){
179
- 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.")
180
- }
181
-
182
-
183
- async function selection(options, prompt){
184
- let selection = 0
185
- while (!(selection <= options && selection > 1)){
186
- selection = (await input(prompt))
187
- if (selection <= options && selection >= 1){
188
- break
189
- }
190
- console.log(colors.Red,`Please input a valid option.`)
191
- }
192
- return selection
193
- }
194
-
195
-
196
- async function process_search(query) {
197
- console.log(colors.Yellow, "Searching: "+query)
198
-
199
- let search_results = await search_anime(query)
200
- if (!search_results[0]) {
201
- console.log(colors.Red, "No results.")
202
- await main()
203
- process.exit()
204
- } else {
205
- for (x in search_results) {
206
- console.log(colors.Cyan,`${parseInt(x)+1})${" ".repeat(((search_results.length).toString().length+1)-((parseInt(x)+1).toString().length))}${search_results[x].replaceAll("-", " ")}`)
207
- }
208
- }
209
-
210
- let anime_id = search_results[await selection(search_results.length, "Please select an anime.")-1]
211
- let episodes = await episode_list(anime_id)
212
- let episode_number = 0;
213
- if (episodes.length > 1){
214
- episode_number = (await selection(episodes.length, `Please select an episode (1-${episodes.length}).`))-1
215
- }
216
- return {
217
- anime_id: anime_id,
218
- episodes: episodes,
219
- episode_number: episode_number
220
- }
221
- }
222
-
223
-
224
- async function get_video_link(episode_dpage){
225
- let id = episode_dpage.replace("//gogohd.net/streaming.php?id=","")
226
- id = id.slice(0, id.indexOf("="))
227
-
228
- return await generate_link(1,id)
229
- }
230
-
231
-
232
- async function generate_link(provider, id){
233
- let html = ""
234
- let provider_name = ""
235
- switch (provider) {
236
- case 1:
237
- html = await curl(`${gogohd_url}streaming.php?id=${id}`)
238
- provider_name = 'Xstreamcdn'
239
- console.log(colors.Yellow, `Fetching ${provider_name} links...`)
240
- html = html.split("\n")
241
- let fb_id = ""
242
- for (x in html){
243
- if (matchRuleShort(html[x], "*<li class=\"linkserver\" data-status=\"1\" data-video=\"https://fembed9hd.com/v/*")){
244
- fb_id = html[x].slice(html[x].indexOf("/v/")+3, html[x].indexOf("\">X"))
245
- break
246
- }
247
- }
248
- if (!fb_id){
249
- console.log("Error, no fb_id found.")
250
- return 0
251
- }
252
-
253
- //let refr = "https://fembed-hd.com/v/"+fb_id
254
- let post = await curl("https://fembed-hd.com/api/source/"+fb_id, "POST")
255
- post = post.slice(post.indexOf(",\"data\":[{\"file\":\"")+18, post.length)
256
- post = post.slice(0, post.indexOf("\"")).replaceAll("\\/","/")
257
- return post
258
- /*case 2:
259
- provider_name = 'Animixplay'
260
- console.log(`${base_url}/api/live/${"TkRBMk9EVT1MVFhzM0dyVTh3ZTlPVGtSQk1rOUVWVDA9"}`)
261
- console.log(colors.Yellow, `Fetching ${provider_name} links...`)
262
- let refr="$base_url"
263
- let links = []
264
- html = (await curl(`${base_url}/api/live/${"Some variable?"}`)).split("\n") // this needs fixed for alot of bigger titles to work.
265
- for (x in html){
266
- console.log(html[x])
267
- }
268
- */
269
-
270
-
271
- }
272
- }
273
-
274
-
275
- async function get_video_quality_m3u8(){
276
- console.log(colors.Red, "Not sure how you even got to this function? Its not implemented yet.")
277
- }
278
-
279
- async function post_play(link, anime, player="VLC"){
280
- while (true){
281
- console.log(colors.Yellow, `Playing episode ${anime.episode_number+1} of ${anime.anime_id.replaceAll("-", " ")}\n`)
282
- console.log(colors.Cyan, "1) Show Link")
283
- console.log(colors.Cyan, "2) Next Episode")
284
- console.log(colors.Cyan, "3) Prev Episode")
285
- console.log(colors.Cyan, "4) Quit")
286
- choice = parseInt(await input("select;"))
287
- switch (choice){
288
- case 1:
289
- console.clear()
290
- console.log(colors.Blue, "ANI-CLI-NPM \n")
291
- console.log(colors.Yellow, "Link: "+link)
292
- break
293
- case 2:
294
- if (anime.episode_number > anime.episodes.length-2){
295
- console.clear()
296
- console.log(colors.Red, "Damn, all out of episodes?")
297
- break
298
- }
299
- anime.episode_number += 1
300
- link = await get_video_link(anime.episodes[anime.episode_number])
301
- await play(link, anime, config.player)
302
- process.exit()
303
- break
304
- //EVEN MORE NEEDLESS QUIT STATEMENTS!!!!!!
305
- case 3:
306
- if (anime.episode_number < 2){
307
- console.clear()
308
- console.log(colors.Red, "Error; Episode 0 is only available for premium members")
309
- break
310
- }
311
- anime.episode_number -= 1
312
- link = await get_video_link(anime.episodes[anime.episode_number])
313
- await play(link, anime, config.player)
314
- process.exit()
315
- break
316
- case 4:
317
- console.clear()
318
- await main()
319
- process.exit()
320
- break
321
- }
322
- }
323
- }
324
-
325
- async function play(link, anime, player="VLC"){
326
- console.clear()
327
- console.log(colors.Blue, "ANI-CLI-NPM \n")
328
- if (player === "VLC"){
329
- console.log(colors.Yellow, "Loading VLC... ")
330
- let player = new VLC(link)
331
- await post_play(link, anime)
332
- process.exit()
333
-
334
-
335
- }else if (player === "BROWSER"){
336
- console.log(colors.Yellow, "Opening video in browser... ")
337
- open(link)
338
- await post_play(link, anime, player)
339
- process.exit()
340
- }
341
- }
342
-
343
-
344
- async function search(){
345
- console.clear()
346
- console.log(colors.Blue, "ANI-CLI-NPM \n")
347
- console.log(colors.Magenta, "Search...")
348
- let choice = await input("")
349
- let anime = await process_search(choice)
350
-
351
- console.log("\n")
352
-
353
- console.log(colors.Blue, "Indexing video...")
354
- let link = await get_video_link(anime.episodes[anime.episode_number])
355
- console.clear()
356
- console.log(colors.Blue, "ANI-CLI-NPM \n")
357
- if (!link){
358
- console.log(colors.Red, "Np link for this episode found?")
359
- console.log(colors.Yellow, "^ at current this is due to not all of the required video repos being implemented.")
360
- console.log(colors.Yellow, "Sorry for any inconvenience, this should soon by implemented. We appreciate your patience.")
361
- process.exit()
362
- }
363
- console.log(colors.Blue, `Episode ${anime.episode_number+1} of ${anime.anime_id.replaceAll("-", " ")} found.\n`)
364
- console.log(colors.Cyan, "1) Play")
365
- console.log(colors.Cyan, "2) Download")
366
- console.log(colors.Cyan, "3) Show Link")
367
- console.log(colors.Cyan, "4) quit")
368
- choice = parseInt(await input("select;"))
369
- switch (choice){
370
- case 1:
371
- await play(link, anime, config.player)
372
- break
373
- case 2:
374
- download(link, anime.anime_id+anime.episode_number+".mp4")
375
- break
376
- case 3:
377
- console.log(colors.Yellow, "Link: "+link)
378
- break
379
- case 4:
380
- process.exit()
381
- }
382
- }
383
-
384
-
385
- console.clear()
386
- console.log(colors.Blue, "Welcome to Ani-Cli-npm")
387
- async function main(){
388
- console.log(colors.Cyan, "1) Search")
389
- console.log(colors.Cyan, "2) config")
390
- console.log(colors.Cyan, "3) quit")
391
- let choice = parseInt(await input("select;"))
392
-
393
- switch (choice){
394
- case 1:
395
- await search()
396
- break
397
- case 2:
398
- let temp = structuredClone(config);
399
- let exit_code;
400
- while (true) {
401
- temp, exit_code = await config_(temp)
402
- if (exit_code === 1) {
403
- config = temp
404
- proxyAgent = new HttpsProxyAgent(config.proxy);
405
- console.clear()
406
- console.log(colors.Blue, "ANI-CLI-NPM \n")
407
- console.log(colors.Yellow, "Config changed.")
408
- break
409
- } else if (exit_code === 2) {
410
- temp = config
411
- console.clear()
412
- console.log(colors.Blue, "ANI-CLI-NPM \n")
413
- console.log(colors.Yellow, "Config changes disregarded.")
414
- break
415
- }
416
- }
417
- await main()
418
- break
419
- case 3:
420
- console.log(colors.Black, "Exiting...")
421
- process.exit()
422
- }
423
- }
424
-
425
- main()
426
-
1
+ #! /usr/bin/env node
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
+
17
+ const VLC = require('vlc-simple-player');
18
+ const open = require("open")
19
+ const prompt = require("simple-input");
20
+ const fs = require("fs");
21
+ //const HttpsProxyAgent = require('https-proxy-agent');
22
+ //const proxyAgent = new HttpsProxyAgent("68.183.230.116:3951");
23
+
24
+ const gogohd_url="https://gogohd.net/"
25
+ const base_url="https://animixplay.to"
26
+ const colors = {
27
+ Black: "\x1b[30m%s\x1b[0m",
28
+ Red: "\x1b[31m%s\x1b[0m",
29
+ Green: "\x1b[32m%s\x1b[0m",
30
+ Yellow: "\x1b[33m%s\x1b[0m",
31
+ Blue: "\x1b[34m%s\x1b[0m",
32
+ Magenta: "\x1b[35m%s\x1b[0m",
33
+ Cyan: "\x1b[36m%s\x1b[0m",
34
+ White: "\x1b[37m%s\x1b[0m"
35
+ }
36
+ let config = {
37
+ player: "VLC",
38
+ proxy: "",
39
+ user_agent: 'Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/100.0'
40
+ }
41
+
42
+ const HttpsProxyAgent = require('https-proxy-agent');
43
+ let proxyAgent = new HttpsProxyAgent(config.proxy);
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 exit")
54
+ console.log(colors.Cyan, "5) Exit 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;"))).replaceAll(" ", "")
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
+ async function input(message){
84
+ if (message){
85
+ console.log(colors.Magenta,message)
86
+ }
87
+ return await prompt(">")
88
+ }
89
+
90
+ async function curl(url, method="GET"){
91
+ try{
92
+ await fetch(url, {
93
+ //"agent": proxyAgent,
94
+ "headers": {
95
+ 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/100.0',
96
+ "X-Requested-With": "XMLHttpRequest"
97
+ },
98
+ "referrerPolicy": "origin",
99
+ "body": null,
100
+ "method": method,
101
+ "proxy": "68.183.230.116:3951"
102
+ }).then(function (response) {
103
+ return response.text();
104
+ }).then(function (html) {
105
+ fs.writeFileSync("./temp.txt", html, function(err) {
106
+ if(err) {
107
+ return console.log(err);
108
+ }
109
+ });
110
+ }).catch(async function(err) {
111
+ console.warn(colors.Red, `Something went wrong connecting to ${url}.`);
112
+ await search();
113
+ process.exit()
114
+ });
115
+
116
+ return fs.readFileSync("./temp.txt").toString()
117
+ }catch{
118
+ console.log(colors.Red, "Something went wrong in curl()")
119
+ await main()
120
+ }
121
+
122
+ }
123
+
124
+ function matchRuleShort(str, rule) {
125
+ let escapeRegex = (str) => str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
126
+ return new RegExp("^" + rule.split("*").map(escapeRegex).join(".*") + "$").test(str);
127
+ }
128
+
129
+ async function search_anime(search){
130
+ let filter = "*<ahref=\"/category/*\"title=\"*\">"
131
+ let html = (await curl("https://gogoanime.dk//search.html?keyword="+search)).split("\n")
132
+ let lines = []
133
+ for (x in html){
134
+ html[x] = html[x].replaceAll(/ /g,'').replaceAll(/\t/g,'')
135
+ if (matchRuleShort(html[x], filter)){
136
+ html[x] = html[x].slice(html[x].indexOf("/category/")+10);
137
+ html[x] = html[x].slice(0, html[x].indexOf("\"title="));
138
+ lines.push(html[x])
139
+ }
140
+ }
141
+ if (!lines[0]){
142
+ lines.pop()
143
+ }
144
+
145
+
146
+ return lines
147
+ }
148
+
149
+ async function episode_list(anime_id){
150
+ let html = (await curl(base_url+"/v1/"+anime_id)).split("\n")
151
+ let lines = ""
152
+
153
+ for (let x in html){
154
+ if(matchRuleShort(html[x], "*<div id=\"epslistplace\"*")){
155
+ lines = (html[x])
156
+ }
157
+ }
158
+
159
+ lines = lines.slice(55, lines.length).replace("}</div>", "")
160
+ lines = "{" + lines.slice(lines.indexOf(",")+1, lines.length) + "}"
161
+ lines = JSON.parse(lines)
162
+
163
+ let json = []
164
+ for (x in lines){
165
+ json.push(lines[x])
166
+ }
167
+ return json
168
+ }
169
+
170
+ async function download(url, name){
171
+ 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.")
172
+ }
173
+
174
+ async function selection(options, prompt){
175
+ let selection = 0
176
+ while (!(selection <= options && selection > 1)){
177
+ selection = (await input(prompt))
178
+ if (selection <= options && selection >= 1){
179
+ break
180
+ }
181
+ console.log(colors.Red,`Please input a valid option.`)
182
+ }
183
+ return selection
184
+ }
185
+
186
+ async function process_search(query) {
187
+ console.log(colors.Yellow, "Searching: "+query)
188
+
189
+ let search_results = await search_anime(query)
190
+ if (!search_results[0]) {
191
+ console.log(colors.Red, "No results.")
192
+ await main()
193
+ process.exit()
194
+ } else {
195
+ for (x in search_results) {
196
+ console.log(colors.Cyan,`${parseInt(x)+1})${" ".repeat(((search_results.length).toString().length+1)-((parseInt(x)+1).toString().length))}${search_results[x].replaceAll("-", " ")}`)
197
+ }
198
+ }
199
+
200
+ let anime_id = search_results[await selection(search_results.length, "Please select an anime.")-1]
201
+ let episodes = await episode_list(anime_id)
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
+ }
206
+ return {
207
+ anime_id: anime_id,
208
+ episodes: episodes,
209
+ episode_number: episode_number
210
+ }
211
+ }
212
+
213
+ async function get_video_link(episode_dpage){
214
+ let id = episode_dpage.replace("//gogohd.net/streaming.php?id=","")
215
+ id = id.slice(0, id.indexOf("="))
216
+ let link = await generate_link(1,id)
217
+ if (!link){
218
+ link = await generate_link(2,id)
219
+ }
220
+ return link
221
+ }
222
+
223
+ async function generate_link(provider, id){
224
+ let html = ""
225
+ let provider_name = ""
226
+ switch (provider) {
227
+ case 1:
228
+ html = await curl(`${gogohd_url}streaming.php?id=${id}`)
229
+ provider_name = 'Xstreamcdn'
230
+ console.log(colors.Yellow, `Fetching ${provider_name} links...`)
231
+ html = html.split("\n")
232
+ let fb_id = ""
233
+ for (x in html){
234
+ if (matchRuleShort(html[x], "*<li class=\"linkserver\" data-status=\"1\" data-video=\"https://fembed9hd.com/v/*")){
235
+ fb_id = html[x].slice(html[x].indexOf("/v/")+3, html[x].indexOf("\">X"))
236
+ break
237
+ }
238
+ }
239
+ if (!fb_id){
240
+ console.log("Error, no fb_id found.")
241
+ return 0
242
+ }
243
+
244
+ //let refr = "https://fembed-hd.com/v/"+fb_id
245
+ let post = await curl("https://fembed-hd.com/api/source/"+fb_id, "POST")
246
+ post = post.slice(post.indexOf(",\"data\":[{\"file\":\"")+18, post.length)
247
+ post = post.slice(0, post.indexOf("\"")).replaceAll("\\/","/")
248
+ return post
249
+ case 2:
250
+ provider_name = 'Animixplay'
251
+ let buffer = new Buffer(id)
252
+ let enc_id = buffer.toString("base64")
253
+ buffer = new Buffer(id+"LTXs3GrU8we9O"+enc_id)
254
+ let ani_id = buffer.toString("base64")
255
+ return `${base_url}/api/live${ani_id}`
256
+
257
+ /*console.log(`${base_url}/api/live${id}`)
258
+ console.log(colors.Yellow, `Fetching ${provider_name} links...`)
259
+ /*let re="$base_url"
260
+ let links = []
261
+ html = (await curl(`${base_url}/api/live/${"Some variable?"}`)).split("\n") // this needs fixed for alot of bigger titles to work.
262
+ for (x in html){
263
+ console.log(html[x])
264
+ }*/
265
+
266
+
267
+
268
+ }
269
+ }
270
+
271
+ async function get_video_quality_m3u8(){
272
+ console.log(colors.Red, "Not sure how you even got to this function? Its not implemented yet.")
273
+ }
274
+
275
+ async function post_play(link, anime, player="VLC"){
276
+ while (true){
277
+ console.log(colors.Yellow, `Playing episode ${anime.episode_number+1} of ${anime.anime_id.replaceAll("-", " ")}\n`)
278
+ console.log(colors.Cyan, "1) Show Link")
279
+ console.log(colors.Cyan, "2) Next Episode")
280
+ console.log(colors.Cyan, "3) Prev Episode")
281
+ console.log(colors.Cyan, "4) Quit")
282
+ choice = parseInt(await input("select;"))
283
+ switch (choice){
284
+ case 1:
285
+ console.clear()
286
+ console.log(colors.Blue, "ANI-CLI-NPM \n")
287
+ console.log(colors.Yellow, "Link: "+link)
288
+ break
289
+ case 2:
290
+ if (anime.episode_number > anime.episodes.length-2){
291
+ console.clear()
292
+ console.log(colors.Red, "Damn, all out of episodes?")
293
+ break
294
+ }
295
+ anime.episode_number += 1
296
+ link = await get_video_link(anime.episodes[anime.episode_number])
297
+ await play(link, anime, config.player)
298
+ process.exit()
299
+ break
300
+ //EVEN MORE NEEDLESS QUIT STATEMENTS!!!!!!
301
+ case 3:
302
+ if (anime.episode_number < 2){
303
+ console.clear()
304
+ console.log(colors.Red, "Error; Episode 0 is only available for premium members")
305
+ break
306
+ }
307
+ anime.episode_number -= 1
308
+ link = await get_video_link(anime.episodes[anime.episode_number])
309
+ await play(link, anime, config.player)
310
+ process.exit()
311
+ break
312
+ case 4:
313
+ console.clear()
314
+ await main()
315
+ process.exit()
316
+ break
317
+ }
318
+ }
319
+ }
320
+
321
+ async function play(link, anime, player="VLC"){
322
+ console.clear()
323
+ console.log(colors.Blue, "ANI-CLI-NPM \n")
324
+ if (player === "VLC"){
325
+ console.log(colors.Yellow, "Loading VLC... ")
326
+ let player = new VLC(link)
327
+ await post_play(link, anime)
328
+ process.exit()
329
+
330
+
331
+ }else if (player === "BROWSER"){
332
+ console.log(colors.Yellow, "Opening video in browser... ")
333
+ open(link)
334
+ await post_play(link, anime, player)
335
+ process.exit()
336
+ }
337
+ }
338
+
339
+ async function search(){
340
+ console.clear()
341
+ console.log(colors.Blue, "ANI-CLI-NPM \n")
342
+ console.log(colors.Magenta, "Search...")
343
+ let choice = await input("")
344
+ let anime = await process_search(choice)
345
+
346
+ console.log("\n")
347
+
348
+ console.log(colors.Blue, "Indexing video...")
349
+ let link = await get_video_link(anime.episodes[anime.episode_number])
350
+ console.clear()
351
+ console.log(colors.Blue, "ANI-CLI-NPM \n")
352
+ if (!link){
353
+ console.log(colors.Red, "Np link for this episode found?")
354
+ console.log(colors.Yellow, "^ at current this is due to not all of the required video repos being implemented.")
355
+ console.log(colors.Yellow, "Sorry for any inconvenience, this should soon by implemented. We appreciate your patience.")
356
+ process.exit()
357
+ }
358
+ console.log(colors.Blue, `Episode ${anime.episode_number+1} of ${anime.anime_id.replaceAll("-", " ")} found.\n`)
359
+ if (link.includes("animixplay.to")){
360
+ console.log(colors.Red, "Warning; VLC compatability for animix.to is currently shaky at best. It is advised to change player to browser in conf")
361
+ }
362
+ console.log(colors.Cyan, "1) Play")
363
+ console.log(colors.Cyan, "2) Download")
364
+ console.log(colors.Cyan, "3) Show Link")
365
+ console.log(colors.Cyan, "4) quit")
366
+ choice = parseInt(await input("select;"))
367
+ switch (choice){
368
+ case 1:
369
+ await play(link, anime, config.player)
370
+ break
371
+ case 2:
372
+ download(link, anime.anime_id+anime.episode_number+".mp4")
373
+ break
374
+ case 3:
375
+ console.log(colors.Yellow, "Link: "+link)
376
+ break
377
+ case 4:
378
+ await main()
379
+ process.exit()
380
+ }
381
+ }
382
+
383
+
384
+ console.clear()
385
+ console.log(colors.Blue, "Welcome to Ani-Cli-npm")
386
+ async function main(){
387
+ console.log(colors.Cyan, "1) Search")
388
+ console.log(colors.Cyan, "2) config")
389
+ console.log(colors.Cyan, "3) quit")
390
+ let choice = parseInt(await input("select;"))
391
+
392
+ switch (choice){
393
+ case 1:
394
+ await search()
395
+ break
396
+ case 2:
397
+ let temp = structuredClone(config);
398
+ let exit_code;
399
+ while (true) {
400
+ temp, exit_code = await config_(temp)
401
+ if (exit_code === 1) {
402
+ config = temp
403
+ proxyAgent = new HttpsProxyAgent(config.proxy);
404
+ console.clear()
405
+ console.log(colors.Blue, "ANI-CLI-NPM \n")
406
+ console.log(colors.Yellow, "Config changed.")
407
+ break
408
+ } else if (exit_code === 2) {
409
+ temp = config
410
+ console.clear()
411
+ console.log(colors.Blue, "ANI-CLI-NPM \n")
412
+ console.log(colors.Yellow, "Config changes disregarded.")
413
+ break
414
+ }
415
+ }
416
+ await main()
417
+ break
418
+ case 3:
419
+ console.log(colors.Black, "Exiting...")
420
+ process.exit()
421
+ }
422
+ }
423
+
424
+ main()
425
+