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/IO/help.js
ADDED
|
@@ -0,0 +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;
|
package/bin/IO/input.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
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.number_input = exports.input = exports.selection = void 0;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const _prompt = require("simple-input");
|
|
9
|
+
async function selection(options, extra_options = [], color1 = ((thing) => { return chalk_1.default.yellow(thing); }), color2 = ((thing) => { return chalk_1.default.green(thing); }), overwrite = false) {
|
|
10
|
+
/*
|
|
11
|
+
selection(options, extra_options, color1, color2)
|
|
12
|
+
|
|
13
|
+
Gives use prompt to choose from a list of options. Either by inputting a number ranging from 1, to the length of the list. Or by inputting a letter (non-caps-sensitive) relating to the option.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
- options: array of options; e.g. ["play", "download", "continue", "quit"] REQUIRED
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
- extra_options: array of characters as alternatives to numbers (both will be displayed). e.g. ["p", "d", "c", "q"].
|
|
20
|
+
|
|
21
|
+
default: []
|
|
22
|
+
|
|
23
|
+
- color1 and color2: functions that will dictate what 2 colors the options with alternate between (option1 will be color1, option2;color2, option3;color1, etc).
|
|
24
|
+
recommended for this function to return a chalk.____() parsed string.
|
|
25
|
+
|
|
26
|
+
default: ((thing:string) => {return chalk.yellow(thing)}) and ((thing:string) => {return chalk.green(thing)})
|
|
27
|
+
|
|
28
|
+
- Overwrite: boolean. Please dont use this. I should not be using it. It prints out the raw string instead of adding numbers to them to allow for bogus.
|
|
29
|
+
*/
|
|
30
|
+
let color = true;
|
|
31
|
+
for (let x in options) {
|
|
32
|
+
if (!overwrite) {
|
|
33
|
+
if (color) {
|
|
34
|
+
console.log(color1((parseInt(x) + 1).toString() +
|
|
35
|
+
((extra_options[x] == undefined) ? "" : "/" + extra_options[x]) +
|
|
36
|
+
") " + options[x].replaceAll("-", " ")));
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
console.log(color2((parseInt(x) + 1).toString() +
|
|
40
|
+
((extra_options[x] == undefined) ? "" : "/" + extra_options[x]) +
|
|
41
|
+
") " + options[x].replaceAll("-", " ")));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
console.log(options[x]);
|
|
46
|
+
}
|
|
47
|
+
color = !color;
|
|
48
|
+
}
|
|
49
|
+
let input = "";
|
|
50
|
+
do {
|
|
51
|
+
// @ts-ignore
|
|
52
|
+
input = (await _prompt(">")).toLowerCase();
|
|
53
|
+
for (let x in extra_options) {
|
|
54
|
+
if (extra_options[x].toLowerCase() == input) {
|
|
55
|
+
input = (parseInt(x) + 1).toString();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (!(1 <= parseInt(input) && parseInt(input) <= options.length)) {
|
|
59
|
+
console.log(chalk_1.default.red("Invalid choice."));
|
|
60
|
+
}
|
|
61
|
+
} while (!(1 <= parseInt(input) && parseInt(input) <= options.length));
|
|
62
|
+
return parseInt(input) - 1;
|
|
63
|
+
}
|
|
64
|
+
exports.selection = selection;
|
|
65
|
+
async function input() {
|
|
66
|
+
return await _prompt(">");
|
|
67
|
+
}
|
|
68
|
+
exports.input = input;
|
|
69
|
+
async function number_input(max, min = 1, extra_options = [], extra_option_values = []) {
|
|
70
|
+
let selector;
|
|
71
|
+
let selection;
|
|
72
|
+
do {
|
|
73
|
+
selector = await _prompt(">");
|
|
74
|
+
if (extra_options.includes(selector.toLowerCase())) {
|
|
75
|
+
selection = extra_option_values[extra_options.indexOf(selector)];
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
selection = parseInt(selector);
|
|
79
|
+
}
|
|
80
|
+
if (selector == "") {
|
|
81
|
+
selection = min;
|
|
82
|
+
}
|
|
83
|
+
if (!(min <= selection && selection <= max)) {
|
|
84
|
+
console.log(chalk_1.default.red("Invalid choice."));
|
|
85
|
+
}
|
|
86
|
+
} while (!(min <= selection && selection <= max));
|
|
87
|
+
return selection;
|
|
88
|
+
}
|
|
89
|
+
exports.number_input = number_input;
|
package/bin/cache.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.search_cache = exports.new_cache = exports.clear_cache = void 0;
|
|
27
|
+
const fs = __importStar(require("fs"));
|
|
28
|
+
function clear_cache(location, show) {
|
|
29
|
+
try {
|
|
30
|
+
console.log("ye sorry that doesnt exist yet.");
|
|
31
|
+
if (show) {
|
|
32
|
+
console.log("Cleared cache");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
if (show) {
|
|
37
|
+
console.log("Failed to clear cache.");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.clear_cache = clear_cache;
|
|
42
|
+
function new_cache(location, anime) {
|
|
43
|
+
/*
|
|
44
|
+
Creates cache of Anime object, in cache file.
|
|
45
|
+
*/
|
|
46
|
+
try {
|
|
47
|
+
fs.writeFileSync(location + "/" + anime.id + ".cache", JSON.stringify(anime));
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
console.log("Failed to write to cache");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.new_cache = new_cache;
|
|
54
|
+
function get_cache(location, anime_id) {
|
|
55
|
+
/*
|
|
56
|
+
## Get cache by anime_id. Does not check if the cache exists.
|
|
57
|
+
*/
|
|
58
|
+
return JSON.parse(fs.readFileSync(location + "/" + anime_id + ".cache").toString());
|
|
59
|
+
}
|
|
60
|
+
function search_cache(cache_folder, anime_id) {
|
|
61
|
+
/*
|
|
62
|
+
## Searches cache folder for cache file with name of anime_id, at the location of cache_folder
|
|
63
|
+
|
|
64
|
+
### returns boolean for weather it is found.
|
|
65
|
+
*/
|
|
66
|
+
try {
|
|
67
|
+
if (check_cache(cache_folder, anime_id)) {
|
|
68
|
+
return get_cache(cache_folder, anime_id);
|
|
69
|
+
}
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.search_cache = search_cache;
|
|
77
|
+
function check_cache(location, anime_id) {
|
|
78
|
+
return fs.readdirSync(location).includes(anime_id + ".cache");
|
|
79
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.config_ = void 0;
|
|
4
|
+
const chalk = require("chalk");
|
|
5
|
+
const input_1 = require("./input");
|
|
6
|
+
const configs = [
|
|
7
|
+
(async (temp) => {
|
|
8
|
+
temp.player = [
|
|
9
|
+
"VLC",
|
|
10
|
+
"BROWSER",
|
|
11
|
+
"MPV",
|
|
12
|
+
"W2G",
|
|
13
|
+
"LINK",
|
|
14
|
+
][await (0, input_1.selection)([
|
|
15
|
+
"VLC - VLC media player",
|
|
16
|
+
"Browser - Play in default browser",
|
|
17
|
+
"MPV - MPV media player",
|
|
18
|
+
"w2g.tv - Watch together with friends in browser (Specify api token to create rooms linked to your account)",
|
|
19
|
+
"Link - Simply display the link in console"
|
|
20
|
+
], [], ((item) => { return chalk.cyan(item); }), ((item) => { return chalk.cyan(item); }))];
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
return temp, 0;
|
|
23
|
+
}),
|
|
24
|
+
(async (temp) => {
|
|
25
|
+
console.log(chalk.cyan("New Proxy;"));
|
|
26
|
+
temp.proxy = (await ((0, input_1.input)())).replaceAll(" ", "");
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
return temp, 0;
|
|
29
|
+
}),
|
|
30
|
+
(async (temp) => {
|
|
31
|
+
console.log(chalk.cyan("New User Agent"));
|
|
32
|
+
temp.user_agent = await ((0, input_1.input)());
|
|
33
|
+
// @ts-ignore
|
|
34
|
+
return temp, 0;
|
|
35
|
+
}),
|
|
36
|
+
(async (temp) => {
|
|
37
|
+
console.log(chalk.cyan("New Downloads Folder"));
|
|
38
|
+
temp.download_folder = await ((0, input_1.input)());
|
|
39
|
+
// @ts-ignore
|
|
40
|
+
return temp, 0;
|
|
41
|
+
}),
|
|
42
|
+
(async (temp) => {
|
|
43
|
+
console.log(chalk.cyan("New socket file"));
|
|
44
|
+
temp.mpv_socket_path = await ((0, input_1.input)());
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
return temp, 0;
|
|
47
|
+
}),
|
|
48
|
+
(async (temp) => {
|
|
49
|
+
console.log(chalk.cyan("New VLC socket"));
|
|
50
|
+
temp.vlc_socket = await ((0, input_1.input)());
|
|
51
|
+
// @ts-ignore
|
|
52
|
+
return temp, 0;
|
|
53
|
+
}),
|
|
54
|
+
(async (temp) => {
|
|
55
|
+
console.log(chalk.cyan("New VLC password"));
|
|
56
|
+
temp.vlc_pass = await ((0, input_1.input)());
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
return temp, 0;
|
|
59
|
+
}),
|
|
60
|
+
(async (temp) => {
|
|
61
|
+
console.log(chalk.cyan("New w2g.tv api token"));
|
|
62
|
+
temp.w2g_api_key = await ((0, input_1.input)());
|
|
63
|
+
// @ts-ignore
|
|
64
|
+
return temp, 0;
|
|
65
|
+
}),
|
|
66
|
+
(async (temp) => {
|
|
67
|
+
// @ts-ignore
|
|
68
|
+
return temp, 1;
|
|
69
|
+
}),
|
|
70
|
+
(async (temp) => {
|
|
71
|
+
// @ts-ignore
|
|
72
|
+
return temp, 2;
|
|
73
|
+
})
|
|
74
|
+
];
|
|
75
|
+
async function config_(temp) {
|
|
76
|
+
/*
|
|
77
|
+
## Lets user change a single attribute of config. Returns new config object, and an exit code
|
|
78
|
+
|
|
79
|
+
### 0 to continue (generic return)
|
|
80
|
+
### 1 To confirm (Save and exit)
|
|
81
|
+
### 2 to cancel (exit without saving changes)
|
|
82
|
+
*/
|
|
83
|
+
console.clear();
|
|
84
|
+
console.log(chalk.blue("ANI-CLI-NPM \n"));
|
|
85
|
+
console.log(chalk.yellow("Config:\n"));
|
|
86
|
+
return configs[await (0, input_1.selection)([
|
|
87
|
+
"Player; " + temp.player,
|
|
88
|
+
"Proxy; " + temp.proxy,
|
|
89
|
+
"User agent; " + temp.user_agent,
|
|
90
|
+
"Downloads folder; " + temp.download_folder,
|
|
91
|
+
"Mpv socket connection file; " + temp.mpv_socket_path,
|
|
92
|
+
"VLC socket; " + temp.vlc_socket,
|
|
93
|
+
"VLC pass; " + temp.vlc_pass,
|
|
94
|
+
"W2G api token: " + temp.w2g_api_key,
|
|
95
|
+
"Save and exit",
|
|
96
|
+
"Exit without saving"
|
|
97
|
+
], [], ((item) => { return chalk.cyan(item); }), ((item) => { return chalk.cyan(item); }))](temp);
|
|
98
|
+
}
|
|
99
|
+
exports.config_ = config_;
|
package/bin/core_utils/curl.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.curl = void 0;
|
|
4
|
-
const fetch = require("node-fetch");
|
|
5
|
-
const chalk = require("chalk");
|
|
6
|
-
async function curl(url, method = "GET", redirect = false) {
|
|
7
|
-
try {
|
|
8
|
-
let response = await fetch(url, {
|
|
9
|
-
//"agent": proxyAgent,
|
|
10
|
-
"headers": {
|
|
11
|
-
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/100.0',
|
|
12
|
-
"X-Requested-With": "XMLHttpRequest"
|
|
13
|
-
},
|
|
14
|
-
"referrerPolicy": "origin",
|
|
15
|
-
"body": null,
|
|
16
|
-
"method": method,
|
|
17
|
-
"redirect": 'follow',
|
|
18
|
-
// "follow": 10,
|
|
19
|
-
}).catch(async function (err) {
|
|
20
|
-
console.warn(chalk.red(`Something went wrong connecting to ${url}. ${err}`));
|
|
21
|
-
process.exit();
|
|
22
|
-
});
|
|
23
|
-
if (redirect) {
|
|
24
|
-
return response.url;
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
return await response.text();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
catch {
|
|
31
|
-
console.log(chalk.red("Something went wrong in curl()"));
|
|
32
|
-
process.exit();
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.curl = curl;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.curl = void 0;
|
|
4
|
+
const fetch = require("node-fetch");
|
|
5
|
+
const chalk = require("chalk");
|
|
6
|
+
async function curl(url, method = "GET", redirect = false) {
|
|
7
|
+
try {
|
|
8
|
+
let response = await fetch(url, {
|
|
9
|
+
//"agent": proxyAgent,
|
|
10
|
+
"headers": {
|
|
11
|
+
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/100.0',
|
|
12
|
+
"X-Requested-With": "XMLHttpRequest"
|
|
13
|
+
},
|
|
14
|
+
"referrerPolicy": "origin",
|
|
15
|
+
"body": null,
|
|
16
|
+
"method": method,
|
|
17
|
+
"redirect": 'follow',
|
|
18
|
+
// "follow": 10,
|
|
19
|
+
}).catch(async function (err) {
|
|
20
|
+
console.warn(chalk.red(`Something went wrong connecting to ${url}. ${err}`));
|
|
21
|
+
process.exit();
|
|
22
|
+
});
|
|
23
|
+
if (redirect) {
|
|
24
|
+
return response.url;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
return await response.text();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
console.log(chalk.red("Something went wrong in curl()"));
|
|
32
|
+
process.exit();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.curl = curl;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/bin/core_utils/libs.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Random functions
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.range = void 0;
|
|
5
|
-
function range(start, end) {
|
|
6
|
-
let ans = [];
|
|
7
|
-
for (let i = start; i <= end; i++) {
|
|
8
|
-
ans.push(i);
|
|
9
|
-
}
|
|
10
|
-
return ans;
|
|
11
|
-
}
|
|
12
|
-
exports.range = range;
|
|
1
|
+
"use strict";
|
|
2
|
+
// Random functions
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.range = void 0;
|
|
5
|
+
function range(start, end) {
|
|
6
|
+
let ans = [];
|
|
7
|
+
for (let i = start; i <= end; i++) {
|
|
8
|
+
ans.push(i);
|
|
9
|
+
}
|
|
10
|
+
return ans;
|
|
11
|
+
}
|
|
12
|
+
exports.range = range;
|
package/bin/core_utils/regex.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RegexParse = void 0;
|
|
4
|
-
function RegexParse(str, rule) {
|
|
5
|
-
let escapeRegex = (str) => str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
|
|
6
|
-
return new RegExp("^" + rule.split("*").map(escapeRegex).join(".*") + "$").test(str);
|
|
7
|
-
}
|
|
8
|
-
exports.RegexParse = RegexParse;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RegexParse = void 0;
|
|
4
|
+
function RegexParse(str, rule) {
|
|
5
|
+
let escapeRegex = (str) => str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
|
|
6
|
+
return new RegExp("^" + rule.split("*").map(escapeRegex).join(".*") + "$").test(str);
|
|
7
|
+
}
|
|
8
|
+
exports.RegexParse = RegexParse;
|
package/bin/curl.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.curl = void 0;
|
|
4
|
+
const fetch = require("node-fetch");
|
|
5
|
+
const chalk = require("chalk");
|
|
6
|
+
async function curl(url, method = "GET", redirect = false) {
|
|
7
|
+
try {
|
|
8
|
+
let response = await fetch(url, {
|
|
9
|
+
//"agent": proxyAgent,
|
|
10
|
+
"headers": {
|
|
11
|
+
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/100.0',
|
|
12
|
+
"X-Requested-With": "XMLHttpRequest"
|
|
13
|
+
},
|
|
14
|
+
"referrerPolicy": "origin",
|
|
15
|
+
"body": null,
|
|
16
|
+
"method": method,
|
|
17
|
+
"redirect": 'follow',
|
|
18
|
+
// "follow": 10,
|
|
19
|
+
}).catch(async function (err) {
|
|
20
|
+
console.warn(chalk.red(`Something went wrong connecting to ${url}. ${err}`));
|
|
21
|
+
process.exit();
|
|
22
|
+
});
|
|
23
|
+
if (redirect) {
|
|
24
|
+
return response.url;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
return await response.text();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
console.log(chalk.red("Something went wrong in curl()"));
|
|
32
|
+
process.exit();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.curl = curl;
|
package/bin/download.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.download = void 0;
|
|
4
|
-
const search_anime_1 = require("./search_anime");
|
|
5
|
-
const Anime_1 = require("./Anime");
|
|
6
|
-
const input_1 = require("./input");
|
|
7
|
-
async function download(cache_folder, config) {
|
|
8
|
-
try {
|
|
9
|
-
console.clear();
|
|
10
|
-
let temp_ = await (0, search_anime_1.search)();
|
|
11
|
-
if (temp_ == 1) {
|
|
12
|
-
return 2;
|
|
13
|
-
}
|
|
14
|
-
let download_id = temp_;
|
|
15
|
-
let download = new Anime_1.Anime();
|
|
16
|
-
await download.init(download_id, cache_folder);
|
|
17
|
-
let start_ep_number;
|
|
18
|
-
let end_ep_number;
|
|
19
|
-
if (download.episode_list.length <= 1) {
|
|
20
|
-
start_ep_number = 1;
|
|
21
|
-
end_ep_number = 0;
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
console.log(`Select start episode [1-${download.episode_list.length}]`);
|
|
25
|
-
start_ep_number = await (0, input_1.number_input)(download.episode_list.length);
|
|
26
|
-
console.log(`Select end episode [${start_ep_number}-${download.episode_list.length}]`);
|
|
27
|
-
end_ep_number = await (0, input_1.number_input)(download.episode_list.length, start_ep_number) - 1;
|
|
28
|
-
}
|
|
29
|
-
await download.download(start_ep_number - 1, config.download_folder, end_ep_number);
|
|
30
|
-
}
|
|
31
|
-
catch {
|
|
32
|
-
return 1;
|
|
33
|
-
}
|
|
34
|
-
return 0;
|
|
35
|
-
}
|
|
36
|
-
exports.download = download;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.download = void 0;
|
|
4
|
+
const search_anime_1 = require("./url_genoration/search_anime");
|
|
5
|
+
const Anime_1 = require("./Anime");
|
|
6
|
+
const input_1 = require("./IO/input");
|
|
7
|
+
async function download(cache_folder, config) {
|
|
8
|
+
try {
|
|
9
|
+
console.clear();
|
|
10
|
+
let temp_ = await (0, search_anime_1.search)();
|
|
11
|
+
if (temp_ == 1) {
|
|
12
|
+
return 2;
|
|
13
|
+
}
|
|
14
|
+
let download_id = temp_;
|
|
15
|
+
let download = new Anime_1.Anime();
|
|
16
|
+
await download.init(download_id, cache_folder);
|
|
17
|
+
let start_ep_number;
|
|
18
|
+
let end_ep_number;
|
|
19
|
+
if (download.episode_list.length <= 1) {
|
|
20
|
+
start_ep_number = 1;
|
|
21
|
+
end_ep_number = 0;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
console.log(`Select start episode [1-${download.episode_list.length}]`);
|
|
25
|
+
start_ep_number = await (0, input_1.number_input)(download.episode_list.length);
|
|
26
|
+
console.log(`Select end episode [${start_ep_number}-${download.episode_list.length}]`);
|
|
27
|
+
end_ep_number = await (0, input_1.number_input)(download.episode_list.length, start_ep_number) - 1;
|
|
28
|
+
}
|
|
29
|
+
await download.download(start_ep_number - 1, config.download_folder, end_ep_number);
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return 1;
|
|
33
|
+
}
|
|
34
|
+
return 0;
|
|
35
|
+
}
|
|
36
|
+
exports.download = download;
|