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.
Files changed (54) hide show
  1. package/.idea/ani-cli-npm.iml +11 -11
  2. package/.idea/discord.xml +6 -6
  3. package/.idea/git_toolbox_prj.xml +15 -0
  4. package/.idea/inspectionProfiles/Project_Default.xml +10 -0
  5. package/.idea/jsLibraryMappings.xml +5 -5
  6. package/.idea/modules.xml +7 -7
  7. package/.idea/vcs.xml +5 -5
  8. package/README.MD +79 -77
  9. package/bin/Anime.js +409 -393
  10. package/bin/IO/help.js +59 -0
  11. package/bin/IO/input.js +89 -0
  12. package/bin/cache.js +79 -0
  13. package/bin/change_config.js +99 -0
  14. package/bin/core_utils/curl.js +35 -35
  15. package/bin/core_utils/interfaces.js +2 -2
  16. package/bin/core_utils/libs.js +12 -12
  17. package/bin/core_utils/regex.js +8 -8
  18. package/bin/cover_manager.js +3 -0
  19. package/bin/curl.js +35 -0
  20. package/bin/download.js +36 -36
  21. package/bin/file_managment/cache.js +87 -87
  22. package/bin/file_managment/change_config.js +122 -121
  23. package/bin/file_managment/load_config.js +111 -110
  24. package/bin/generate_link.js +47 -47
  25. package/bin/help.js +59 -59
  26. package/bin/index.js +164 -159
  27. package/bin/input.js +89 -89
  28. package/bin/interfaces.js +2 -0
  29. package/bin/libs.js +12 -0
  30. package/bin/load_config.js +106 -0
  31. package/bin/regex.js +8 -0
  32. package/bin/search_anime.js +39 -39
  33. package/bin/url_genoration/generate_link.js +47 -0
  34. package/bin/url_genoration/search_anime.js +39 -0
  35. package/bin/video_quality.js +6 -0
  36. package/package.json +45 -45
  37. package/src/Anime.ts +427 -0
  38. package/src/IO/help.ts +64 -0
  39. package/src/IO/input.ts +92 -0
  40. package/src/core_utils/curl.ts +32 -0
  41. package/src/core_utils/interfaces.ts +25 -0
  42. package/src/core_utils/libs.ts +13 -0
  43. package/src/core_utils/regex.ts +5 -0
  44. package/src/cover_manager.ts +9 -0
  45. package/src/download.ts +35 -0
  46. package/src/file_managment/cache.ts +58 -0
  47. package/src/file_managment/change_config.ts +126 -0
  48. package/src/file_managment/load_config.ts +79 -0
  49. package/src/index.ts +143 -0
  50. package/src/url_genoration/generate_link.ts +53 -0
  51. package/src/url_genoration/search_anime.ts +41 -0
  52. package/src/video_quality.ts +6 -0
  53. package/temp.sh +676 -0
  54. package/tsconfig.json +109 -109
