ani-cli-npm 1.0.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/.idea/ani-cli-npm.iml +12 -0
- package/.idea/git_toolbox_prj.xml +15 -0
- package/.idea/jsLibraryMappings.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/README.MD +7 -0
- package/bin/index.js +196 -0
- package/bin/temp.txt +1 -0
- package/package.json +24 -0
@@ -0,0 +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>
|
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>
|
@@ -0,0 +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>
|
8
|
+
</project>
|
package/.idea/vcs.xml
ADDED
package/README.MD
ADDED
package/bin/index.js
ADDED
@@ -0,0 +1,196 @@
|
|
1
|
+
#! /usr/bin/env node
|
2
|
+
const fs = require("fs");
|
3
|
+
const http = require('http');
|
4
|
+
//const HttpsProxyAgent = require('https-proxy-agent');
|
5
|
+
const VLC = require('vlc-simple-player');
|
6
|
+
//const proxyAgent = new HttpsProxyAgent("68.183.230.116:3951");
|
7
|
+
const prompt = require("simple-input");
|
8
|
+
async function input(message){
|
9
|
+
console.log(colors.Magenta,message)
|
10
|
+
return await prompt(">")
|
11
|
+
}
|
12
|
+
|
13
|
+
|
14
|
+
const download_dir = "./../downloads/"
|
15
|
+
const gogohd_url="https://gogohd.net/"
|
16
|
+
const base_url="https://animixplay.to"
|
17
|
+
|
18
|
+
const colors = {
|
19
|
+
Black: "\x1b[30m%s\x1b[0m",
|
20
|
+
Red: "\x1b[31m%s\x1b[0m",
|
21
|
+
Green: "\x1b[32m%s\x1b[0m",
|
22
|
+
Yellow: "\x1b[33m%s\x1b[0m",
|
23
|
+
Blue: "\x1b[34m%s\x1b[0m",
|
24
|
+
Magenta: "\x1b[35m%s\x1b[0m",
|
25
|
+
Cyan: "\x1b[36m%s\x1b[0m",
|
26
|
+
White: "\x1b[37m%s\x1b[0m"
|
27
|
+
}
|
28
|
+
|
29
|
+
|
30
|
+
async function curl(url, method="GET"){
|
31
|
+
await fetch(url, {
|
32
|
+
//"agent": proxyAgent,
|
33
|
+
"headers": {
|
34
|
+
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/100.0',
|
35
|
+
"X-Requested-With": "XMLHttpRequest"
|
36
|
+
},
|
37
|
+
"referrerPolicy": "origin",
|
38
|
+
"body": null,
|
39
|
+
"method": method,
|
40
|
+
"proxy": "68.183.230.116:3951"
|
41
|
+
}).then(function (response) {
|
42
|
+
return response.text();
|
43
|
+
}).then(function (html) {
|
44
|
+
fs.writeFileSync("./temp.txt", html, function(err) {
|
45
|
+
if(err) {
|
46
|
+
return console.log(err);
|
47
|
+
}
|
48
|
+
});
|
49
|
+
}).catch(function (err) {
|
50
|
+
console.warn(`Something went wrong connecting to ${url}.`, err);
|
51
|
+
});
|
52
|
+
|
53
|
+
return fs.readFileSync("./temp.txt").toString()
|
54
|
+
}
|
55
|
+
|
56
|
+
|
57
|
+
function matchRuleShort(str, rule) {
|
58
|
+
let escapeRegex = (str) => str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
|
59
|
+
return new RegExp("^" + rule.split("*").map(escapeRegex).join(".*") + "$").test(str);
|
60
|
+
}
|
61
|
+
|
62
|
+
|
63
|
+
async function search_anime(search){
|
64
|
+
let filter = "*<ahref=\"/category/*\"title=\"*\">"
|
65
|
+
|
66
|
+
let html = (await curl("https://gogoanime.lu//search.html?keyword="+search)).split("\n")
|
67
|
+
let lines = []
|
68
|
+
for (x in html){
|
69
|
+
html[x] = html[x].replace(/ /g,'').replace(/\t/g,'')
|
70
|
+
if (matchRuleShort(html[x], filter)){
|
71
|
+
html[x] = html[x].slice(html[x].indexOf("/category/")+10);
|
72
|
+
html[x] = html[x].slice(0, html[x].indexOf("\"title="));
|
73
|
+
lines.push(html[x])
|
74
|
+
}
|
75
|
+
}
|
76
|
+
lines.pop()
|
77
|
+
|
78
|
+
return lines
|
79
|
+
}
|
80
|
+
|
81
|
+
|
82
|
+
async function episode_list(anime_id){
|
83
|
+
let html = (await curl(base_url+"/v1/"+anime_id)).split("\n")
|
84
|
+
let lines = ""
|
85
|
+
for (let x in html){
|
86
|
+
if(matchRuleShort(html[x], "*<div id=\"epslistplace\"*")){
|
87
|
+
lines = (html[x])
|
88
|
+
}
|
89
|
+
}
|
90
|
+
lines = lines.slice(55, lines.length).replace("}</div>", "")
|
91
|
+
lines = "{" + lines.slice(lines.indexOf(",")+1, lines.length) + "}"
|
92
|
+
lines = JSON.parse(lines)
|
93
|
+
let json = []
|
94
|
+
for (x in lines){
|
95
|
+
json.push(lines[x])
|
96
|
+
}
|
97
|
+
return json
|
98
|
+
}
|
99
|
+
|
100
|
+
|
101
|
+
async function download(url, name){
|
102
|
+
let file = fs.createWriteStream(download_dir+name)
|
103
|
+
http.get(url, function(response) {
|
104
|
+
response.pipe(file);
|
105
|
+
// after download completed close filestream
|
106
|
+
file.on("finish", () => {
|
107
|
+
file.close();
|
108
|
+
console.log(`Downloaded: ${name}`);
|
109
|
+
});
|
110
|
+
});
|
111
|
+
}
|
112
|
+
|
113
|
+
|
114
|
+
async function selection(options, prompt){
|
115
|
+
let selection
|
116
|
+
while (!(selection <= options && selection > 1)){
|
117
|
+
selection = (await input(prompt))
|
118
|
+
if (selection <= options && selection >= 1){
|
119
|
+
break
|
120
|
+
}
|
121
|
+
console.log(colors.Red,`Please input a valid option.`)
|
122
|
+
}
|
123
|
+
return selection
|
124
|
+
}
|
125
|
+
|
126
|
+
|
127
|
+
async function process_search(query){
|
128
|
+
console.log("Searching: "+query)
|
129
|
+
let search_results = await search_anime(query)
|
130
|
+
if (!search_results[0]){
|
131
|
+
console.log("No results.")
|
132
|
+
return 0
|
133
|
+
}else{
|
134
|
+
for (x in search_results){
|
135
|
+
console.log(colors.Cyan,`${parseInt(x)+1})${" ".repeat(((search_results.length).toString().length+1)-((parseInt(x)+1).toString().length))}${search_results[x].replaceAll("-", " ")}`)
|
136
|
+
}
|
137
|
+
}
|
138
|
+
let anime_id = search_results[await selection(search_results.length, "Please select an anime.")-1]
|
139
|
+
let episodes = await episode_list(anime_id)
|
140
|
+
let episode_number = await selection(episodes.length, `Please select an episode (1-${episodes.length}).`)
|
141
|
+
return {anime_id:anime_id,
|
142
|
+
episodes:episodes,
|
143
|
+
episode_number:episode_number
|
144
|
+
}
|
145
|
+
}
|
146
|
+
|
147
|
+
|
148
|
+
async function get_video_link(episode_dpage){
|
149
|
+
let id = episode_dpage.replace("//gogohd.net/streaming.php?id=","")
|
150
|
+
id = id.slice(0, id.indexOf("="))
|
151
|
+
|
152
|
+
let html = await curl(`${gogohd_url}streaming.php?id=${id}`)
|
153
|
+
return await generate_link(1, html)
|
154
|
+
}
|
155
|
+
|
156
|
+
|
157
|
+
async function generate_link(provider, html){
|
158
|
+
switch (provider) {
|
159
|
+
case 1:
|
160
|
+
let provider_name = 'Xstreamcdn'
|
161
|
+
console.log(colors.Blue, `Fetching ${provider_name} links...`)
|
162
|
+
html = html.split("\n")
|
163
|
+
let fb_id = ""
|
164
|
+
for (x in html){
|
165
|
+
if (matchRuleShort(html[x], "*<li class=\"linkserver\" data-status=\"1\" data-video=\"https://fembed9hd.com/v/*")){
|
166
|
+
fb_id = html[x].slice(html[x].indexOf("/v/")+3, html[x].indexOf("\">X"))
|
167
|
+
}
|
168
|
+
}
|
169
|
+
if (!fb_id){
|
170
|
+
console.log("Error, no fb_id found.")
|
171
|
+
return 0
|
172
|
+
}
|
173
|
+
//let refr = "https://fembed-hd.com/v/"+fb_id
|
174
|
+
let post = await curl("https://fembed-hd.com/api/source/"+fb_id, "POST")
|
175
|
+
post = post.slice(post.indexOf(",\"data\":[{\"file\":\"")+18, post.length)
|
176
|
+
post = post.slice(0, post.indexOf("\"")).replaceAll("\\/","/")
|
177
|
+
return post
|
178
|
+
}
|
179
|
+
}
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
async function main(){
|
186
|
+
let choice = await input("Search anime.")
|
187
|
+
let anime = await process_search(choice)
|
188
|
+
let link = await get_video_link(anime.episodes[anime.episode_number])
|
189
|
+
let player = new VLC(link)
|
190
|
+
this.process.on('close', (code) => {
|
191
|
+
console.log("exit")
|
192
|
+
})
|
193
|
+
}
|
194
|
+
|
195
|
+
main()
|
196
|
+
|
package/bin/temp.txt
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"success":false,"data":"Video not found or has been removed"}
|
package/package.json
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
{
|
2
|
+
"name": "ani-cli-npm",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"description": "ani-cli tool rewritten as npm package",
|
5
|
+
"main": "index.js",
|
6
|
+
"scripts": {
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
8
|
+
},
|
9
|
+
"keywords": [
|
10
|
+
"anime",
|
11
|
+
"ani-cli"
|
12
|
+
],
|
13
|
+
"author": "bumpkin-pi",
|
14
|
+
"license": "ISC",
|
15
|
+
"bin": {
|
16
|
+
"multiply": "bin/index.js"
|
17
|
+
},
|
18
|
+
"dependencies": {
|
19
|
+
"http-proxy-agent": "^5.0.0",
|
20
|
+
"https-proxy-agent": "^5.0.1",
|
21
|
+
"simple-input": "^1.0.1",
|
22
|
+
"vlc-simple-player": "^0.5.1"
|
23
|
+
}
|
24
|
+
}
|