ani-cli-npm 1.0.3 → 1.0.5

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.
@@ -1,12 +1,12 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="WEB_MODULE" version="4">
3
- <component name="NewModuleRootManager">
4
- <content url="file://$MODULE_DIR$">
5
- <excludeFolder url="file://$MODULE_DIR$/temp" />
6
- <excludeFolder url="file://$MODULE_DIR$/.tmp" />
7
- <excludeFolder url="file://$MODULE_DIR$/tmp" />
8
- </content>
9
- <orderEntry type="inheritedJdk" />
10
- <orderEntry type="sourceFolder" forTests="false" />
11
- </component>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="WEB_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$">
5
+ <excludeFolder url="file://$MODULE_DIR$/temp" />
6
+ <excludeFolder url="file://$MODULE_DIR$/.tmp" />
7
+ <excludeFolder url="file://$MODULE_DIR$/tmp" />
8
+ </content>
9
+ <orderEntry type="inheritedJdk" />
10
+ <orderEntry type="sourceFolder" forTests="false" />
11
+ </component>
12
12
  </module>
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="DiscordProjectSettings">
4
+ <option name="show" value="ASK" />
5
+ <option name="description" value="" />
6
+ </component>
7
+ </project>
@@ -1,6 +1,6 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="JavaScriptLibraryMappings">
4
- <includedPredefinedLibrary name="Node.js Core" />
5
- </component>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="JavaScriptLibraryMappings">
4
+ <includedPredefinedLibrary name="Node.js Core" />
5
+ </component>
6
6
  </project>
package/.idea/modules.xml CHANGED
@@ -1,8 +1,8 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/ani-cli-npm.iml" filepath="$PROJECT_DIR$/.idea/ani-cli-npm.iml" />
6
- </modules>
7
- </component>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/ani-cli-npm.iml" filepath="$PROJECT_DIR$/.idea/ani-cli-npm.iml" />
6
+ </modules>
7
+ </component>
8
8
  </project>
package/.idea/vcs.xml CHANGED
@@ -1,6 +1,6 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
- </component>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
6
  </project>