@@ -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.pro/";
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
- if (player === "BROWSER") {
41
- return `${base_url}/api/live${ani_id}`;
42
- }
43
- buffer = Buffer.from((await (0, curl_1.curl)(`${base_url}/api/live${ani_id}`, "GET", true)).split("#")[1], "base64");
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
- // External
33
- const appdata_path_1 = __importDefault(require("appdata-path"));
34
- const chalk = require("chalk");
35
- // Internal
36
- const Anime_1 = require("./Anime");
37
- const search_anime_1 = require("./search_anime");
38
- const load_config_1 = require("./file_managment/load_config");
39
- const input_1 = require("./input");
40
- const change_config_1 = require("./file_managment/change_config");
41
- const cache_1 = require("./file_managment/cache");
42
- const download_1 = require("./download");
43
- const help_1 = require("./help");
44
- const app_data_folder = (0, appdata_path_1.default)();
45
- const cache_folder = app_data_folder + "/ani-cli-npm";
46
- (0, load_config_1.make_config_dir)(cache_folder, true);
47
- console.clear();
48
- async function main() {
49
- let config = (0, load_config_1.load_config)(cache_folder);
50
- console.log(chalk.magenta("Ani-cli-npm!\n"));
51
- if (config.most_recent.anime_id !== "") {
52
- console.log(chalk.grey(`Most recently played: ${config.most_recent.anime_id} episode ${config.most_recent.episode_number + 1}\n`));
53
- }
54
- let choice = await (0, input_1.selection)([
55
- "Search",
56
- "Continue",
57
- "Download",
58
- "Option",
59
- "Clear cache",
60
- "Help",
61
- "Quit",
62
- ], ["s", "c", "d", "o", " ", "h", "q"], ((thing) => { return chalk.magenta(thing); }), ((thing) => { return chalk.magenta(thing); }));
63
- switch (choice) {
64
- case 0: // Search
65
- let temp_ = await (0, search_anime_1.search)();
66
- if (temp_ == 1) {
67
- await main();
68
- process.exit();
69
- }
70
- let anime_id = temp_;
71
- let anime = new Anime_1.Anime();
72
- await anime.init(anime_id, cache_folder);
73
- let episode_number;
74
- if (anime.episode_list.length == 1) {
75
- episode_number = 1;
76
- }
77
- else {
78
- console.log(`Select episode [1-${anime.episode_list.length}] ${(anime.most_recent != 0) ? `Or C to continue from ep${anime.most_recent + 1}` : ""}`);
79
- 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] : []);
80
- }
81
- await anime.play_head(episode_number - 1, config, cache_folder);
82
- if (anime.player.hasOwnProperty("quit")) {
83
- await anime.player.player.quit();
84
- }
85
- await main();
86
- break;
87
- case 1: // Continue
88
- if (config.most_recent.anime_id == "") {
89
- console.clear();
90
- console.log(chalk.red("No episode played recently"));
91
- await main();
92
- break;
93
- }
94
- let continue_anime = new Anime_1.Anime();
95
- await continue_anime.init(config.most_recent.anime_id, cache_folder);
96
- await continue_anime.play_head(config.most_recent.episode_number, config, cache_folder);
97
- try {
98
- await continue_anime.player.player.quit();
99
- }
100
- catch { }
101
- await main();
102
- break;
103
- case 2: // Download
104
- let code = await (0, download_1.download)(cache_folder, config);
105
- if (code == 1) {
106
- console.log(chalk.red("Error downloading episodes"));
107
- }
108
- break;
109
- case 3: // Options
110
- let temp = structuredClone(config);
111
- let exit_code;
112
- while (true) {
113
- // @ts-ignore
114
- temp, exit_code = await (0, change_config_1.config_)(temp);
115
- if (exit_code === 1) {
116
- config = temp;
117
- //proxyAgent = new HttpsProxyAgent(config.proxy);
118
- console.clear();
119
- try {
120
- (0, load_config_1.write_config)(cache_folder, config);
121
- console.log(chalk.yellow("Config changed."));
122
- }
123
- catch {
124
- console.log(chalk.red("Error writing to .conf file."));
125
- }
126
- break;
127
- }
128
- else if (exit_code === 2) {
129
- temp = config;
130
- console.clear();
131
- console.log(chalk.yellow("Config changes disregarded."));
132
- break;
133
- }
134
- }
135
- await main();
136
- break;
137
- case 4:
138
- console.clear();
139
- console.log(chalk.yellow("Warning, this will also clear your current position in each anime, are you sure you want to do this?"));
140
- if (await (0, input_1.selection)(["yes", "no"], ["y", "n"]) == 0) {
141
- await (0, cache_1.clear_cache)(cache_folder);
142
- console.clear();
143
- console.log(chalk.grey("Cache cleared"));
144
- }
145
- else {
146
- console.clear();
147
- }
148
- await main();
149
- break;
150
- case 5:
151
- await (0, help_1.help)();
152
- break;
153
- case 6: // Quit
154
- console.log("Exit");
155
- }
156
- return 0;
157
- // await search()
158
- }
159
- main();
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();