ani-cli-npm 1.0.2 → 1.0.4

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.
Files changed (2) hide show
  1. package/bin/index.js +207 -36
  2. 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
- quality: "best",
25
- player: "VLC"
35
+ player: "VLC",
36
+ proxy: "",
37
+ user_agent: 'Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/100.0'
38
+ }
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 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
+ }
26
81
  }
27
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
- //"agent": proxyAgent,
94
+ "agent": proxyAgent,
38
95
  "headers": {
39
- 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/100.0',
96
+ 'User-Agent': config.user_agent,
40
97
  "X-Requested-With": "XMLHttpRequest"
41
98
  },
42
99
  "referrerPolicy": "origin",
@@ -67,18 +124,20 @@ 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
- html[x] = html[x].replace(/ /g,'').replace(/\t/g,'')
130
+ html[x] = html[x].replaceAll(/ /g,'').replaceAll(/\t/g,'')
75
131
  if (matchRuleShort(html[x], filter)){
76
132
  html[x] = html[x].slice(html[x].indexOf("/category/")+10);
77
133
  html[x] = html[x].slice(0, html[x].indexOf("\"title="));
78
134
  lines.push(html[x])
79
135
  }
80
136
  }
81
- lines.pop()
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
- return 0
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 = await selection(episodes.length, `Please select an episode (1-${episodes.length}).`)
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
- let html = await curl(`${gogohd_url}streaming.php?id=${id}`)
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, html){
222
+ async function generate_link(provider, id){
223
+ let html = ""
224
+ let provider_name = ""
162
225
  switch (provider) {
163
226
  case 1:
164
- let provider_name = 'Xstreamcdn'
165
- console.log(colors.Blue, `Fetching ${provider_name} links...`)
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,134 @@ 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 play(link, player="VLC"){
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.Yellow, "Playing video.\n")
193
- console.log("VLC;")
276
+ console.log(colors.Yellow, `Playing episode ${anime.episode_number+1} of ${anime.anime_id.replaceAll("-", " ")}\n`)
194
277
  console.log(colors.Cyan, "1) Show Link")
278
+ console.log(colors.Cyan, "2) Next Episode")
279
+ console.log(colors.Cyan, "3) Quit")
280
+ choice = parseInt(await input("select;"))
281
+ switch (choice){
282
+ case 1:
283
+ console.clear()
284
+ console.log(colors.Blue, "ANI-CLI-NPM \n")
285
+ console.log(colors.Yellow, "Link: "+link)
286
+ break
287
+ case 2:
288
+ link = await get_video_link(anime.episodes[anime.episode_number+1])
289
+ await play(link, anime, config.player)
290
+ process.exit()
291
+ break
292
+ case 3:
293
+ console.clear()
294
+ await main()
295
+ process.exit()
296
+ break
297
+ }
298
+ console.log(colors.Cyan, "1) Next Episode")
195
299
  console.log(colors.Cyan, "2) Quit")
196
300
  choice = parseInt(await input("select;"))
197
301
  switch (choice){
198
302
  case 1:
303
+ link = await get_video_link(anime.episodes[anime.episode_number+1])
304
+ await play(link, anime, config.player)
305
+ process.exit()
306
+ break
307
+ case 2:
308
+ console.clear()
309
+ await main()
310
+ process.exit()
311
+ break
312
+ }
313
+ }else if (player === "BROWSER"){
314
+ console.log(colors.Yellow, "Opening video in browser... ")
315
+ open(link)
316
+ console.log(colors.Yellow, `Playing episode ${anime.episode_number+1} of ${anime.anime_id.replaceAll("-", " ")}\n`)
317
+ console.log(colors.Cyan, "1) Show Link")
318
+ console.log(colors.Cyan, "2) Next Episode")
319
+ console.log(colors.Cyan, "3) Quit")
320
+ choice = parseInt(await input("select;"))
321
+ switch (choice){
322
+ case 1:
323
+ console.clear()
324
+ console.log(colors.Blue, "ANI-CLI-NPM \n")
199
325
  console.log(colors.Yellow, "Link: "+link)
200
326
  break
201
327
  case 2:
328
+ link = await get_video_link(anime.episodes[anime.episode_number+1])
329
+ await play(link, anime, config.player)
330
+ process.exit()
331
+ break
332
+ case 3:
333
+ console.clear()
334
+ await main()
335
+ process.exit()
336
+ break
337
+ }
338
+ console.log(colors.Cyan, "1) Next Episode")
339
+ console.log(colors.Cyan, "2) Quit")
340
+ choice = parseInt(await input("select;"))
341
+ switch (choice){
342
+ case 1:
343
+ link = await get_video_link(anime.episodes[anime.episode_number+1])
344
+ await play(link, anime, config.player)
345
+ process.exit()
346
+ break
347
+ case 2:
348
+ console.clear()
349
+ await main()
202
350
  process.exit()
203
351
  break
204
352
  }
205
- }else{
206
-
207
353
  }
208
354
  }
209
355
 
356
+
210
357
  async function search(){
211
358
  console.clear()
212
- console.log(colors.Blue, "Search...")
359
+ console.log(colors.Blue, "ANI-CLI-NPM \n")
360
+ console.log(colors.Magenta, "Search...")
213
361
  let choice = await input("")
214
362
  let anime = await process_search(choice)
215
-
216
363
  console.log("\n")
217
364
 
218
365
  console.log(colors.Blue, "Indexing video...")
219
366
  let link = await get_video_link(anime.episodes[anime.episode_number])
220
367
  console.clear()
221
- console.log(colors.Blue, "Episode found.\n")
368
+ console.log(colors.Blue, "ANI-CLI-NPM \n")
369
+ if (!link){
370
+ console.log(colors.Red, "Np link for this episode found?")
371
+ console.log(colors.Yellow, "^ at current this is due to not all of the required video repos being implemented.")
372
+ console.log(colors.Yellow, "Sorry for any inconvenience, this should soon by implemented. We appreciate your patience.")
373
+ process.exit()
374
+ }
375
+ console.log(colors.Blue, `Episode ${anime.episode_number+1} of ${anime.anime_id.replaceAll("-", " ")} found.\n`)
222
376
  console.log(colors.Cyan, "1) Play")
223
377
  console.log(colors.Cyan, "2) Download")
224
378
  console.log(colors.Cyan, "3) Show Link")
@@ -226,7 +380,7 @@ async function search(){
226
380
  choice = parseInt(await input("select;"))
227
381
  switch (choice){
228
382
  case 1:
229
- await play(link, config.player)
383
+ await play(link, anime, config.player)
230
384
  break
231
385
  case 2:
232
386
  download(link, anime.anime_id+anime.episode_number+".mp4")
@@ -237,15 +391,12 @@ async function search(){
237
391
  case 4:
238
392
  process.exit()
239
393
  }
240
-
241
-
242
-
243
394
  }
244
395
 
245
396
 
397
+ console.clear()
398
+ console.log(colors.Blue, "Welcome to Ani-Cli-npm")
246
399
  async function main(){
247
- console.clear()
248
- console.log(colors.Blue, "Welcome to Ani-Cli-npm")
249
400
  console.log(colors.Cyan, "1) Search")
250
401
  console.log(colors.Cyan, "2) config")
251
402
  console.log(colors.Cyan, "3) quit")
@@ -256,6 +407,26 @@ async function main(){
256
407
  await search()
257
408
  break
258
409
  case 2:
410
+ let temp = structuredClone(config);
411
+ let exit_code;
412
+ while (true) {
413
+ temp, exit_code = await config_(temp)
414
+ if (exit_code === 1) {
415
+ config = temp
416
+ proxyAgent = new HttpsProxyAgent(config.proxy);
417
+ console.clear()
418
+ console.log(colors.Blue, "ANI-CLI-NPM \n")
419
+ console.log(colors.Yellow, "Config changed.")
420
+ break
421
+ } else if (exit_code === 2) {
422
+ temp = config
423
+ console.clear()
424
+ console.log(colors.Blue, "ANI-CLI-NPM \n")
425
+ console.log(colors.Yellow, "Config changes disregarded.")
426
+ break
427
+ }
428
+ }
429
+ await main()
259
430
  break
260
431
  case 3:
261
432
  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.2",
3
+ "version": "1.0.4",
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
  }