ani-cli-npm 1.0.0 → 1.0.2

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 CHANGED
@@ -1,17 +1,11 @@
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 http = require('http');
4
6
  //const HttpsProxyAgent = require('https-proxy-agent');
5
- const VLC = require('vlc-simple-player');
6
7
  //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
8
 
14
- const download_dir = "./../downloads/"
15
9
  const gogohd_url="https://gogohd.net/"
16
10
  const base_url="https://animixplay.to"
17
11
 
@@ -26,6 +20,17 @@ const colors = {
26
20
  White: "\x1b[37m%s\x1b[0m"
27
21
  }
28
22
 
23
+ let config = {
24
+ quality: "best",
25
+ player: "VLC"
26
+ }
27
+
28
+ async function input(message){
29
+ if (message){
30
+ console.log(colors.Magenta,message)
31
+ }
32
+ return await prompt(">")
33
+ }
29
34
 
30
35
  async function curl(url, method="GET"){
31
36
  await fetch(url, {
@@ -82,14 +87,17 @@ async function search_anime(search){
82
87
  async function episode_list(anime_id){
83
88
  let html = (await curl(base_url+"/v1/"+anime_id)).split("\n")
84
89
  let lines = ""
90
+
85
91
  for (let x in html){
86
92
  if(matchRuleShort(html[x], "*<div id=\"epslistplace\"*")){
87
93
  lines = (html[x])
88
94
  }
89
95
  }
96
+
90
97
  lines = lines.slice(55, lines.length).replace("}</div>", "")
91
98
  lines = "{" + lines.slice(lines.indexOf(",")+1, lines.length) + "}"
92
99
  lines = JSON.parse(lines)
100
+
93
101
  let json = []
94
102
  for (x in lines){
95
103
  json.push(lines[x])
@@ -99,20 +107,12 @@ async function episode_list(anime_id){
99
107
 
100
108
 
101
109
  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
- });
110
+ 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
111
  }
112
112
 
113
113
 
114
114
  async function selection(options, prompt){
115
- let selection
115
+ let selection = 0
116
116
  while (!(selection <= options && selection > 1)){
117
117
  selection = (await input(prompt))
118
118
  if (selection <= options && selection >= 1){
@@ -124,23 +124,27 @@ async function selection(options, prompt){
124
124
  }
125
125
 
126
126
 
127
- async function process_search(query){
127
+ async function process_search(query) {
128
128
  console.log("Searching: "+query)
129
+
129
130
  let search_results = await search_anime(query)
130
- if (!search_results[0]){
131
+ if (!search_results[0]) {
131
132
  console.log("No results.")
132
133
  return 0
133
- }else{
134
- for (x in search_results){
134
+ } else {
135
+ for (x in search_results) {
135
136
  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
  }
137
138
  }
139
+
138
140
  let anime_id = search_results[await selection(search_results.length, "Please select an anime.")-1]
139
141
  let episodes = await episode_list(anime_id)
140
142
  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
143
+
144
+ return {
145
+ anime_id: anime_id,
146
+ episodes: episodes,
147
+ episode_number: episode_number
144
148
  }
145
149
  }
146
150
 
@@ -170,6 +174,7 @@ async function generate_link(provider, html){
170
174
  console.log("Error, no fb_id found.")
171
175
  return 0
172
176
  }
177
+
173
178
  //let refr = "https://fembed-hd.com/v/"+fb_id
174
179
  let post = await curl("https://fembed-hd.com/api/source/"+fb_id, "POST")
175
180
  post = post.slice(post.indexOf(",\"data\":[{\"file\":\"")+18, post.length)
@@ -179,17 +184,83 @@ async function generate_link(provider, html){
179
184
  }
180
185
 
181
186
 
187
+ async function play(link, player="VLC"){
188
+ console.clear()
189
+ if (player === "VLC"){
190
+ console.log(colors.Yellow, "Loading VLC... ")
191
+ let player = new VLC(link)
192
+ console.log(colors.Yellow, "Playing video.\n")
193
+ console.log("VLC;")
194
+ console.log(colors.Cyan, "1) Show Link")
195
+ console.log(colors.Cyan, "2) Quit")
196
+ choice = parseInt(await input("select;"))
197
+ switch (choice){
198
+ case 1:
199
+ console.log(colors.Yellow, "Link: "+link)
200
+ break
201
+ case 2:
202
+ process.exit()
203
+ break
204
+ }
205
+ }else{
182
206
 
207
+ }
208
+ }
183
209
 
184
-
185
- async function main(){
186
- let choice = await input("Search anime.")
210
+ async function search(){
211
+ console.clear()
212
+ console.log(colors.Blue, "Search...")
213
+ let choice = await input("")
187
214
  let anime = await process_search(choice)
215
+
216
+ console.log("\n")
217
+
218
+ console.log(colors.Blue, "Indexing video...")
188
219
  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
- })
220
+ console.clear()
221
+ console.log(colors.Blue, "Episode found.\n")
222
+ console.log(colors.Cyan, "1) Play")
223
+ console.log(colors.Cyan, "2) Download")
224
+ console.log(colors.Cyan, "3) Show Link")
225
+ console.log(colors.Cyan, "4) quit")
226
+ choice = parseInt(await input("select;"))
227
+ switch (choice){
228
+ case 1:
229
+ await play(link, config.player)
230
+ break
231
+ case 2:
232
+ download(link, anime.anime_id+anime.episode_number+".mp4")
233
+ break
234
+ case 3:
235
+ console.log(colors.Yellow, "Link: "+link)
236
+ break
237
+ case 4:
238
+ process.exit()
239
+ }
240
+
241
+
242
+
243
+ }
244
+
245
+
246
+ async function main(){
247
+ console.clear()
248
+ console.log(colors.Blue, "Welcome to Ani-Cli-npm")
249
+ console.log(colors.Cyan, "1) Search")
250
+ console.log(colors.Cyan, "2) config")
251
+ console.log(colors.Cyan, "3) quit")
252
+ let choice = parseInt(await input("select;"))
253
+
254
+ switch (choice){
255
+ case 1:
256
+ await search()
257
+ break
258
+ case 2:
259
+ break
260
+ case 3:
261
+ console.log(colors.Black, "Exiting...")
262
+ process.exit()
263
+ }
193
264
  }
194
265
 
195
266
  main()
package/package.json CHANGED
@@ -1,14 +1,17 @@
1
1
  {
2
2
  "name": "ani-cli-npm",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
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",
package/bin/temp.txt DELETED
@@ -1 +0,0 @@
1
- {"success":false,"data":"Video not found or has been removed"}