ani-cli-npm 1.4.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.idea/{ani-cli-npm.iml → ani-cli-npm-ts.iml} +1 -1
- package/.idea/modules.xml +1 -1
- package/bin/Anime.js +257 -0
- package/bin/cache.js +70 -0
- package/bin/change_config.js +65 -0
- package/bin/curl.js +34 -0
- package/bin/download.js +43 -0
- package/bin/generate_link.js +46 -0
- package/bin/index.js +85 -567
- package/bin/index.js.old +586 -0
- package/bin/input.js +63 -0
- package/bin/interfaces.js +2 -0
- package/bin/libs.js +12 -0
- package/bin/load_config.js +89 -0
- package/bin/regex.js +8 -0
- package/bin/search_anime.js +35 -0
- package/package.json +13 -8
- package/tsconfig.json +110 -0
- package/.idea/inspectionProfiles/Project_Default.xml +0 -10
- package/.idea/jsLibraryMappings.xml +0 -6
- package/bin/ani-cli-npm.conf +0 -1
@@ -4,7 +4,7 @@
|
|
4
4
|
<content url="file://$MODULE_DIR$">
|
5
5
|
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
6
6
|
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
7
|
-
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
7
|
+
<excludeFolder url="file://$MODULE_DIR$/tmp.js" />
|
8
8
|
</content>
|
9
9
|
<orderEntry type="inheritedJdk" />
|
10
10
|
<orderEntry type="sourceFolder" forTests="false" />
|
package/.idea/modules.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
<project version="4">
|
3
3
|
<component name="ProjectModuleManager">
|
4
4
|
<modules>
|
5
|
-
<module fileurl="file://$PROJECT_DIR$/.idea/ani-cli-npm.iml" filepath="$PROJECT_DIR$/.idea/ani-cli-npm.iml" />
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/ani-cli-npm-ts.iml" filepath="$PROJECT_DIR$/.idea/ani-cli-npm-ts.iml" />
|
6
6
|
</modules>
|
7
7
|
</component>
|
8
8
|
</project>
|
package/bin/Anime.js
ADDED
@@ -0,0 +1,257 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Anime = void 0;
|
4
|
+
const curl_1 = require("./curl");
|
5
|
+
const regex_1 = require("./regex");
|
6
|
+
const generate_link_1 = require("./generate_link");
|
7
|
+
const cache_1 = require("./cache");
|
8
|
+
const input_1 = require("./input");
|
9
|
+
const load_config_1 = require("./load_config");
|
10
|
+
const open = require("open");
|
11
|
+
const PlayerController = require("media-player-controller");
|
12
|
+
const dl = require("download-file-with-progressbar");
|
13
|
+
const chalk = require("chalk");
|
14
|
+
// const gogohd_url="https://gogohd.net/"
|
15
|
+
const base_url = "https://animixplay.to";
|
16
|
+
class Anime {
|
17
|
+
id = "";
|
18
|
+
episode_list = [];
|
19
|
+
player = 0;
|
20
|
+
async init(anime_id, cache_folder) {
|
21
|
+
let cache_object = (0, cache_1.search_cache)(cache_folder, anime_id);
|
22
|
+
this.id = anime_id;
|
23
|
+
if (cache_object == 0) {
|
24
|
+
await this.get_ap_bases(anime_id);
|
25
|
+
}
|
26
|
+
else {
|
27
|
+
try {
|
28
|
+
this.episode_list = cache_object.episode_list;
|
29
|
+
}
|
30
|
+
catch {
|
31
|
+
await this.get_ap_bases(anime_id);
|
32
|
+
}
|
33
|
+
}
|
34
|
+
return 0;
|
35
|
+
}
|
36
|
+
async get_episode_link(episode, player = "VLC") {
|
37
|
+
let episode_dpage = this.episode_list[episode];
|
38
|
+
let id = episode_dpage.replace("//gogohd.net/streaming.php?id=", "");
|
39
|
+
id = id.slice(0, id.indexOf("="));
|
40
|
+
let link = await (0, generate_link_1.generate_link)(1, id, player);
|
41
|
+
if (!link) {
|
42
|
+
link = await (0, generate_link_1.generate_link)(2, id, player);
|
43
|
+
}
|
44
|
+
if (!link) {
|
45
|
+
console.log(chalk.red("Failed to generate links"));
|
46
|
+
}
|
47
|
+
if (player == "VLC" && link.includes("m3u8")) {
|
48
|
+
console.log(chalk.red("Warning; VLC is not compatible with m3u8 playlist files without custom plugins."));
|
49
|
+
}
|
50
|
+
return link;
|
51
|
+
}
|
52
|
+
async get_ap_bases(anime_id) {
|
53
|
+
let html = (await ((0, curl_1.curl)(base_url + "/v1/" + anime_id))).split("\n");
|
54
|
+
let lines = "";
|
55
|
+
for (let x in html) {
|
56
|
+
if ((0, regex_1.RegexParse)(html[x], "*<div id=\"epslistplace\"*")) {
|
57
|
+
lines = (html[x]);
|
58
|
+
}
|
59
|
+
}
|
60
|
+
lines = lines.slice(55, lines.length).replace("}</div>", "");
|
61
|
+
lines = "{" + lines.slice(lines.indexOf(",") + 1, lines.length) + "}";
|
62
|
+
let json = JSON.parse(lines);
|
63
|
+
for (const value of Object.entries(json)) {
|
64
|
+
this.episode_list.push(value[1]);
|
65
|
+
}
|
66
|
+
}
|
67
|
+
async play_head(episode, config, config_dir) {
|
68
|
+
console.clear();
|
69
|
+
console.log(`Playing ${this.id} episode ${episode + 1}`);
|
70
|
+
switch (config.player) {
|
71
|
+
case "MPV":
|
72
|
+
console.log(("Opening MPV.."));
|
73
|
+
this.player = await new PlayerController({
|
74
|
+
app: 'mpv',
|
75
|
+
args: ['--fullscreen'],
|
76
|
+
media: await this.get_episode_link(episode, config.player)
|
77
|
+
});
|
78
|
+
// @ts-ignore
|
79
|
+
await this.player.launch(err => {
|
80
|
+
if (err)
|
81
|
+
return console.error(err.message);
|
82
|
+
});
|
83
|
+
break;
|
84
|
+
case "VLC":
|
85
|
+
console.log(("Opening VLC.."));
|
86
|
+
this.player = await new PlayerController({
|
87
|
+
app: 'vlc',
|
88
|
+
args: ['--fullscreen'],
|
89
|
+
media: await this.get_episode_link(episode, config.player)
|
90
|
+
});
|
91
|
+
// @ts-ignore
|
92
|
+
await this.player.launch(err => {
|
93
|
+
if (err)
|
94
|
+
return console.error(err.message);
|
95
|
+
});
|
96
|
+
break;
|
97
|
+
case "BROWSER":
|
98
|
+
console.log(("Opening browser..."));
|
99
|
+
await open(await this.get_episode_link(episode, config.player));
|
100
|
+
break;
|
101
|
+
case "LINK":
|
102
|
+
this.player = 1;
|
103
|
+
console.log(await this.get_episode_link(episode, config.player));
|
104
|
+
break;
|
105
|
+
}
|
106
|
+
config.most_recent.anime_id = this.id;
|
107
|
+
config.most_recent.episode_number = episode;
|
108
|
+
(0, load_config_1.write_config)(config_dir, config);
|
109
|
+
if (episode <= 0) {
|
110
|
+
switch (await (0, input_1.selection)([
|
111
|
+
"Next",
|
112
|
+
"Quit"
|
113
|
+
], ["n", "q"])) {
|
114
|
+
case 0:
|
115
|
+
await this.play(episode + 1, config, config_dir);
|
116
|
+
break;
|
117
|
+
case 1:
|
118
|
+
break;
|
119
|
+
}
|
120
|
+
}
|
121
|
+
else if (episode >= this.episode_list.length - 1) {
|
122
|
+
switch (await (0, input_1.selection)([
|
123
|
+
"Previous",
|
124
|
+
"Quit"
|
125
|
+
], ["p", "q"])) {
|
126
|
+
case 0:
|
127
|
+
await this.play(episode - 1, config, config_dir);
|
128
|
+
break;
|
129
|
+
case 1:
|
130
|
+
break;
|
131
|
+
}
|
132
|
+
}
|
133
|
+
else {
|
134
|
+
switch (await (0, input_1.selection)([
|
135
|
+
"Next",
|
136
|
+
"Previous",
|
137
|
+
"Quit"
|
138
|
+
], ["n", "p", "q"])) {
|
139
|
+
case 0:
|
140
|
+
await this.play(episode + 1, config, config_dir);
|
141
|
+
break;
|
142
|
+
case 1:
|
143
|
+
await this.play(episode - 1, config, config_dir);
|
144
|
+
break;
|
145
|
+
case 2:
|
146
|
+
break;
|
147
|
+
}
|
148
|
+
}
|
149
|
+
}
|
150
|
+
async play(episode, config, config_dir) {
|
151
|
+
console.clear();
|
152
|
+
console.log(`Playing ${this.id} episode ${episode + 1}`);
|
153
|
+
if (this.player == 0) {
|
154
|
+
await open(await this.get_episode_link(episode, "BROWSER"));
|
155
|
+
}
|
156
|
+
else if (this.player == 1) {
|
157
|
+
console.log(await this.get_episode_link(episode));
|
158
|
+
}
|
159
|
+
else if (this.player.opts.app == "mpv") {
|
160
|
+
await this.player.load(await this.get_episode_link(episode));
|
161
|
+
}
|
162
|
+
else {
|
163
|
+
this.player.quit();
|
164
|
+
this.player = await new PlayerController({
|
165
|
+
app: 'vlc',
|
166
|
+
args: ['--fullscreen'],
|
167
|
+
media: await this.get_episode_link(episode, config.player)
|
168
|
+
});
|
169
|
+
// @ts-ignore
|
170
|
+
await this.player.launch(err => {
|
171
|
+
if (err)
|
172
|
+
return console.error(err.message);
|
173
|
+
});
|
174
|
+
}
|
175
|
+
config.most_recent.anime_id = this.id;
|
176
|
+
config.most_recent.episode_number = episode;
|
177
|
+
(0, load_config_1.write_config)(config_dir, config);
|
178
|
+
if (episode <= 0) {
|
179
|
+
switch (await (0, input_1.selection)([
|
180
|
+
"Next",
|
181
|
+
"Quit"
|
182
|
+
], ["n", "q"])) {
|
183
|
+
case 0:
|
184
|
+
await this.play(episode + 1, config, config_dir);
|
185
|
+
break;
|
186
|
+
case 1:
|
187
|
+
break;
|
188
|
+
}
|
189
|
+
}
|
190
|
+
else if (episode >= this.episode_list.length - 1) {
|
191
|
+
switch (await (0, input_1.selection)([
|
192
|
+
"Previous",
|
193
|
+
"Quit"
|
194
|
+
], ["p", "q"])) {
|
195
|
+
case 0:
|
196
|
+
await this.play(episode - 1, config, config_dir);
|
197
|
+
break;
|
198
|
+
case 1:
|
199
|
+
break;
|
200
|
+
}
|
201
|
+
}
|
202
|
+
else {
|
203
|
+
switch (await (0, input_1.selection)([
|
204
|
+
"Next",
|
205
|
+
"Previous",
|
206
|
+
"Quit"
|
207
|
+
], ["n", "p", "q"])) {
|
208
|
+
case 0:
|
209
|
+
await this.play(episode + 1, config, config_dir);
|
210
|
+
break;
|
211
|
+
case 1:
|
212
|
+
await this.play(episode - 1, config, config_dir);
|
213
|
+
break;
|
214
|
+
case 2:
|
215
|
+
break;
|
216
|
+
}
|
217
|
+
}
|
218
|
+
}
|
219
|
+
async download(episode, download_folder) {
|
220
|
+
// @ts-ignore
|
221
|
+
let ep_link = await this.get_episode_link(episode);
|
222
|
+
let file_name = `${this.id}-${episode + 1}.mp4`;
|
223
|
+
if (ep_link.includes(".m3u8"))
|
224
|
+
console.log(chalk.red("Warning: Animixplay will download an m3u8 file. This will require some extra steps to play. It is advised to use a 3rd party website or tool to download these from the link."));
|
225
|
+
// @ts-ignore
|
226
|
+
let option = {
|
227
|
+
filename: ep_link.includes("m3u8") ? file_name.replace("mp4", "m3u8") : file_name,
|
228
|
+
dir: download_folder,
|
229
|
+
// @ts-ignore
|
230
|
+
onDone: (info) => {
|
231
|
+
// @ts-ignore
|
232
|
+
console.log(chalk.green(`\n -- Download finished -- \nLocation: ${info.path}. Size: ${Math.round(info.size / 100000) * 10} Bytes\n`) + ">");
|
233
|
+
return 0;
|
234
|
+
},
|
235
|
+
// @ts-ignore
|
236
|
+
onError: (err) => {
|
237
|
+
console.log(chalk.red('error', err));
|
238
|
+
},
|
239
|
+
// @ts-ignore
|
240
|
+
onProgress: (curr, total) => {
|
241
|
+
process.stdout.clearLine(0);
|
242
|
+
process.stdout.cursorTo(0);
|
243
|
+
process.stdout.write("\x1b[32m -- " + (curr / total * 100).toFixed(2) + "% " + "#".repeat(Math.ceil((curr / total) * ((process.stdout.columns - 20) / 1.5))) + "~".repeat(Math.ceil(((process.stdout.columns - 20) / 1.5) - (curr / total) * ((process.stdout.columns - 20) / 1.5))) + " -- \x1b[0m");
|
244
|
+
}
|
245
|
+
};
|
246
|
+
//console.log((`${option.dir}/${option.filename}`))
|
247
|
+
return await dl(ep_link, option);
|
248
|
+
}
|
249
|
+
async bulk_download(start_episode, end_episode, download_folder) {
|
250
|
+
let downloaders = [];
|
251
|
+
for (let episode = start_episode; episode <= end_episode; episode++) {
|
252
|
+
downloaders.push(await this.download(episode, download_folder));
|
253
|
+
}
|
254
|
+
return await Promise.all(downloaders);
|
255
|
+
}
|
256
|
+
}
|
257
|
+
exports.Anime = Anime;
|
package/bin/cache.js
ADDED
@@ -0,0 +1,70 @@
|
|
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, show) {
|
43
|
+
try {
|
44
|
+
fs.writeFileSync(location + "/" + anime.id + ".cache", JSON.stringify(anime));
|
45
|
+
}
|
46
|
+
catch {
|
47
|
+
if (show) {
|
48
|
+
console.log("Failed to write to cache");
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}
|
52
|
+
exports.new_cache = new_cache;
|
53
|
+
function get_cache(location, anime_id) {
|
54
|
+
return JSON.parse(fs.readFileSync(location + "/" + anime_id + ".cache").toString());
|
55
|
+
}
|
56
|
+
function search_cache(location, anime_id) {
|
57
|
+
try {
|
58
|
+
if (check_cache(location, anime_id)) {
|
59
|
+
return get_cache(location, anime_id);
|
60
|
+
}
|
61
|
+
return false;
|
62
|
+
}
|
63
|
+
catch {
|
64
|
+
return false;
|
65
|
+
}
|
66
|
+
}
|
67
|
+
exports.search_cache = search_cache;
|
68
|
+
function check_cache(location, anime_id) {
|
69
|
+
return fs.readdirSync(location).includes(anime_id + ".cache");
|
70
|
+
}
|
@@ -0,0 +1,65 @@
|
|
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
|
+
async function config_(temp) {
|
7
|
+
console.clear();
|
8
|
+
console.log(chalk.blue("ANI-CLI-NPM \n"));
|
9
|
+
console.log(chalk.yellow("Config:\n"));
|
10
|
+
let choice = await (0, input_1.selection)([
|
11
|
+
"Player; " + temp.player,
|
12
|
+
"Proxy; " + temp.proxy,
|
13
|
+
"User agent; " + temp.user_agent,
|
14
|
+
"Downloads folder; " + temp.download_folder,
|
15
|
+
"Save and exit",
|
16
|
+
"Exit without saving"
|
17
|
+
], [], ((item) => { return chalk.cyan(item); }), ((item) => { return chalk.cyan(item); }));
|
18
|
+
switch (choice) {
|
19
|
+
case 0:
|
20
|
+
let player = await (0, input_1.selection)([
|
21
|
+
"VLC - VLC media player",
|
22
|
+
"Browser - Play in default browser",
|
23
|
+
"MPV - MPV media player",
|
24
|
+
"Link - Simply display the link in console"
|
25
|
+
], [], ((item) => { return chalk.cyan(item); }), ((item) => { return chalk.cyan(item); }));
|
26
|
+
switch (player) {
|
27
|
+
case 0:
|
28
|
+
temp.player = "VLC";
|
29
|
+
break;
|
30
|
+
case 1:
|
31
|
+
temp.player = "BROWSER";
|
32
|
+
break;
|
33
|
+
case 2:
|
34
|
+
temp.player = "MPV";
|
35
|
+
break;
|
36
|
+
case 3:
|
37
|
+
temp.player = "LINK";
|
38
|
+
break;
|
39
|
+
}
|
40
|
+
// @ts-ignore
|
41
|
+
return temp, 0;
|
42
|
+
case 1:
|
43
|
+
console.log(chalk.cyan("New Proxy;"));
|
44
|
+
temp.proxy = (await ((0, input_1.input)())).replaceAll(" ", "");
|
45
|
+
// @ts-ignore
|
46
|
+
return temp, 0;
|
47
|
+
case 2:
|
48
|
+
console.log(chalk.cyan("New User Agent"));
|
49
|
+
temp.user_agent = await ((0, input_1.input)());
|
50
|
+
// @ts-ignore
|
51
|
+
return temp, 0;
|
52
|
+
case 3:
|
53
|
+
console.log(chalk.cyan("New Downloads Folder"));
|
54
|
+
temp.download_folder = await ((0, input_1.input)());
|
55
|
+
// @ts-ignore
|
56
|
+
return temp, 0;
|
57
|
+
case 4:
|
58
|
+
// @ts-ignore
|
59
|
+
return temp, 1;
|
60
|
+
case 5:
|
61
|
+
// @ts-ignore
|
62
|
+
return temp, 2;
|
63
|
+
}
|
64
|
+
}
|
65
|
+
exports.config_ = config_;
|
package/bin/curl.js
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.curl = void 0;
|
4
|
+
const fetch = require("node-fetch");
|
5
|
+
async function curl(url, method = "GET", redirect = false) {
|
6
|
+
//try{
|
7
|
+
let response = await fetch(url, {
|
8
|
+
//"agent": proxyAgent,
|
9
|
+
"headers": {
|
10
|
+
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/100.0',
|
11
|
+
"X-Requested-With": "XMLHttpRequest"
|
12
|
+
},
|
13
|
+
"referrerPolicy": "origin",
|
14
|
+
"body": null,
|
15
|
+
"method": method,
|
16
|
+
"redirect": 'follow',
|
17
|
+
// "follow": 10,
|
18
|
+
}); /*.catch(async function(err) {
|
19
|
+
console.warn(colors.Red, `Something went wrong connecting to ${url}.`);
|
20
|
+
await search();
|
21
|
+
process.exit()
|
22
|
+
})*/
|
23
|
+
if (redirect) {
|
24
|
+
return response.url;
|
25
|
+
}
|
26
|
+
else {
|
27
|
+
return await response.text();
|
28
|
+
}
|
29
|
+
/*}catch{
|
30
|
+
console.log(colors.Red, "Something went wrong in curl()")
|
31
|
+
await main()
|
32
|
+
}*/
|
33
|
+
}
|
34
|
+
exports.curl = curl;
|
package/bin/download.js
ADDED
@@ -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;
|