ani-cli-npm 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/index.js +107 -33
- package/package.json +6 -2
- package/bin/temp.txt +0 -1
package/bin/index.js
CHANGED
@@ -1,17 +1,13 @@
|
|
1
1
|
#! /usr/bin/env node
|
2
|
+
|
3
|
+
const VLC = require('vlc-simple-player');
|
4
|
+
const prompt = require("simple-input");
|
2
5
|
const fs = require("fs");
|
3
|
-
const
|
6
|
+
const downloadsFolder = require('downloads-folder');
|
4
7
|
//const HttpsProxyAgent = require('https-proxy-agent');
|
5
|
-
const VLC = require('vlc-simple-player');
|
6
8
|
//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
9
|
|
14
|
-
const download_dir =
|
10
|
+
const download_dir = downloadsFolder()
|
15
11
|
const gogohd_url="https://gogohd.net/"
|
16
12
|
const base_url="https://animixplay.to"
|
17
13
|
|
@@ -26,6 +22,18 @@ const colors = {
|
|
26
22
|
White: "\x1b[37m%s\x1b[0m"
|
27
23
|
}
|
28
24
|
|
25
|
+
let config = {
|
26
|
+
download_dir: download_dir,
|
27
|
+
quality: "best",
|
28
|
+
player: "VLC"
|
29
|
+
}
|
30
|
+
|
31
|
+
async function input(message){
|
32
|
+
if (message){
|
33
|
+
console.log(colors.Magenta,message)
|
34
|
+
}
|
35
|
+
return await prompt(">")
|
36
|
+
}
|
29
37
|
|
30
38
|
async function curl(url, method="GET"){
|
31
39
|
await fetch(url, {
|
@@ -82,14 +90,17 @@ async function search_anime(search){
|
|
82
90
|
async function episode_list(anime_id){
|
83
91
|
let html = (await curl(base_url+"/v1/"+anime_id)).split("\n")
|
84
92
|
let lines = ""
|
93
|
+
|
85
94
|
for (let x in html){
|
86
95
|
if(matchRuleShort(html[x], "*<div id=\"epslistplace\"*")){
|
87
96
|
lines = (html[x])
|
88
97
|
}
|
89
98
|
}
|
99
|
+
|
90
100
|
lines = lines.slice(55, lines.length).replace("}</div>", "")
|
91
101
|
lines = "{" + lines.slice(lines.indexOf(",")+1, lines.length) + "}"
|
92
102
|
lines = JSON.parse(lines)
|
103
|
+
|
93
104
|
let json = []
|
94
105
|
for (x in lines){
|
95
106
|
json.push(lines[x])
|
@@ -99,20 +110,12 @@ async function episode_list(anime_id){
|
|
99
110
|
|
100
111
|
|
101
112
|
async function download(url, name){
|
102
|
-
|
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
|
-
});
|
113
|
+
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.")
|
111
114
|
}
|
112
115
|
|
113
116
|
|
114
117
|
async function selection(options, prompt){
|
115
|
-
let selection
|
118
|
+
let selection = 0
|
116
119
|
while (!(selection <= options && selection > 1)){
|
117
120
|
selection = (await input(prompt))
|
118
121
|
if (selection <= options && selection >= 1){
|
@@ -124,23 +127,27 @@ async function selection(options, prompt){
|
|
124
127
|
}
|
125
128
|
|
126
129
|
|
127
|
-
async function process_search(query){
|
130
|
+
async function process_search(query) {
|
128
131
|
console.log("Searching: "+query)
|
132
|
+
|
129
133
|
let search_results = await search_anime(query)
|
130
|
-
if (!search_results[0]){
|
134
|
+
if (!search_results[0]) {
|
131
135
|
console.log("No results.")
|
132
136
|
return 0
|
133
|
-
}else{
|
134
|
-
for (x in search_results){
|
137
|
+
} else {
|
138
|
+
for (x in search_results) {
|
135
139
|
console.log(colors.Cyan,`${parseInt(x)+1})${" ".repeat(((search_results.length).toString().length+1)-((parseInt(x)+1).toString().length))}${search_results[x].replaceAll("-", " ")}`)
|
136
140
|
}
|
137
141
|
}
|
142
|
+
|
138
143
|
let anime_id = search_results[await selection(search_results.length, "Please select an anime.")-1]
|
139
144
|
let episodes = await episode_list(anime_id)
|
140
145
|
let episode_number = await selection(episodes.length, `Please select an episode (1-${episodes.length}).`)
|
141
|
-
|
142
|
-
|
143
|
-
|
146
|
+
|
147
|
+
return {
|
148
|
+
anime_id: anime_id,
|
149
|
+
episodes: episodes,
|
150
|
+
episode_number: episode_number
|
144
151
|
}
|
145
152
|
}
|
146
153
|
|
@@ -170,6 +177,7 @@ async function generate_link(provider, html){
|
|
170
177
|
console.log("Error, no fb_id found.")
|
171
178
|
return 0
|
172
179
|
}
|
180
|
+
|
173
181
|
//let refr = "https://fembed-hd.com/v/"+fb_id
|
174
182
|
let post = await curl("https://fembed-hd.com/api/source/"+fb_id, "POST")
|
175
183
|
post = post.slice(post.indexOf(",\"data\":[{\"file\":\"")+18, post.length)
|
@@ -179,17 +187,83 @@ async function generate_link(provider, html){
|
|
179
187
|
}
|
180
188
|
|
181
189
|
|
190
|
+
async function play(link, player="VLC"){
|
191
|
+
console.clear()
|
192
|
+
if (player === "VLC"){
|
193
|
+
console.log(colors.Yellow, "Loading VLC... ")
|
194
|
+
let player = new VLC(link)
|
195
|
+
console.log(colors.Yellow, "Playing video.\n")
|
196
|
+
console.log("VLC;")
|
197
|
+
console.log(colors.Cyan, "1) Show Link")
|
198
|
+
console.log(colors.Cyan, "2) Quit")
|
199
|
+
choice = parseInt(await input("select;"))
|
200
|
+
switch (choice){
|
201
|
+
case 1:
|
202
|
+
console.log(colors.Yellow, "Link: "+link)
|
203
|
+
break
|
204
|
+
case 2:
|
205
|
+
process.exit()
|
206
|
+
break
|
207
|
+
}
|
208
|
+
}else{
|
182
209
|
|
210
|
+
}
|
211
|
+
}
|
183
212
|
|
184
|
-
|
185
|
-
|
186
|
-
|
213
|
+
async function search(){
|
214
|
+
console.clear()
|
215
|
+
console.log(colors.Blue, "Search...")
|
216
|
+
let choice = await input("")
|
187
217
|
let anime = await process_search(choice)
|
218
|
+
|
219
|
+
console.log("\n")
|
220
|
+
|
221
|
+
console.log(colors.Blue, "Indexing video...")
|
188
222
|
let link = await get_video_link(anime.episodes[anime.episode_number])
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
223
|
+
console.clear()
|
224
|
+
console.log(colors.Blue, "Episode found.\n")
|
225
|
+
console.log(colors.Cyan, "1) Play")
|
226
|
+
console.log(colors.Cyan, "2) Download")
|
227
|
+
console.log(colors.Cyan, "3) Show Link")
|
228
|
+
console.log(colors.Cyan, "4) quit")
|
229
|
+
choice = parseInt(await input("select;"))
|
230
|
+
switch (choice){
|
231
|
+
case 1:
|
232
|
+
await play(link, config.player)
|
233
|
+
break
|
234
|
+
case 2:
|
235
|
+
download(link, anime.anime_id+anime.episode_number+".mp4")
|
236
|
+
break
|
237
|
+
case 3:
|
238
|
+
console.log(colors.Yellow, "Link: "+link)
|
239
|
+
break
|
240
|
+
case 4:
|
241
|
+
process.exit()
|
242
|
+
}
|
243
|
+
|
244
|
+
|
245
|
+
|
246
|
+
}
|
247
|
+
|
248
|
+
|
249
|
+
async function main(){
|
250
|
+
console.clear()
|
251
|
+
console.log(colors.Blue, "Welcome to Ani-Cli-npm")
|
252
|
+
console.log(colors.Cyan, "1) Search")
|
253
|
+
console.log(colors.Cyan, "2) config")
|
254
|
+
console.log(colors.Cyan, "3) quit")
|
255
|
+
let choice = parseInt(await input("select;"))
|
256
|
+
|
257
|
+
switch (choice){
|
258
|
+
case 1:
|
259
|
+
await search()
|
260
|
+
break
|
261
|
+
case 2:
|
262
|
+
break
|
263
|
+
case 3:
|
264
|
+
console.log(colors.Black, "Exiting...")
|
265
|
+
process.exit()
|
266
|
+
}
|
193
267
|
}
|
194
268
|
|
195
269
|
main()
|
package/package.json
CHANGED
@@ -1,14 +1,17 @@
|
|
1
1
|
{
|
2
2
|
"name": "ani-cli-npm",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.1",
|
4
4
|
"description": "ani-cli tool rewritten as npm package",
|
5
5
|
"main": "index.js",
|
6
6
|
"scripts": {
|
7
|
+
"start": "node bin/index.js",
|
7
8
|
"test": "echo \"Error: no test specified\" && exit 1"
|
8
9
|
},
|
9
10
|
"keywords": [
|
10
11
|
"anime",
|
11
|
-
"ani-cli"
|
12
|
+
"ani-cli",
|
13
|
+
"anime",
|
14
|
+
"client"
|
12
15
|
],
|
13
16
|
"author": "bumpkin-pi",
|
14
17
|
"license": "ISC",
|
@@ -16,6 +19,7 @@
|
|
16
19
|
"multiply": "bin/index.js"
|
17
20
|
},
|
18
21
|
"dependencies": {
|
22
|
+
"downloads-folder": "^3.0.3",
|
19
23
|
"http-proxy-agent": "^5.0.0",
|
20
24
|
"https-proxy-agent": "^5.0.1",
|
21
25
|
"simple-input": "^1.0.1",
|
package/bin/temp.txt
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"success":false,"data":"Video not found or has been removed"}
|