package/README.MD CHANGED
@@ -1,7 +1,7 @@
1
- # ANI-CLI-NPM
2
-
3
- ## Instalation:
4
-
5
- ### 1. Install npm/node
6
- ### 2. npx ani-cli-npm
7
- ### 3. done
1
+ # ANI-CLI-NPM
2
+
3
+ ## Instalation:
4
+
5
+ ### 1. Install npm/node
6
+ ### 2. npx ani-cli-npm
7
+ ### 3. done
package/bin/index.js CHANGED
@@ -1,407 +1,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
-
22
- const gogohd_url="https://gogohd.net/"
23
- const base_url="https://animixplay.to"
24
- const colors = {
25
- Black: "\x1b[30m%s\x1b[0m",
26
- Red: "\x1b[31m%s\x1b[0m",
27
- Green: "\x1b[32m%s\x1b[0m",
28
- Yellow: "\x1b[33m%s\x1b[0m",
29
- Blue: "\x1b[34m%s\x1b[0m",
30
- Magenta: "\x1b[35m%s\x1b[0m",
31
- Cyan: "\x1b[36m%s\x1b[0m",
32
- White: "\x1b[37m%s\x1b[0m"
33
- }
34
- let config = {
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 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
-
84
- async function input(message){
85
- if (message){
86
- console.log(colors.Magenta,message)
87
- }
88
- return await prompt(">")
89
- }
90
-
91
-
92
- async function curl(url, method="GET"){
93
- await fetch(url, {
94
- "agent": proxyAgent,
95
- "headers": {
96
- 'User-Agent': config.user_agent,
97
- "X-Requested-With": "XMLHttpRequest"
98
- },
99
- "referrerPolicy": "origin",
100
- "body": null,
101
- "method": method,
102
- "proxy": "68.183.230.116:3951"
103
- }).then(function (response) {
104
- return response.text();
105
- }).then(function (html) {
106
- fs.writeFileSync("./temp.txt", html, function(err) {
107
- if(err) {
108
- return console.log(err);
109
- }
110
- });
111
- }).catch(function (err) {
112
- console.warn(`Something went wrong connecting to ${url}.`, err);
113
- });
114
-
115
- return fs.readFileSync("./temp.txt").toString()
116
- }
117
-
118
-
119
- function matchRuleShort(str, rule) {
120
- let escapeRegex = (str) => str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
121
- return new RegExp("^" + rule.split("*").map(escapeRegex).join(".*") + "$").test(str);
122
- }
123
-
124
-
125
- async function search_anime(search){
126
- let filter = "*<ahref=\"/category/*\"title=\"*\">"
127
- let html = (await curl("https://gogoanime.dk//search.html?keyword="+search)).split("\n")
128
- let lines = []
129
- for (x in html){
130
- html[x] = html[x].replace(/ /g,'').replace(/\t/g,'')
131
- if (matchRuleShort(html[x], filter)){
132
- html[x] = html[x].slice(html[x].indexOf("/category/")+10);
133
- html[x] = html[x].slice(0, html[x].indexOf("\"title="));
134
- lines.push(html[x])
135
- }
136
- }
137
- if (!lines[0]){
138
- lines.pop()
139
- }
140
-
141
-
142
- return lines
143
- }
144
-
145
-
146
- async function episode_list(anime_id){
147
- let html = (await curl(base_url+"/v1/"+anime_id)).split("\n")
148
- let lines = ""
149
-
150
- for (let x in html){
151
- if(matchRuleShort(html[x], "*<div id=\"epslistplace\"*")){
152
- lines = (html[x])
153
- }
154
- }
155
-
156
- lines = lines.slice(55, lines.length).replace("}</div>", "")
157
- lines = "{" + lines.slice(lines.indexOf(",")+1, lines.length) + "}"
158
- lines = JSON.parse(lines)
159
-
160
- let json = []
161
- for (x in lines){
162
- json.push(lines[x])
163
- }
164
- return json
165
- }
166
-
167
-
168
- async function download(url, name){
169
- 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.")
170
- }
171
-
172
-
173
- async function selection(options, prompt){
174
- let selection = 0
175
- while (!(selection <= options && selection > 1)){
176
- selection = (await input(prompt))
177
- if (selection <= options && selection >= 1){
178
- break
179
- }
180
- console.log(colors.Red,`Please input a valid option.`)
181
- }
182
- return selection
183
- }
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
-
214
- async function get_video_link(episode_dpage){
215
- let id = episode_dpage.replace("//gogohd.net/streaming.php?id=","")
216
- id = id.slice(0, id.indexOf("="))
217
-
218
- return await generate_link(1,id)
219
- }
220
-
221
-
222
- async function generate_link(provider, id){
223
- let html = ""
224
- let provider_name = ""
225
- switch (provider) {
226
- case 1:
227
- html = await curl(`${gogohd_url}streaming.php?id=${id}`)
228
- provider_name = 'Xstreamcdn'
229
- console.log(colors.Yellow, `Fetching ${provider_name} links...`)
230
- html = html.split("\n")
231
- let fb_id = ""
232
- for (x in html){
233
- if (matchRuleShort(html[x], "*<li class=\"linkserver\" data-status=\"1\" data-video=\"https://fembed9hd.com/v/*")){
234
- fb_id = html[x].slice(html[x].indexOf("/v/")+3, html[x].indexOf("\">X"))
235
- break
236
- }
237
- }
238
- if (!fb_id){
239
- console.log("Error, no fb_id found.")
240
- return 0
241
- }
242
-
243
- //let refr = "https://fembed-hd.com/v/"+fb_id
244
- let post = await curl("https://fembed-hd.com/api/source/"+fb_id, "POST")
245
- post = post.slice(post.indexOf(",\"data\":[{\"file\":\"")+18, post.length)
246
- post = post.slice(0, post.indexOf("\"")).replaceAll("\\/","/")
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
-
261
- }
262
- }
263
-
264
-
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"){
271
- console.clear()
272
- console.log(colors.Blue, "ANI-CLI-NPM \n")
273
- if (player === "VLC"){
274
- console.log(colors.Yellow, "Loading VLC... ")
275
- let player = new VLC(link)
276
- console.log(colors.Blue, `Playing episode ${anime.episode_number+1} of ${anime.anime_id.replaceAll("-", " ")}`)
277
- console.log(colors.Cyan, "1) Show Link")
278
- console.log(colors.Cyan, "2) Quit")
279
- choice = parseInt(await input("select;"))
280
- switch (choice){
281
- case 1:
282
- console.clear()
283
- console.log(colors.Blue, "ANI-CLI-NPM \n")
284
- console.log
285
- console.log(colors.Yellow, "Link: "+link)
286
- break
287
- case 2:
288
- process.exit()
289
- break
290
- }
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
- }
322
- }
323
- }
324
-
325
-
326
- async function search(){
327
- console.clear()
328
- console.log(colors.Blue, "ANI-CLI-NPM \n")
329
- console.log(colors.Magenta, "Search...")
330
- let choice = await input("")
331
- let anime = await process_search(choice)
332
- console.log("\n")
333
-
334
- console.log(colors.Blue, "Indexing video...")
335
- let link = await get_video_link(anime.episodes[anime.episode_number])
336
- console.clear()
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`)
345
- console.log(colors.Cyan, "1) Play")
346
- console.log(colors.Cyan, "2) Download")
347
- console.log(colors.Cyan, "3) Show Link")
348
- console.log(colors.Cyan, "4) quit")
349
- choice = parseInt(await input("select;"))
350
- switch (choice){
351
- case 1:
352
- await play(link, anime, config.player)
353
- break
354
- case 2:
355
- download(link, anime.anime_id+anime.episode_number+".mp4")
356
- break
357
- case 3:
358
- console.log(colors.Yellow, "Link: "+link)
359
- break
360
- case 4:
361
- process.exit()
362
- }
363
- }
364
-
365
-
366
- console.clear()
367
- console.log(colors.Blue, "Welcome to Ani-Cli-npm")
368
- async function main(){
369
- console.log(colors.Cyan, "1) Search")
370
- console.log(colors.Cyan, "2) config")
371
- console.log(colors.Cyan, "3) quit")
372
- let choice = parseInt(await input("select;"))
373
-
374
- switch (choice){
375
- case 1:
376
- await search()
377
- break
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()
399
- break
400
- case 3:
401
- console.log(colors.Black, "Exiting...")
402
- process.exit()
403
- }
404
- }
405
-
406
- main()
407
-
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
+
package/index.cjs ADDED
@@ -0,0 +1,45 @@
1
+
2
+ const HttpsProxyAgent = require("http-proxy-agent")
3
+ const cluster = require("cluster");
4
+ const os = require("os")
5
+
6
+ //const proxylist = require("./proxylist.json")
7
+ function makereq(url, agent) {
8
+ return new Promise((res,rej) => {
9
+ fetch("https://animixplay.to/v1/one-punch-man", {
10
+ "headers": {
11
+ "accept": "text/html,application/xhtml+xml,application/9",
12
+ "accept-language": "en-GB,en-US;q=0.9,en;q=0.8",
13
+ "cache-control": "max-age=0",
14
+ "sec-ch-ua": "\"Not-A.Brand\";v=\"99\", \"Opera GX\";v=\"91\", \"Chromium\";v=\"105\"",
15
+ "sec-ch-ua-mobile": "?0",
16
+ "sec-ch-ua-platform": "\"Windows\"",
17
+ "sec-fetch-dest": "document",
18
+ "sec-fetch-mode": "navigate",
19
+ "sec-fetch-site": "none",
20
+ "sec-fetch-user": "?1",
21
+ "upgrade-insecure-requests": "1",
22
+ //"cookie": "animix_ses=78c4mbvq1g8v3kjdrbo85m5c8sbpjagkjbip"
23
+ },
24
+ "referrerPolicy": "strict-origin-when-cross-origin",
25
+ "body": null,
26
+ "method": "GET",
27
+ "proxy": ""
28
+ }).then(function (response) {
29
+ // The API call was successful!
30
+ return response.text();
31
+ }).then(function (html) {
32
+ // This is the HTML from our response as a text string
33
+ console.log(html);
34
+ return html
35
+ })
36
+ })
37
+ }
38
+
39
+ async function main() {
40
+ let proxy = "194.195.213.197:1080"
41
+ let html = await makereq("", new HttpsProxyAgent(proxy))
42
+ console.log(html)
43
+ }
44
+
45
+ main()
package/package.json CHANGED
@@ -1,28 +1,28 @@
1
- {
2
- "name": "ani-cli-npm",
3
- "version": "1.0.3",
4
- "description": "ani-cli tool rewritten as npm package",
5
- "main": "index.js",
6
- "scripts": {
7
- "start": "node bin/index.js",
8
- "test": "echo \"Error: no test specified\" && exit 1"
9
- },
10
- "keywords": [
11
- "anime",
12
- "ani-cli",
13
- "anime",
14
- "client"
15
- ],
16
- "author": "bumpkin-pi",
17
- "license": "ISC",
18
- "bin": {
19
- "multiply": "bin/index.js"
20
- },
21
- "dependencies": {
22
- "http-proxy-agent": "^5.0.0",
23
- "https-proxy-agent": "^5.0.1",
24
- "open": "^8.4.0",
25
- "simple-input": "^1.0.1",
26
- "vlc-simple-player": "^0.5.1"
27
- }
28
- }
1
+ {
2
+ "name": "ani-cli-npm",
3
+ "version": "1.0.5",
4
+ "description": "ani-cli tool rewritten as npm package",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "start": "node bin/index.js",
8
+ "test": "echo \"Error: no test specified\" && exit 1"
9
+ },
10
+ "keywords": [
11
+ "anime",
12
+ "ani-cli",
13
+ "anime",
14
+ "client"
15
+ ],
16
+ "author": "bumpkin-pi",
17
+ "license": "ISC",
18
+ "bin": {
19
+ "multiply": "bin/index.js"
20
+ },
21
+ "dependencies": {
22
+ "http-proxy-agent": "^5.0.0",
23
+ "https-proxy-agent": "^5.0.1",
24
+ "open": "^8.4.0",
25
+ "simple-input": "^1.0.1",
26
+ "vlc-simple-player": "^0.5.1"
27
+ }
28
+ }
@@ -1,15 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="GitToolBoxProjectSettings">
4
- <option name="commitMessageIssueKeyValidationOverride">
5
- <BoolValueOverride>
6
- <option name="enabled" value="true" />
7
- </BoolValueOverride>
8
- </option>
9
- <option name="commitMessageValidationEnabledOverride">
10
- <BoolValueOverride>
11
- <option name="enabled" value="true" />
12
- </BoolValueOverride>
13
- </option>
14
- </component>
15
- </project>