ani-cli-npm 2.1.4 → 2.1.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.
- package/.idea/ani-cli-npm.iml +11 -11
- package/.idea/discord.xml +6 -6
- package/.idea/git_toolbox_prj.xml +15 -0
- package/.idea/inspectionProfiles/Project_Default.xml +10 -0
- package/.idea/jsLibraryMappings.xml +5 -5
- package/.idea/modules.xml +7 -7
- package/.idea/vcs.xml +5 -5
- package/README.MD +79 -77
- package/bin/Anime.js +409 -393
- package/bin/IO/help.js +59 -0
- package/bin/IO/input.js +89 -0
- package/bin/cache.js +79 -0
- package/bin/change_config.js +99 -0
- package/bin/core_utils/curl.js +35 -35
- package/bin/core_utils/interfaces.js +2 -2
- package/bin/core_utils/libs.js +12 -12
- package/bin/core_utils/regex.js +8 -8
- package/bin/cover_manager.js +3 -0
- package/bin/curl.js +35 -0
- package/bin/download.js +36 -36
- package/bin/file_managment/cache.js +87 -87
- package/bin/file_managment/change_config.js +122 -121
- package/bin/file_managment/load_config.js +111 -110
- package/bin/generate_link.js +47 -47
- package/bin/help.js +59 -59
- package/bin/index.js +164 -159
- package/bin/input.js +89 -89
- package/bin/interfaces.js +2 -0
- package/bin/libs.js +12 -0
- package/bin/load_config.js +106 -0
- package/bin/regex.js +8 -0
- package/bin/search_anime.js +39 -39
- package/bin/url_genoration/generate_link.js +47 -0
- package/bin/url_genoration/search_anime.js +39 -0
- package/bin/video_quality.js +6 -0
- package/package.json +45 -45
- package/src/Anime.ts +427 -0
- package/src/IO/help.ts +64 -0
- package/src/IO/input.ts +92 -0
- package/src/core_utils/curl.ts +32 -0
- package/src/core_utils/interfaces.ts +25 -0
- package/src/core_utils/libs.ts +13 -0
- package/src/core_utils/regex.ts +5 -0
- package/src/cover_manager.ts +9 -0
- package/src/download.ts +35 -0
- package/src/file_managment/cache.ts +58 -0
- package/src/file_managment/change_config.ts +126 -0
- package/src/file_managment/load_config.ts +79 -0
- package/src/index.ts +143 -0
- package/src/url_genoration/generate_link.ts +53 -0
- package/src/url_genoration/search_anime.ts +41 -0
- package/src/video_quality.ts +6 -0
- package/temp.sh +676 -0
- package/tsconfig.json +109 -109
package/bin/generate_link.js
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generate_link = void 0;
|
|
4
|
-
const gogohd_url = "https://gogohd.
|
|
5
|
-
const base_url = "https://animixplay.to";
|
|
6
|
-
const curl_1 = require("./core_utils/curl");
|
|
7
|
-
const regex_1 = require("./core_utils/regex");
|
|
8
|
-
async function generate_link(provider, id, player) {
|
|
9
|
-
let html_ = "";
|
|
10
|
-
let provider_name = "";
|
|
11
|
-
switch (provider) {
|
|
12
|
-
case 1:
|
|
13
|
-
html_ = await (0, curl_1.curl)(`${gogohd_url}streaming.php?id=${id}`);
|
|
14
|
-
provider_name = 'Xstreamcdn';
|
|
15
|
-
console.log(`Fetching ${provider_name} links...`);
|
|
16
|
-
let html = html_.split("\n");
|
|
17
|
-
let fb_id = "";
|
|
18
|
-
for (let x in html) {
|
|
19
|
-
if ((0, regex_1.RegexParse)(html[x], "*<li class=\"linkserver\" data-status=\"1\" data-video=\"https://fembed9hd.com/v/*")) {
|
|
20
|
-
fb_id = html[x].slice(html[x].indexOf("/v/") + 3, html[x].indexOf("\">X"));
|
|
21
|
-
break;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
if (!fb_id) {
|
|
25
|
-
console.log("Error, no fb_id found.");
|
|
26
|
-
return 0;
|
|
27
|
-
}
|
|
28
|
-
//let refr = "https://fembed-hd.com/v/"+fb_id
|
|
29
|
-
let post = await (0, curl_1.curl)("https://fembed-hd.com/api/source/" + fb_id, "POST");
|
|
30
|
-
post = post.slice(post.indexOf(",\"data\":[{\"file\":\"") + 18, post.length);
|
|
31
|
-
post = post.slice(0, post.indexOf("\"")).replaceAll("\\/", "/");
|
|
32
|
-
return post;
|
|
33
|
-
case 2:
|
|
34
|
-
provider_name = 'Animixplay';
|
|
35
|
-
console.log(`Fetching ${provider_name} links...`);
|
|
36
|
-
let buffer = new Buffer(id);
|
|
37
|
-
let enc_id = buffer.toString("base64");
|
|
38
|
-
buffer = new Buffer(id + "LTXs3GrU8we9O" + enc_id);
|
|
39
|
-
let ani_id = buffer.toString("base64");
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return buffer.toString("utf-8");
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
exports.generate_link = generate_link;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generate_link = void 0;
|
|
4
|
+
const gogohd_url = "https://gogohd.net/";
|
|
5
|
+
const base_url = "https://animixplay.to";
|
|
6
|
+
const curl_1 = require("./core_utils/curl");
|
|
7
|
+
const regex_1 = require("./core_utils/regex");
|
|
8
|
+
async function generate_link(provider, id, player) {
|
|
9
|
+
let html_ = "";
|
|
10
|
+
let provider_name = "";
|
|
11
|
+
switch (provider) {
|
|
12
|
+
case 1:
|
|
13
|
+
html_ = await (0, curl_1.curl)(`${gogohd_url}streaming.php?id=${id}`);
|
|
14
|
+
provider_name = 'Xstreamcdn';
|
|
15
|
+
console.log(`Fetching ${provider_name} links...`);
|
|
16
|
+
let html = html_.split("\n");
|
|
17
|
+
let fb_id = "";
|
|
18
|
+
for (let x in html) {
|
|
19
|
+
if ((0, regex_1.RegexParse)(html[x], "*<li class=\"linkserver\" data-status=\"1\" data-video=\"https://fembed9hd.com/v/*")) {
|
|
20
|
+
fb_id = html[x].slice(html[x].indexOf("/v/") + 3, html[x].indexOf("\">X"));
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (!fb_id) {
|
|
25
|
+
console.log("Error, no fb_id found.");
|
|
26
|
+
return 0;
|
|
27
|
+
}
|
|
28
|
+
//let refr = "https://fembed-hd.com/v/"+fb_id
|
|
29
|
+
let post = await (0, curl_1.curl)("https://fembed-hd.com/api/source/" + fb_id, "POST");
|
|
30
|
+
post = post.slice(post.indexOf(",\"data\":[{\"file\":\"") + 18, post.length);
|
|
31
|
+
post = post.slice(0, post.indexOf("\"")).replaceAll("\\/", "/");
|
|
32
|
+
return post;
|
|
33
|
+
case 2:
|
|
34
|
+
provider_name = 'Animixplay';
|
|
35
|
+
console.log(`Fetching ${provider_name} links...`);
|
|
36
|
+
let buffer = new Buffer(id);
|
|
37
|
+
let enc_id = buffer.toString("base64");
|
|
38
|
+
buffer = new Buffer(id + "LTXs3GrU8we9O" + enc_id);
|
|
39
|
+
let ani_id = buffer.toString("base64");
|
|
40
|
+
buffer = Buffer.from((await (0, curl_1.curl)(`${base_url}/api/live${ani_id}`, "GET", true)).split("#")[1], "base64");
|
|
41
|
+
if (player === "BROWSER") {
|
|
42
|
+
return `${base_url}/api/live${ani_id}`;
|
|
43
|
+
}
|
|
44
|
+
return buffer.toString("utf-8");
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.generate_link = generate_link;
|
package/bin/help.js
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.help = void 0;
|
|
4
|
-
const input_1 = require("./input");
|
|
5
|
-
const chalk = require("chalk");
|
|
6
|
-
const helps = [
|
|
7
|
-
(async () => {
|
|
8
|
-
console.log(chalk.cyan("Playing anime: \n" +
|
|
9
|
-
" Search: \n" +
|
|
10
|
-
" Search for a show/movie. This will search on gogoanime.dk.\n" +
|
|
11
|
-
" Episode selection: \n" +
|
|
12
|
-
" Once an anime is selected, select an episode. If there is only 1 episode " +
|
|
13
|
-
"(in the case of a movie), the episode will be played automatically.\n" +
|
|
14
|
-
" The episode selected will be played in the video player selected in options. Info on video players can be found in options help."));
|
|
15
|
-
await help();
|
|
16
|
-
return;
|
|
17
|
-
}),
|
|
18
|
-
(async () => {
|
|
19
|
-
console.log(chalk.cyan("Downloading anime: \n" +
|
|
20
|
-
" Search: \n" +
|
|
21
|
-
" Search for a show/movie. This will search on gogoanime.dk.\n" +
|
|
22
|
-
" Episode selection: \n" +
|
|
23
|
-
" Once an anime is selected, select a start episode and an end episode. If there is only 1 episode " +
|
|
24
|
-
"(in the case of a movie), the episode will be downloaded automatically. Download folder can be changed in options. Default to run location.\n" +
|
|
25
|
-
" The selected episodes will be downloaded. It is common for episode links to fail to be fetched, when this happens the episode will be passed, then reattempted in another pass.\n" +
|
|
26
|
-
" Episodes sourced from Animixplay links will download m3u8 file, which you will have difficulty playing, if you are able to at all."));
|
|
27
|
-
await help();
|
|
28
|
-
return;
|
|
29
|
-
}),
|
|
30
|
-
(async () => {
|
|
31
|
-
console.log(chalk.cyan("Options: \n" +
|
|
32
|
-
" Player: \n" +
|
|
33
|
-
" Player used to play anime.\n" +
|
|
34
|
-
" Proxy: \n" +
|
|
35
|
-
" https proxy address and port in form ip:port. This is not currently implemented.\n" +
|
|
36
|
-
" User agent:\n" +
|
|
37
|
-
" node-fetch user agent.\n" +
|
|
38
|
-
" Downloads folder:\n" +
|
|
39
|
-
" Folder to place downloaded episodes.\n" +
|
|
40
|
-
" MPV socket connection file:\n" +
|
|
41
|
-
" File for mpv socket, used to control mpv instance with outside tools.\n" +
|
|
42
|
-
" VLC socket:\n" +
|
|
43
|
-
" VLC http control socket\n" +
|
|
44
|
-
" VLC pass:\n" +
|
|
45
|
-
" VLC http control password\n" +
|
|
46
|
-
" W2G api token:\n" +
|
|
47
|
-
" Your user access token for w2g.tv. Can be found at https://w2g.tv/en/account/edit_user under Tools/API\n"));
|
|
48
|
-
await help();
|
|
49
|
-
return;
|
|
50
|
-
}),
|
|
51
|
-
(async () => {
|
|
52
|
-
return;
|
|
53
|
-
})
|
|
54
|
-
];
|
|
55
|
-
async function help() {
|
|
56
|
-
console.log(chalk.cyan("Help page select: \n"));
|
|
57
|
-
return helps[await (0, input_1.selection)(["Playing", "Downloading", "Options", "Quit"], ["p", "d", "o", "q"])]();
|
|
58
|
-
}
|
|
59
|
-
exports.help = help;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.help = void 0;
|
|
4
|
+
const input_1 = require("./input");
|
|
5
|
+
const chalk = require("chalk");
|
|
6
|
+
const helps = [
|
|
7
|
+
(async () => {
|
|
8
|
+
console.log(chalk.cyan("Playing anime: \n" +
|
|
9
|
+
" Search: \n" +
|
|
10
|
+
" Search for a show/movie. This will search on gogoanime.dk.\n" +
|
|
11
|
+
" Episode selection: \n" +
|
|
12
|
+
" Once an anime is selected, select an episode. If there is only 1 episode " +
|
|
13
|
+
"(in the case of a movie), the episode will be played automatically.\n" +
|
|
14
|
+
" The episode selected will be played in the video player selected in options. Info on video players can be found in options help."));
|
|
15
|
+
await help();
|
|
16
|
+
return;
|
|
17
|
+
}),
|
|
18
|
+
(async () => {
|
|
19
|
+
console.log(chalk.cyan("Downloading anime: \n" +
|
|
20
|
+
" Search: \n" +
|
|
21
|
+
" Search for a show/movie. This will search on gogoanime.dk.\n" +
|
|
22
|
+
" Episode selection: \n" +
|
|
23
|
+
" Once an anime is selected, select a start episode and an end episode. If there is only 1 episode " +
|
|
24
|
+
"(in the case of a movie), the episode will be downloaded automatically. Download folder can be changed in options. Default to run location.\n" +
|
|
25
|
+
" The selected episodes will be downloaded. It is common for episode links to fail to be fetched, when this happens the episode will be passed, then reattempted in another pass.\n" +
|
|
26
|
+
" Episodes sourced from Animixplay links will download m3u8 file, which you will have difficulty playing, if you are able to at all."));
|
|
27
|
+
await help();
|
|
28
|
+
return;
|
|
29
|
+
}),
|
|
30
|
+
(async () => {
|
|
31
|
+
console.log(chalk.cyan("Options: \n" +
|
|
32
|
+
" Player: \n" +
|
|
33
|
+
" Player used to play anime.\n" +
|
|
34
|
+
" Proxy: \n" +
|
|
35
|
+
" https proxy address and port in form ip:port. This is not currently implemented.\n" +
|
|
36
|
+
" User agent:\n" +
|
|
37
|
+
" node-fetch user agent.\n" +
|
|
38
|
+
" Downloads folder:\n" +
|
|
39
|
+
" Folder to place downloaded episodes.\n" +
|
|
40
|
+
" MPV socket connection file:\n" +
|
|
41
|
+
" File for mpv socket, used to control mpv instance with outside tools.\n" +
|
|
42
|
+
" VLC socket:\n" +
|
|
43
|
+
" VLC http control socket\n" +
|
|
44
|
+
" VLC pass:\n" +
|
|
45
|
+
" VLC http control password\n" +
|
|
46
|
+
" W2G api token:\n" +
|
|
47
|
+
" Your user access token for w2g.tv. Can be found at https://w2g.tv/en/account/edit_user under Tools/API\n"));
|
|
48
|
+
await help();
|
|
49
|
+
return;
|
|
50
|
+
}),
|
|
51
|
+
(async () => {
|
|
52
|
+
return;
|
|
53
|
+
})
|
|
54
|
+
];
|
|
55
|
+
async function help() {
|
|
56
|
+
console.log(chalk.cyan("Help page select: \n"));
|
|
57
|
+
return helps[await (0, input_1.selection)(["Playing", "Downloading", "Options", "Quit"], ["p", "d", "o", "q"])]();
|
|
58
|
+
}
|
|
59
|
+
exports.help = help;
|
package/bin/index.js
CHANGED
|
@@ -1,159 +1,164 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
-
if (mod && mod.__esModule) return mod;
|
|
21
|
-
var result = {};
|
|
22
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
-
__setModuleDefault(result, mod);
|
|
24
|
-
return result;
|
|
25
|
-
};
|
|
26
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
|
-
};
|
|
29
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
const process = __importStar(require("process"));
|
|
31
|
-
//process.removeAllListeners() // Ignore warning
|
|
32
|
-
//
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
let
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
let
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
await
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
const process = __importStar(require("process"));
|
|
31
|
+
//process.removeAllListeners() // Ignore warning
|
|
32
|
+
// TODO: Use terminal-kit properly
|
|
33
|
+
// External
|
|
34
|
+
const appdata_path_1 = __importDefault(require("appdata-path"));
|
|
35
|
+
const terminal_kit = require("terminal-kit");
|
|
36
|
+
const chalk = require("chalk");
|
|
37
|
+
// Internal
|
|
38
|
+
const Anime_1 = require("./Anime");
|
|
39
|
+
const search_anime_1 = require("./url_genoration/search_anime");
|
|
40
|
+
const load_config_1 = require("./file_managment/load_config");
|
|
41
|
+
const input_1 = require("./IO/input");
|
|
42
|
+
const change_config_1 = require("./file_managment/change_config");
|
|
43
|
+
const cache_1 = require("./file_managment/cache");
|
|
44
|
+
const download_1 = require("./download");
|
|
45
|
+
const help_1 = require("./IO/help");
|
|
46
|
+
// import {display_cover} from "./cover_manager";
|
|
47
|
+
const app_data_folder = (0, appdata_path_1.default)();
|
|
48
|
+
const cache_folder = app_data_folder + "/ani-cli-npm";
|
|
49
|
+
(0, load_config_1.make_config_dir)(cache_folder, true);
|
|
50
|
+
// display_cover()
|
|
51
|
+
console.clear();
|
|
52
|
+
terminal_kit.draw("https://gogocdn.net/cover/yuri-on-ice-dub.png");
|
|
53
|
+
async function main() {
|
|
54
|
+
let config = (0, load_config_1.load_config)(cache_folder);
|
|
55
|
+
console.log(chalk.magenta("Ani-cli-npm!\n"));
|
|
56
|
+
if (config.most_recent.anime_id !== "") {
|
|
57
|
+
console.log(chalk.grey(`Most recently played: ${config.most_recent.anime_id} episode ${config.most_recent.episode_number + 1}\n`));
|
|
58
|
+
}
|
|
59
|
+
let choice = await (0, input_1.selection)([
|
|
60
|
+
"Search",
|
|
61
|
+
"Continue",
|
|
62
|
+
"Download",
|
|
63
|
+
"Option",
|
|
64
|
+
"Clear cache",
|
|
65
|
+
"Help",
|
|
66
|
+
"Quit",
|
|
67
|
+
], ["s", "c", "d", "o", " ", "h", "q"], ((thing) => { return chalk.magenta(thing); }), ((thing) => { return chalk.magenta(thing); }));
|
|
68
|
+
switch (choice) {
|
|
69
|
+
case 0: // Search
|
|
70
|
+
let temp_ = await (0, search_anime_1.search)();
|
|
71
|
+
if (temp_ == 1) {
|
|
72
|
+
await main();
|
|
73
|
+
process.exit();
|
|
74
|
+
}
|
|
75
|
+
let anime_id = temp_;
|
|
76
|
+
let anime = new Anime_1.Anime();
|
|
77
|
+
await anime.init(anime_id, cache_folder);
|
|
78
|
+
let episode_number;
|
|
79
|
+
if (anime.episode_list.length == 1) {
|
|
80
|
+
episode_number = 1;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
console.log(`Select episode [1-${anime.episode_list.length}] ${(anime.most_recent != 0) ? `Or C to continue from ep${anime.most_recent + 1}` : ""}`);
|
|
84
|
+
episode_number = await (0, input_1.number_input)(anime.episode_list.length, 1, (anime.most_recent != 0) ? ["c"] : [], (anime.most_recent != 0) ? [anime.most_recent + 1] : []);
|
|
85
|
+
}
|
|
86
|
+
await anime.play_head(episode_number - 1, config, cache_folder);
|
|
87
|
+
if (anime.player.hasOwnProperty("quit")) {
|
|
88
|
+
await anime.player.player.quit();
|
|
89
|
+
}
|
|
90
|
+
await main();
|
|
91
|
+
break;
|
|
92
|
+
case 1: // Continue
|
|
93
|
+
if (config.most_recent.anime_id == "") {
|
|
94
|
+
console.clear();
|
|
95
|
+
console.log(chalk.red("No episode played recently"));
|
|
96
|
+
await main();
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
let continue_anime = new Anime_1.Anime();
|
|
100
|
+
await continue_anime.init(config.most_recent.anime_id, cache_folder);
|
|
101
|
+
await continue_anime.play_head(config.most_recent.episode_number, config, cache_folder);
|
|
102
|
+
try {
|
|
103
|
+
await continue_anime.player.player.quit();
|
|
104
|
+
}
|
|
105
|
+
catch { }
|
|
106
|
+
await main();
|
|
107
|
+
break;
|
|
108
|
+
case 2: // Download
|
|
109
|
+
let code = await (0, download_1.download)(cache_folder, config);
|
|
110
|
+
if (code == 1) {
|
|
111
|
+
console.log(chalk.red("Error downloading episodes"));
|
|
112
|
+
}
|
|
113
|
+
break;
|
|
114
|
+
case 3: // Options
|
|
115
|
+
let temp = structuredClone(config);
|
|
116
|
+
let exit_code;
|
|
117
|
+
while (true) {
|
|
118
|
+
// @ts-ignore
|
|
119
|
+
temp, exit_code = await (0, change_config_1.config_)(temp);
|
|
120
|
+
if (exit_code === 1) {
|
|
121
|
+
config = temp;
|
|
122
|
+
//proxyAgent = new HttpsProxyAgent(config.proxy);
|
|
123
|
+
console.clear();
|
|
124
|
+
try {
|
|
125
|
+
(0, load_config_1.write_config)(cache_folder, config);
|
|
126
|
+
console.log(chalk.yellow("Config changed."));
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
console.log(chalk.red("Error writing to .conf file."));
|
|
130
|
+
}
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
else if (exit_code === 2) {
|
|
134
|
+
temp = config;
|
|
135
|
+
console.clear();
|
|
136
|
+
console.log(chalk.yellow("Config changes disregarded."));
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
await main();
|
|
141
|
+
break;
|
|
142
|
+
case 4:
|
|
143
|
+
console.clear();
|
|
144
|
+
console.log(chalk.yellow("Warning, this will also clear your current position in each anime, are you sure you want to do this?"));
|
|
145
|
+
if (await (0, input_1.selection)(["yes", "no"], ["y", "n"]) == 0) {
|
|
146
|
+
await (0, cache_1.clear_cache)(cache_folder);
|
|
147
|
+
console.clear();
|
|
148
|
+
console.log(chalk.grey("Cache cleared"));
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
console.clear();
|
|
152
|
+
}
|
|
153
|
+
await main();
|
|
154
|
+
break;
|
|
155
|
+
case 5:
|
|
156
|
+
await (0, help_1.help)();
|
|
157
|
+
break;
|
|
158
|
+
case 6: // Quit
|
|
159
|
+
console.log("Exit");
|
|
160
|
+
}
|
|
161
|
+
return 0;
|
|
162
|
+
// await search()
|
|
163
|
+
}
|
|
164
|
+
main();
|