ani-cli-npm 1.4.3 → 2.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.
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.download = void 0;
7
+ const search_anime_1 = require("./search_anime");
8
+ const Anime_1 = require("./Anime");
9
+ const input_1 = require("./input");
10
+ const libs_1 = require("./libs");
11
+ const chalk_1 = __importDefault(require("chalk"));
12
+ async function download(cache_folder, config) {
13
+ try {
14
+ console.clear();
15
+ let download_id = await (0, search_anime_1.search)();
16
+ let download = new Anime_1.Anime();
17
+ await download.init(download_id, cache_folder);
18
+ console.log(`Select start episode [1-${download.episode_list.length}]`);
19
+ let start_ep_number = await (0, input_1.number_input)(download.episode_list.length);
20
+ console.log(`Select end episode [${start_ep_number}-${download.episode_list.length}]`);
21
+ let end_ep_number = await (0, input_1.number_input)(download.episode_list.length, start_ep_number) - 1;
22
+ let to_do = (0, libs_1.range)(start_ep_number, end_ep_number + 1);
23
+ do {
24
+ for (let x in to_do) {
25
+ try {
26
+ await download.download(to_do[x] - 1, config.download_folder);
27
+ to_do.splice(Number(x), 1);
28
+ }
29
+ catch {
30
+ console.log(chalk_1.default.red("Failed to download episode " + to_do[x]));
31
+ }
32
+ }
33
+ if (to_do[0] !== undefined) { //TODO fix buggy downloads
34
+ console.log(chalk_1.default.red("Failed to download episodes: " + to_do) + "\nRetrying...");
35
+ }
36
+ } while (to_do[0] !== undefined);
37
+ }
38
+ catch {
39
+ return 1;
40
+ }
41
+ return 0;
42
+ }
43
+ exports.download = download;
@@ -0,0 +1,46 @@
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("./curl");
7
+ const regex_1 = require("./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
+ let buffer = new Buffer(id);
36
+ let enc_id = buffer.toString("base64");
37
+ buffer = new Buffer(id + "LTXs3GrU8we9O" + enc_id);
38
+ let ani_id = buffer.toString("base64");
39
+ buffer = Buffer.from((await (0, curl_1.curl)(`${base_url}/api/live${ani_id}`, "GET", true)).split("#")[1], "base64");
40
+ if (player === "BROWSER") {
41
+ return `${base_url}/api/live${ani_id}`;
42
+ }
43
+ return buffer.toString("utf-8");
44
+ }
45
+ }
46
+ exports.generate_link = generate_link;