ani-cli-npm 2.1.3 → 2.1.4
Sign up to get free protection for your applications and to get access to all the features.
- package/.idea/ani-cli-npm.iml +11 -11
- package/.idea/discord.xml +6 -6
- package/.idea/jsLibraryMappings.xml +5 -5
- package/.idea/modules.xml +7 -7
- package/.idea/vcs.xml +5 -5
- package/README.MD +77 -77
- package/bin/Anime.js +393 -393
- 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/download.js +36 -36
- package/bin/file_managment/cache.js +87 -87
- package/bin/file_managment/change_config.js +121 -121
- package/bin/file_managment/load_config.js +110 -110
- package/bin/generate_link.js +47 -47
- package/bin/help.js +59 -59
- package/bin/index.js +159 -159
- package/bin/input.js +89 -89
- package/bin/search_anime.js +39 -39
- package/package.json +45 -45
- package/tsconfig.json +109 -109
- package/.idea/git_toolbox_prj.xml +0 -15
- package/.idea/inspectionProfiles/Project_Default.xml +0 -10
- package/bin/cache.js +0 -79
- package/bin/change_config.js +0 -99
- package/bin/curl.js +0 -35
- package/bin/interfaces.js +0 -2
- package/bin/libs.js +0 -12
- package/bin/load_config.js +0 -106
- package/bin/regex.js +0 -8
- package/bin/video_quality.js +0 -6
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/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("./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,87 +1,87 @@
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
27
|
-
};
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
-
exports.search_cache = exports.new_cache = exports.clear_cache = void 0;
|
30
|
-
const fs = __importStar(require("fs"));
|
31
|
-
const chalk_1 = __importDefault(require("chalk"));
|
32
|
-
async function clear_cache(location) {
|
33
|
-
try {
|
34
|
-
await fs.readdir(location, (err, files) => {
|
35
|
-
if (err)
|
36
|
-
throw err;
|
37
|
-
for (const file of files) {
|
38
|
-
if (file.includes(".cache")) {
|
39
|
-
fs.unlinkSync(location + "/" + file);
|
40
|
-
}
|
41
|
-
}
|
42
|
-
});
|
43
|
-
}
|
44
|
-
catch {
|
45
|
-
console.log(chalk_1.default.red("Error clearing cache."));
|
46
|
-
}
|
47
|
-
return 0;
|
48
|
-
}
|
49
|
-
exports.clear_cache = clear_cache;
|
50
|
-
function new_cache(location, anime) {
|
51
|
-
/*
|
52
|
-
Creates cache of Anime object, in cache file.
|
53
|
-
*/
|
54
|
-
try {
|
55
|
-
fs.writeFileSync(location + "/" + anime.id + ".cache", JSON.stringify(anime));
|
56
|
-
}
|
57
|
-
catch {
|
58
|
-
console.log("Failed to write to cache");
|
59
|
-
}
|
60
|
-
}
|
61
|
-
exports.new_cache = new_cache;
|
62
|
-
function get_cache(location, anime_id) {
|
63
|
-
/*
|
64
|
-
## Get cache by anime_id. Does not check if the cache exists.
|
65
|
-
*/
|
66
|
-
return JSON.parse(fs.readFileSync(location + "/" + anime_id + ".cache").toString());
|
67
|
-
}
|
68
|
-
function search_cache(cache_folder, anime_id) {
|
69
|
-
/*
|
70
|
-
## Searches cache folder for cache file with name of anime_id, at the location of cache_folder
|
71
|
-
|
72
|
-
### returns boolean for weather it is found.
|
73
|
-
*/
|
74
|
-
try {
|
75
|
-
if (check_cache(cache_folder, anime_id)) {
|
76
|
-
return get_cache(cache_folder, anime_id);
|
77
|
-
}
|
78
|
-
return false;
|
79
|
-
}
|
80
|
-
catch {
|
81
|
-
return false;
|
82
|
-
}
|
83
|
-
}
|
84
|
-
exports.search_cache = search_cache;
|
85
|
-
function check_cache(location, anime_id) {
|
86
|
-
return fs.readdirSync(location).includes(anime_id + ".cache");
|
87
|
-
}
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
27
|
+
};
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
+
exports.search_cache = exports.new_cache = exports.clear_cache = void 0;
|
30
|
+
const fs = __importStar(require("fs"));
|
31
|
+
const chalk_1 = __importDefault(require("chalk"));
|
32
|
+
async function clear_cache(location) {
|
33
|
+
try {
|
34
|
+
await fs.readdir(location, (err, files) => {
|
35
|
+
if (err)
|
36
|
+
throw err;
|
37
|
+
for (const file of files) {
|
38
|
+
if (file.includes(".cache")) {
|
39
|
+
fs.unlinkSync(location + "/" + file);
|
40
|
+
}
|
41
|
+
}
|
42
|
+
});
|
43
|
+
}
|
44
|
+
catch {
|
45
|
+
console.log(chalk_1.default.red("Error clearing cache."));
|
46
|
+
}
|
47
|
+
return 0;
|
48
|
+
}
|
49
|
+
exports.clear_cache = clear_cache;
|
50
|
+
function new_cache(location, anime) {
|
51
|
+
/*
|
52
|
+
Creates cache of Anime object, in cache file.
|
53
|
+
*/
|
54
|
+
try {
|
55
|
+
fs.writeFileSync(location + "/" + anime.id + ".cache", JSON.stringify(anime));
|
56
|
+
}
|
57
|
+
catch {
|
58
|
+
console.log("Failed to write to cache");
|
59
|
+
}
|
60
|
+
}
|
61
|
+
exports.new_cache = new_cache;
|
62
|
+
function get_cache(location, anime_id) {
|
63
|
+
/*
|
64
|
+
## Get cache by anime_id. Does not check if the cache exists.
|
65
|
+
*/
|
66
|
+
return JSON.parse(fs.readFileSync(location + "/" + anime_id + ".cache").toString());
|
67
|
+
}
|
68
|
+
function search_cache(cache_folder, anime_id) {
|
69
|
+
/*
|
70
|
+
## Searches cache folder for cache file with name of anime_id, at the location of cache_folder
|
71
|
+
|
72
|
+
### returns boolean for weather it is found.
|
73
|
+
*/
|
74
|
+
try {
|
75
|
+
if (check_cache(cache_folder, anime_id)) {
|
76
|
+
return get_cache(cache_folder, anime_id);
|
77
|
+
}
|
78
|
+
return false;
|
79
|
+
}
|
80
|
+
catch {
|
81
|
+
return false;
|
82
|
+
}
|
83
|
+
}
|
84
|
+
exports.search_cache = search_cache;
|
85
|
+
function check_cache(location, anime_id) {
|
86
|
+
return fs.readdirSync(location).includes(anime_id + ".cache");
|
87
|
+
}
|
@@ -1,121 +1,121 @@
|
|
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
|
-
let config = {
|
68
|
-
player: "BROWSER",
|
69
|
-
proxy: "",
|
70
|
-
user_agent: "Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/100.0",
|
71
|
-
most_recent: {
|
72
|
-
episode_number: 0,
|
73
|
-
episode_second: 0,
|
74
|
-
anime_id: ""
|
75
|
-
},
|
76
|
-
download_folder: ".",
|
77
|
-
debug_mode: false,
|
78
|
-
mpv_socket_path: "",
|
79
|
-
vlc_socket: 0,
|
80
|
-
vlc_pass: "",
|
81
|
-
w2g_api_key: ""
|
82
|
-
};
|
83
|
-
console.log(config);
|
84
|
-
// @ts-ignore
|
85
|
-
return config, 0;
|
86
|
-
}),
|
87
|
-
(async (temp) => {
|
88
|
-
// @ts-ignore
|
89
|
-
return temp, 1;
|
90
|
-
}),
|
91
|
-
(async (temp) => {
|
92
|
-
// @ts-ignore
|
93
|
-
return temp, 2;
|
94
|
-
})
|
95
|
-
];
|
96
|
-
async function config_(temp) {
|
97
|
-
/*
|
98
|
-
## Lets user change a single attribute of config. Returns new config object, and an exit code
|
99
|
-
|
100
|
-
### 0 to continue (generic return)
|
101
|
-
### 1 To confirm (Save and exit)
|
102
|
-
### 2 to cancel (exit without saving changes)
|
103
|
-
*/
|
104
|
-
console.clear();
|
105
|
-
console.log(chalk.blue("ANI-CLI-NPM \n"));
|
106
|
-
console.log(chalk.yellow("Config:\n"));
|
107
|
-
return configs[await (0, input_1.selection)([
|
108
|
-
"Player; " + temp.player,
|
109
|
-
"Proxy; " + temp.proxy,
|
110
|
-
"User agent; " + temp.user_agent,
|
111
|
-
"Downloads folder; " + temp.download_folder,
|
112
|
-
"Mpv socket connection file; " + temp.mpv_socket_path,
|
113
|
-
"VLC socket; " + temp.vlc_socket,
|
114
|
-
"VLC pass; " + temp.vlc_pass,
|
115
|
-
"W2G api token: " + temp.w2g_api_key,
|
116
|
-
"Reset to defaults",
|
117
|
-
"Save and exit",
|
118
|
-
"Exit without saving"
|
119
|
-
], [], ((item) => { return chalk.cyan(item); }), ((item) => { return chalk.cyan(item); }))](temp);
|
120
|
-
}
|
121
|
-
exports.config_ = config_;
|
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
|
+
let config = {
|
68
|
+
player: "BROWSER",
|
69
|
+
proxy: "",
|
70
|
+
user_agent: "Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/100.0",
|
71
|
+
most_recent: {
|
72
|
+
episode_number: 0,
|
73
|
+
episode_second: 0,
|
74
|
+
anime_id: ""
|
75
|
+
},
|
76
|
+
download_folder: ".",
|
77
|
+
debug_mode: false,
|
78
|
+
mpv_socket_path: "",
|
79
|
+
vlc_socket: 0,
|
80
|
+
vlc_pass: "",
|
81
|
+
w2g_api_key: ""
|
82
|
+
};
|
83
|
+
console.log(config);
|
84
|
+
// @ts-ignore
|
85
|
+
return config, 0;
|
86
|
+
}),
|
87
|
+
(async (temp) => {
|
88
|
+
// @ts-ignore
|
89
|
+
return temp, 1;
|
90
|
+
}),
|
91
|
+
(async (temp) => {
|
92
|
+
// @ts-ignore
|
93
|
+
return temp, 2;
|
94
|
+
})
|
95
|
+
];
|
96
|
+
async function config_(temp) {
|
97
|
+
/*
|
98
|
+
## Lets user change a single attribute of config. Returns new config object, and an exit code
|
99
|
+
|
100
|
+
### 0 to continue (generic return)
|
101
|
+
### 1 To confirm (Save and exit)
|
102
|
+
### 2 to cancel (exit without saving changes)
|
103
|
+
*/
|
104
|
+
console.clear();
|
105
|
+
console.log(chalk.blue("ANI-CLI-NPM \n"));
|
106
|
+
console.log(chalk.yellow("Config:\n"));
|
107
|
+
return configs[await (0, input_1.selection)([
|
108
|
+
"Player; " + temp.player,
|
109
|
+
"Proxy; " + temp.proxy,
|
110
|
+
"User agent; " + temp.user_agent,
|
111
|
+
"Downloads folder; " + temp.download_folder,
|
112
|
+
"Mpv socket connection file; " + temp.mpv_socket_path,
|
113
|
+
"VLC socket; " + temp.vlc_socket,
|
114
|
+
"VLC pass; " + temp.vlc_pass,
|
115
|
+
"W2G api token: " + temp.w2g_api_key,
|
116
|
+
"Reset to defaults",
|
117
|
+
"Save and exit",
|
118
|
+
"Exit without saving"
|
119
|
+
], [], ((item) => { return chalk.cyan(item); }), ((item) => { return chalk.cyan(item); }))](temp);
|
120
|
+
}
|
121
|
+
exports.config_ = config_;
|