ani-cli-npm 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -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,15 @@
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>
@@ -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,66 @@
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
+ ### An Anime client, writen in nodeJS, to access any* anime without the need for ad filled websites! Just install, search for the anime of your choice, and watch in the video player of your choice.
4
+ ### NodeJS rewrite of the [ani-cli](https://github.com/pystardust/ani-cli) package for linux.
5
+
6
+
7
+ ## Instalation:
8
+ ### Windows:
9
+ #### - Download and install [nodejs](https://nodejs.org/en/download/)
10
+ #### - Open a terminal or powershell and run the following command to run the program:
11
+ ```
12
+ npx ani-cli-npm@latest
13
+ ```
14
+ #### - It is recomended to install VLC media player, but optionaly you can change your video player to Browser in config
15
+
16
+ ### Android
17
+ #### - Install the android terminal of your choice. e.g. [Termux](https://play.google.com/store/apps/details?id=com.termux)
18
+ #### - Install [nodejs](https://nodejs.org/). In termux this is done with the following command:
19
+ ```
20
+ pkg install nodejs
21
+ ```
22
+ #### - Run npx ani-cli-npm@latest
23
+ ##### Note: At preset (1.0.6), you will need to change the player to browser, and will have to do any downloads through your browser of choice.
24
+
25
+ ### Linux:
26
+ #### - Install [nodejs](https://nodejs.org/en/download/ with your distrabutions package manager.
27
+ #### - Run the following command:
28
+ ```
29
+ npx ani-cli-npm@latest
30
+ ```
31
+ ##### Note: If you are using linux, I would advise just using the origonal [ani-cli](https://github.com/pystardust/ani-cli), the main perpous of this package is to allow easier use on windows and android.
32
+
33
+
34
+ ## Usage:
35
+ <img width="147" alt="image" src="https://user-images.githubusercontent.com/74017165/195988816-5088cbff-348e-4852-a1a0-ef343785d488.png">
36
+
37
+ #### Input the page you wish to got to then press the enter key to select
38
+
39
+ ### Search:
40
+
41
+ #### Input the name of the anime you want to watch, the select an anime from the search results. Then select the episode you wish to watch (If there is only one episode, said ep will be played automaticly)
42
+
43
+ #### Play - Plays the episode you have chosen in the player you have selected in config (VLC by default)
44
+
45
+ #### Download - Will download the episode. (This requires you to have chosed a download directory in config).
46
+
47
+ ##### The download feature is not currently implemented, if you wish to download, open in browser and download there.
48
+
49
+ #### Show Link - Will display the link to the video file. This can be opened in a video player or browser.
50
+
51
+ ### Config:
52
+
53
+ #### For configuring several of options about how the program works.
54
+
55
+ #### Player - Change which player is used to open the anime.
56
+
57
+ #### Prozy - Proxy used for searching. This is not currently implemented and will not work.
58
+
59
+ #### User agent - The user agent used to make requests to websites.
60
+
61
+
62
+ ## Current limitations:
63
+
64
+ ### At present this program only has Xstreamcdn videos implemented, as such, there is a high liklyhood that many animes will not be available. This will soon be amended but for now you will need to stick to the animes that are available under Xstreamcdn.
65
+
66
+ ### This project is still very much under development, as such, there are quite a few bugs.
package/bin/index.js CHANGED
@@ -1,426 +1,427 @@
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
+
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
+ await main()
381
+ process.exit()
382
+ }
383
+ }
384
+
385
+
386
+ console.clear()
387
+ console.log(colors.Blue, "Welcome to Ani-Cli-npm")
388
+ async function main(){
389
+ console.log(colors.Cyan, "1) Search")
390
+ console.log(colors.Cyan, "2) config")
391
+ console.log(colors.Cyan, "3) quit")
392
+ let choice = parseInt(await input("select;"))
393
+
394
+ switch (choice){
395
+ case 1:
396
+ await search()
397
+ break
398
+ case 2:
399
+ let temp = structuredClone(config);
400
+ let exit_code;
401
+ while (true) {
402
+ temp, exit_code = await config_(temp)
403
+ if (exit_code === 1) {
404
+ config = temp
405
+ proxyAgent = new HttpsProxyAgent(config.proxy);
406
+ console.clear()
407
+ console.log(colors.Blue, "ANI-CLI-NPM \n")
408
+ console.log(colors.Yellow, "Config changed.")
409
+ break
410
+ } else if (exit_code === 2) {
411
+ temp = config
412
+ console.clear()
413
+ console.log(colors.Blue, "ANI-CLI-NPM \n")
414
+ console.log(colors.Yellow, "Config changes disregarded.")
415
+ break
416
+ }
417
+ }
418
+ await main()
419
+ break
420
+ case 3:
421
+ console.log(colors.Black, "Exiting...")
422
+ process.exit()
423
+ }
424
+ }
425
+
426
+ main()
427
+
package/package.json CHANGED
@@ -1,28 +1,33 @@
1
- {
2
- "name": "ani-cli-npm",
3
- "version": "1.0.6",
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": "github:mxkacsa/vlc-simple-player#process-close-exception-fix"
27
- }
28
- }
1
+ {
2
+ "name": "ani-cli-npm",
3
+ "version": "1.0.7",
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
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/Bumpkin-Pi/ani-cli-npm"
13
+ },
14
+ "homepage": "https://github.com/Bumpkin-Pi/ani-cli-npm",
15
+ "keywords": [
16
+ "anime",
17
+ "ani-cli",
18
+ "anime",
19
+ "client"
20
+ ],
21
+ "author": "bumpkin-pi",
22
+ "license": "ISC",
23
+ "bin": {
24
+ "multiply": "bin/index.js"
25
+ },
26
+ "dependencies": {
27
+ "http-proxy-agent": "^5.0.0",
28
+ "https-proxy-agent": "^5.0.1",
29
+ "open": "^8.4.0",
30
+ "simple-input": "^1.0.1",
31
+ "vlc-simple-player": "github:mxkacsa/vlc-simple-player#process-close-exception-fix"
32
+ }
33
+ }
package/.idea/discord.xml DELETED
@@ -1,7 +0,0 @@
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>
package/index.cjs DELETED
@@ -1,45 +0,0 @@
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()