react-native-consumet 1.1.0 → 1.2.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.
- package/README.md +19 -0
- package/lib/commonjs/extension-registry.json +30 -1
- package/lib/commonjs/extractors/index.js +2 -2
- package/lib/commonjs/extractors/index.js.map +1 -1
- package/lib/commonjs/extractors/megacloud.js +11 -5
- package/lib/commonjs/extractors/megacloud.js.map +1 -1
- package/lib/commonjs/extractors/megaup.js +87 -84
- package/lib/commonjs/extractors/megaup.js.map +1 -1
- package/lib/commonjs/index.js +1 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/providers/anime/animekai/animekai.js +118 -0
- package/lib/commonjs/providers/anime/animekai/animekai.js.map +1 -0
- package/lib/commonjs/providers/anime/animekai/create-animekai.js +507 -0
- package/lib/commonjs/providers/anime/animekai/create-animekai.js.map +1 -0
- package/lib/commonjs/providers/anime/index.js +4 -2
- package/lib/commonjs/providers/anime/index.js.map +1 -1
- package/lib/commonjs/providers/meta/anilist.js +1 -1
- package/lib/commonjs/providers/movies/multistream/utils.js +252 -26
- package/lib/commonjs/providers/movies/multistream/utils.js.map +1 -1
- package/lib/commonjs/utils/extension-utils.js +1 -1
- package/lib/commonjs/utils/extension-utils.js.map +1 -1
- package/lib/commonjs/utils/provider-maps.js +3 -0
- package/lib/commonjs/utils/provider-maps.js.map +1 -1
- package/lib/module/extension-registry.json +30 -1
- package/lib/module/extractors/index.js +1 -1
- package/lib/module/extractors/index.js.map +1 -1
- package/lib/module/extractors/megacloud.js +11 -5
- package/lib/module/extractors/megacloud.js.map +1 -1
- package/lib/module/extractors/megaup.js +85 -82
- package/lib/module/extractors/megaup.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/providers/anime/animekai/animekai.js +112 -0
- package/lib/module/providers/anime/animekai/animekai.js.map +1 -0
- package/lib/module/providers/anime/animekai/create-animekai.js +503 -0
- package/lib/module/providers/anime/animekai/create-animekai.js.map +1 -0
- package/lib/module/providers/anime/index.js +4 -2
- package/lib/module/providers/anime/index.js.map +1 -1
- package/lib/module/providers/meta/anilist.js +1 -1
- package/lib/module/providers/meta/anilist.js.map +1 -1
- package/lib/module/providers/movies/multistream/utils.js +249 -26
- package/lib/module/providers/movies/multistream/utils.js.map +1 -1
- package/lib/module/utils/extension-utils.js +1 -1
- package/lib/module/utils/extension-utils.js.map +1 -1
- package/lib/module/utils/provider-maps.js +3 -0
- package/lib/module/utils/provider-maps.js.map +1 -1
- package/lib/typescript/commonjs/src/extractors/index.d.ts +1 -1
- package/lib/typescript/commonjs/src/extractors/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/extractors/megacloud.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/extractors/megaup.d.ts +5 -15
- package/lib/typescript/commonjs/src/extractors/megaup.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +1 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/models/provider-context.d.ts +2 -2
- package/lib/typescript/commonjs/src/models/provider-context.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/providers/anime/animekai/animekai.d.ts +83 -0
- package/lib/typescript/commonjs/src/providers/anime/animekai/animekai.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/providers/anime/animekai/create-animekai.d.ts +28 -0
- package/lib/typescript/commonjs/src/providers/anime/animekai/create-animekai.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/providers/anime/index.d.ts +3 -1
- package/lib/typescript/commonjs/src/providers/anime/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/providers/movies/multistream/utils.d.ts +9 -0
- package/lib/typescript/commonjs/src/providers/movies/multistream/utils.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/extension-utils.d.ts +2 -2
- package/lib/typescript/commonjs/src/utils/extension-utils.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/provider-maps.d.ts +1 -0
- package/lib/typescript/commonjs/src/utils/provider-maps.d.ts.map +1 -1
- package/lib/typescript/module/src/extractors/index.d.ts +1 -1
- package/lib/typescript/module/src/extractors/index.d.ts.map +1 -1
- package/lib/typescript/module/src/extractors/megacloud.d.ts.map +1 -1
- package/lib/typescript/module/src/extractors/megaup.d.ts +5 -15
- package/lib/typescript/module/src/extractors/megaup.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +1 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/models/provider-context.d.ts +2 -2
- package/lib/typescript/module/src/models/provider-context.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/anime/animekai/animekai.d.ts +83 -0
- package/lib/typescript/module/src/providers/anime/animekai/animekai.d.ts.map +1 -0
- package/lib/typescript/module/src/providers/anime/animekai/create-animekai.d.ts +28 -0
- package/lib/typescript/module/src/providers/anime/animekai/create-animekai.d.ts.map +1 -0
- package/lib/typescript/module/src/providers/anime/index.d.ts +3 -1
- package/lib/typescript/module/src/providers/anime/index.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/movies/multistream/utils.d.ts +9 -0
- package/lib/typescript/module/src/providers/movies/multistream/utils.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/extension-utils.d.ts +2 -2
- package/lib/typescript/module/src/utils/extension-utils.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/provider-maps.d.ts +1 -0
- package/lib/typescript/module/src/utils/provider-maps.d.ts.map +1 -1
- package/package.json +4 -5
- package/src/extension-registry.json +30 -1
- package/src/extractors/index.ts +1 -1
- package/src/extractors/megacloud.ts +11 -5
- package/src/extractors/megaup.ts +92 -88
- package/src/index.tsx +1 -0
- package/src/models/provider-context.ts +2 -2
- package/src/providers/anime/animekai/animekai.ts +121 -0
- package/src/providers/anime/animekai/create-animekai.ts +579 -0
- package/src/providers/anime/index.ts +3 -1
- package/src/providers/meta/anilist.ts +1 -1
- package/src/providers/movies/multistream/utils.ts +213 -16
- package/src/utils/extension-utils.ts +1 -1
- package/src/utils/provider-maps.ts +3 -0
- package/lib/commonjs/providers/anime/animekai.js +0 -587
- package/lib/commonjs/providers/anime/animekai.js.map +0 -1
- package/lib/module/providers/anime/animekai.js +0 -583
- package/lib/module/providers/anime/animekai.js.map +0 -1
- package/lib/typescript/commonjs/src/providers/anime/animekai.d.ts +0 -89
- package/lib/typescript/commonjs/src/providers/anime/animekai.d.ts.map +0 -1
- package/lib/typescript/module/src/providers/anime/animekai.d.ts +0 -89
- package/lib/typescript/module/src/providers/anime/animekai.d.ts.map +0 -1
- package/src/providers/anime/animekai.ts +0 -627
|
@@ -1,627 +0,0 @@
|
|
|
1
|
-
import { type CheerioAPI, load } from 'cheerio';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
AnimeParser,
|
|
5
|
-
type ISearch,
|
|
6
|
-
type IAnimeInfo,
|
|
7
|
-
type IAnimeResult,
|
|
8
|
-
type ISource,
|
|
9
|
-
type IEpisodeServer,
|
|
10
|
-
StreamingServers,
|
|
11
|
-
MediaFormat,
|
|
12
|
-
SubOrDub,
|
|
13
|
-
MediaStatus,
|
|
14
|
-
type Intro,
|
|
15
|
-
} from '../../models';
|
|
16
|
-
|
|
17
|
-
import { MegaUp } from '../../extractors';
|
|
18
|
-
import axios from 'axios';
|
|
19
|
-
|
|
20
|
-
const { GenerateToken, DecodeIframeData, Decode } = new MegaUp();
|
|
21
|
-
|
|
22
|
-
class AnimeKai extends AnimeParser {
|
|
23
|
-
override readonly name = 'AnimeKai';
|
|
24
|
-
protected override baseUrl = 'https://animekai.to';
|
|
25
|
-
protected override logo =
|
|
26
|
-
'https://animekai.to/assets/uploads/37585a39fe8c8d8fafaa2c7bfbf5374ecac859ea6a0288a6da2c61f5.png';
|
|
27
|
-
protected override classPath = 'ANIME.AnimeKai';
|
|
28
|
-
|
|
29
|
-
constructor(customBaseURL?: string) {
|
|
30
|
-
super();
|
|
31
|
-
if (customBaseURL) {
|
|
32
|
-
if (customBaseURL.startsWith('http://') || customBaseURL.startsWith('https://')) {
|
|
33
|
-
this.baseUrl = customBaseURL;
|
|
34
|
-
} else {
|
|
35
|
-
this.baseUrl = `http://${customBaseURL}`;
|
|
36
|
-
}
|
|
37
|
-
} else {
|
|
38
|
-
this.baseUrl = this.baseUrl;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* @param query Search query
|
|
44
|
-
* @param page Page number (optional)
|
|
45
|
-
*/
|
|
46
|
-
override search(query: string, page: number = 1): Promise<ISearch<IAnimeResult>> {
|
|
47
|
-
if (page <= 0) {
|
|
48
|
-
page = 1;
|
|
49
|
-
}
|
|
50
|
-
return this.scrapeCardPage(`${this.baseUrl}/browser?keyword=${query.replace(/[\W_]+/g, '+')}&page=${page}`);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* @param page number
|
|
55
|
-
*/
|
|
56
|
-
fetchLatestCompleted(page: number = 1): Promise<ISearch<IAnimeResult>> {
|
|
57
|
-
if (page <= 0) {
|
|
58
|
-
page = 1;
|
|
59
|
-
}
|
|
60
|
-
return this.scrapeCardPage(`${this.baseUrl}/completed?page=${page}`);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* @param page number
|
|
65
|
-
*/
|
|
66
|
-
fetchRecentlyAdded(page: number = 1): Promise<ISearch<IAnimeResult>> {
|
|
67
|
-
if (page <= 0) {
|
|
68
|
-
page = 1;
|
|
69
|
-
}
|
|
70
|
-
return this.scrapeCardPage(`${this.baseUrl}/recent?page=${page}`);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* @param page number
|
|
75
|
-
*/
|
|
76
|
-
fetchRecentlyUpdated(page: number = 1): Promise<ISearch<IAnimeResult>> {
|
|
77
|
-
if (page <= 0) {
|
|
78
|
-
page = 1;
|
|
79
|
-
}
|
|
80
|
-
return this.scrapeCardPage(`${this.baseUrl}/updates?page=${page}`);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* @param page number
|
|
85
|
-
*/
|
|
86
|
-
fetchNewReleases(page: number = 1): Promise<ISearch<IAnimeResult>> {
|
|
87
|
-
if (page <= 0) {
|
|
88
|
-
page = 1;
|
|
89
|
-
}
|
|
90
|
-
return this.scrapeCardPage(`${this.baseUrl}/new-releases?page=${page}`);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* @param page number
|
|
95
|
-
*/
|
|
96
|
-
fetchMovie(page: number = 1): Promise<ISearch<IAnimeResult>> {
|
|
97
|
-
if (page <= 0) {
|
|
98
|
-
page = 1;
|
|
99
|
-
}
|
|
100
|
-
return this.scrapeCardPage(`${this.baseUrl}/movie?page=${page}`);
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* @param page number
|
|
104
|
-
*/
|
|
105
|
-
fetchTV(page: number = 1): Promise<ISearch<IAnimeResult>> {
|
|
106
|
-
if (page <= 0) {
|
|
107
|
-
page = 1;
|
|
108
|
-
}
|
|
109
|
-
return this.scrapeCardPage(`${this.baseUrl}/tv?page=${page}`);
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* @param page number
|
|
113
|
-
*/
|
|
114
|
-
fetchOVA(page: number = 1): Promise<ISearch<IAnimeResult>> {
|
|
115
|
-
if (page <= 0) {
|
|
116
|
-
page = 1;
|
|
117
|
-
}
|
|
118
|
-
return this.scrapeCardPage(`${this.baseUrl}/ova?page=${page}`);
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* @param page number
|
|
122
|
-
*/
|
|
123
|
-
fetchONA(page: number = 1): Promise<ISearch<IAnimeResult>> {
|
|
124
|
-
if (page <= 0) {
|
|
125
|
-
page = 1;
|
|
126
|
-
}
|
|
127
|
-
return this.scrapeCardPage(`${this.baseUrl}/ona?page=${page}`);
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* @param page number
|
|
131
|
-
*/
|
|
132
|
-
fetchSpecial(page: number = 1): Promise<ISearch<IAnimeResult>> {
|
|
133
|
-
if (page <= 0) {
|
|
134
|
-
page = 1;
|
|
135
|
-
}
|
|
136
|
-
return this.scrapeCardPage(`${this.baseUrl}/special?page=${page}`);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
async fetchGenres(): Promise<string[]> {
|
|
140
|
-
try {
|
|
141
|
-
const res: string[] = [];
|
|
142
|
-
const { data } = await axios.get(`${this.baseUrl}/home`, {
|
|
143
|
-
headers: this.Headers(),
|
|
144
|
-
});
|
|
145
|
-
const $ = load(data);
|
|
146
|
-
|
|
147
|
-
const sideBar = $('#menu');
|
|
148
|
-
sideBar.find('ul.c4 li a').each((i, ele) => {
|
|
149
|
-
const genres = $(ele);
|
|
150
|
-
res.push(genres.text().toLowerCase());
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
return res;
|
|
154
|
-
} catch (err) {
|
|
155
|
-
throw new Error('Something went wrong. Please try again later.');
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* @param page number
|
|
160
|
-
*/
|
|
161
|
-
genreSearch(genre: string, page: number = 1): Promise<ISearch<IAnimeResult>> {
|
|
162
|
-
if (genre === '') {
|
|
163
|
-
throw new Error('genre is empty');
|
|
164
|
-
}
|
|
165
|
-
if (page <= 0) {
|
|
166
|
-
page = 1;
|
|
167
|
-
}
|
|
168
|
-
return this.scrapeCardPage(`${this.baseUrl}/genres/${genre}?page=${page}`);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Fetches the schedule for a given date.
|
|
173
|
-
* @param date The date in format 'YYYY-MM-DD'. Defaults to the current date.
|
|
174
|
-
* @returns A promise that resolves to an object containing the search results.
|
|
175
|
-
*/
|
|
176
|
-
async fetchSchedule(date: string = new Date().toISOString().split('T')[0]!): Promise<ISearch<IAnimeResult>> {
|
|
177
|
-
try {
|
|
178
|
-
const res: ISearch<IAnimeResult> = {
|
|
179
|
-
results: [],
|
|
180
|
-
};
|
|
181
|
-
const { data } = await axios.get(
|
|
182
|
-
`${this.baseUrl}/ajax/schedule/items?tz=5.5&time=${Math.floor(new Date(`${date}T00:00:00Z`).getTime() / 1000)}`,
|
|
183
|
-
{ headers: this.Headers() }
|
|
184
|
-
);
|
|
185
|
-
const $ = load(data.result);
|
|
186
|
-
|
|
187
|
-
$('ul.collapsed li').each((i, ele) => {
|
|
188
|
-
const card = $(ele);
|
|
189
|
-
const titleElement = card.find('span.title');
|
|
190
|
-
const episodeText = card.find('span').last().text().trim();
|
|
191
|
-
|
|
192
|
-
res.results.push({
|
|
193
|
-
id: card.find('a').attr('href')?.split('/')[2]!, // Extract anime ID
|
|
194
|
-
title: titleElement.text().trim(),
|
|
195
|
-
japaneseTitle: titleElement.attr('data-jp'),
|
|
196
|
-
airingTime: card.find('span.time').text().trim(),
|
|
197
|
-
airingEpisode: episodeText.replace('EP ', ''), // Extract episode number
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
return res;
|
|
202
|
-
} catch (err) {
|
|
203
|
-
throw new Error('Something went wrong. Please try again later.');
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
async fetchSpotlight(): Promise<ISearch<IAnimeResult>> {
|
|
208
|
-
try {
|
|
209
|
-
const res: ISearch<IAnimeResult> = { results: [] };
|
|
210
|
-
const { data } = await axios.get(`${this.baseUrl}/home`, {
|
|
211
|
-
headers: this.Headers(),
|
|
212
|
-
});
|
|
213
|
-
const $ = load(data);
|
|
214
|
-
|
|
215
|
-
$('div.swiper-wrapper > div.swiper-slide').each((i, el) => {
|
|
216
|
-
const card = $(el);
|
|
217
|
-
const titleElement = card.find('div.detail > p.title');
|
|
218
|
-
const id = card.find('div.swiper-ctrl > a.btn').attr('href')?.replace('/watch/', '')!;
|
|
219
|
-
const img = card.attr('style');
|
|
220
|
-
res.results.push({
|
|
221
|
-
id: id!,
|
|
222
|
-
title: titleElement.text(),
|
|
223
|
-
japaneseTitle: titleElement.attr('data-jp'),
|
|
224
|
-
banner: img?.match(/background-image:\s*url\(["']?(.+?)["']?\)/)?.[1] || null,
|
|
225
|
-
url: `${this.baseUrl}/watch/${id}`,
|
|
226
|
-
type: card.find('div.detail > div.info').children().eq(-2).text().trim() as MediaFormat,
|
|
227
|
-
genres: card
|
|
228
|
-
.find('div.detail > div.info')
|
|
229
|
-
.children()
|
|
230
|
-
.last()
|
|
231
|
-
.text()
|
|
232
|
-
.trim()
|
|
233
|
-
.split(',')
|
|
234
|
-
.map((genre) => genre.trim()),
|
|
235
|
-
releaseDate: card.find('div.detail > div.mics >div:contains("Release")').children('span').text().trim(),
|
|
236
|
-
quality: card.find('div.detail > div.mics >div:contains("Quality")').children('span').text().trim(),
|
|
237
|
-
sub: parseInt(card.find('div.detail > div.info > span.sub').text().trim()) || 0,
|
|
238
|
-
dub: parseInt(card.find('div.detail > div.info > span.dub').text().trim()) || 0,
|
|
239
|
-
description: card.find('div.detail > p.desc').text().trim(),
|
|
240
|
-
});
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
return res;
|
|
244
|
-
} catch (error) {
|
|
245
|
-
throw new Error('Something went wrong. Please try again later.');
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
async fetchSearchSuggestions(query: string): Promise<ISearch<IAnimeResult>> {
|
|
250
|
-
try {
|
|
251
|
-
const { data } = await axios.get(`${this.baseUrl}/ajax/anime/search?keyword=${query.replace(/[\W_]+/g, '+')}`, {
|
|
252
|
-
headers: this.Headers(),
|
|
253
|
-
});
|
|
254
|
-
const $ = load(data.result.html);
|
|
255
|
-
const res: ISearch<IAnimeResult> = {
|
|
256
|
-
results: [],
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
$('a.aitem').each((i, el) => {
|
|
260
|
-
const card = $(el);
|
|
261
|
-
const image = card.find('.poster img').attr('src');
|
|
262
|
-
const titleElement = card.find('.title');
|
|
263
|
-
const title = titleElement.text().trim();
|
|
264
|
-
const japaneseTitle = titleElement.attr('data-jp');
|
|
265
|
-
const id = card.attr('href')?.split('/')[2];
|
|
266
|
-
const year = card.find('.info').children().eq(-2).text().trim();
|
|
267
|
-
const type = card.find('.info').children().eq(-3).text().trim();
|
|
268
|
-
const sub = parseInt(card.find('.info span.sub')?.text()) || 0;
|
|
269
|
-
const dub = parseInt(card.find('.info span.dub')?.text()) || 0;
|
|
270
|
-
const episodes =
|
|
271
|
-
parseInt(card.find('.info').children().eq(-4).text().trim() ?? card.find('.info span.sub')?.text()) || 0;
|
|
272
|
-
|
|
273
|
-
res.results.push({
|
|
274
|
-
id: id!,
|
|
275
|
-
title: title,
|
|
276
|
-
url: `${this.baseUrl}/watch/${id}`,
|
|
277
|
-
image: image!,
|
|
278
|
-
japaneseTitle: japaneseTitle || null,
|
|
279
|
-
type: type as MediaFormat,
|
|
280
|
-
year: year,
|
|
281
|
-
sub: sub,
|
|
282
|
-
dub: dub,
|
|
283
|
-
episodes: episodes,
|
|
284
|
-
});
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
return res;
|
|
288
|
-
} catch (error) {
|
|
289
|
-
throw new Error('Something went wrong. Please try again later.');
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* @param id Anime id
|
|
295
|
-
*/
|
|
296
|
-
override fetchAnimeInfo = async (id: string): Promise<IAnimeInfo> => {
|
|
297
|
-
const info: IAnimeInfo = {
|
|
298
|
-
id: id,
|
|
299
|
-
title: '',
|
|
300
|
-
};
|
|
301
|
-
try {
|
|
302
|
-
const { data } = await axios.get(`${this.baseUrl}/watch/${id}`, {
|
|
303
|
-
headers: this.Headers(),
|
|
304
|
-
});
|
|
305
|
-
const $ = load(data);
|
|
306
|
-
|
|
307
|
-
info.title = $('.entity-scroll > .title').text();
|
|
308
|
-
info.japaneseTitle = $('.entity-scroll > .title').attr('data-jp')?.trim();
|
|
309
|
-
info.image = $('div.poster > div >img').attr('src');
|
|
310
|
-
info.description = $('.entity-scroll > .desc').text().trim();
|
|
311
|
-
// Movie, TV, OVA, ONA, Special, Music
|
|
312
|
-
info.type = $('.entity-scroll > .info').children().last().text().toUpperCase() as MediaFormat;
|
|
313
|
-
info.url = `${this.baseUrl}/watch/${id}`;
|
|
314
|
-
info.recommendations = [];
|
|
315
|
-
$('section.sidebar-section:not(#related-anime) .aitem-col .aitem').each((i, ele) => {
|
|
316
|
-
const aTag = $(ele);
|
|
317
|
-
const id = aTag.attr('href')?.replace('/watch/', '');
|
|
318
|
-
info.recommendations?.push({
|
|
319
|
-
id: id!,
|
|
320
|
-
title: aTag.find('.title').text().trim(),
|
|
321
|
-
url: `${this.baseUrl}${aTag.attr('href')}`,
|
|
322
|
-
image: aTag.attr('style')?.match(/background-image:\s*url\('(.+?)'\)/)?.[1],
|
|
323
|
-
japaneseTitle: aTag.find('.title').attr('data-jp')?.trim(),
|
|
324
|
-
type: aTag.find('.info').children().last().text().trim() as MediaFormat,
|
|
325
|
-
sub: parseInt(aTag.find('.info span.sub')?.text()) || 0,
|
|
326
|
-
dub: parseInt(aTag.find('.info span.dub')?.text()) || 0,
|
|
327
|
-
episodes:
|
|
328
|
-
parseInt(aTag.find('.info').children().eq(-2).text().trim() ?? aTag.find('.info span.sub')?.text()) || 0,
|
|
329
|
-
});
|
|
330
|
-
});
|
|
331
|
-
info.relations = [];
|
|
332
|
-
$('section#related-anime .tab-body .aitem-col').each((i, ele) => {
|
|
333
|
-
const card = $(ele);
|
|
334
|
-
const aTag = card.find('a.aitem');
|
|
335
|
-
const id = aTag.attr('href')?.replace('/watch/', '');
|
|
336
|
-
info.relations?.push({
|
|
337
|
-
id: id!,
|
|
338
|
-
title: aTag.find('.title').text().trim(),
|
|
339
|
-
url: `${this.baseUrl}${aTag.attr('href')}`,
|
|
340
|
-
image: aTag.attr('style')?.match(/background-image:\s*url\('(.+?)'\)/)?.[1],
|
|
341
|
-
japaneseTitle: aTag.find('.title').attr('data-jp')?.trim(),
|
|
342
|
-
type: card.find('.info').children().eq(-2).text().trim() as MediaFormat,
|
|
343
|
-
sub: parseInt(card.find('.info span.sub')?.text()) || 0,
|
|
344
|
-
dub: parseInt(card.find('.info span.dub')?.text()) || 0,
|
|
345
|
-
relationType: card.find('.info').children().last().text().trim(),
|
|
346
|
-
episodes:
|
|
347
|
-
parseInt(card.find('.info').children().eq(-3).text().trim() ?? card.find('.info span.sub')?.text()) || 0,
|
|
348
|
-
});
|
|
349
|
-
});
|
|
350
|
-
const hasSub: boolean = $('.entity-scroll > .info > span.sub').length > 0;
|
|
351
|
-
const hasDub: boolean = $('.entity-scroll > .info > span.dub').length > 0;
|
|
352
|
-
|
|
353
|
-
if (hasSub) {
|
|
354
|
-
info.subOrDub = SubOrDub.SUB;
|
|
355
|
-
info.hasSub = hasSub;
|
|
356
|
-
}
|
|
357
|
-
if (hasDub) {
|
|
358
|
-
info.subOrDub = SubOrDub.DUB;
|
|
359
|
-
info.hasDub = hasDub;
|
|
360
|
-
}
|
|
361
|
-
if (hasSub && hasDub) {
|
|
362
|
-
info.subOrDub = SubOrDub.BOTH;
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
info.genres = [];
|
|
366
|
-
$('.entity-scroll > .detail')
|
|
367
|
-
.find('div:contains("Genres")')
|
|
368
|
-
.each(function () {
|
|
369
|
-
const genre = $(this).text().trim();
|
|
370
|
-
if (genre !== undefined) info.genres?.push(genre);
|
|
371
|
-
});
|
|
372
|
-
|
|
373
|
-
switch ($('.entity-scroll > .detail').find("div:contains('Status') > span").text().trim()) {
|
|
374
|
-
case 'Completed':
|
|
375
|
-
info.status = MediaStatus.COMPLETED;
|
|
376
|
-
break;
|
|
377
|
-
case 'Releasing':
|
|
378
|
-
info.status = MediaStatus.ONGOING;
|
|
379
|
-
break;
|
|
380
|
-
case 'Not yet aired':
|
|
381
|
-
info.status = MediaStatus.NOT_YET_AIRED;
|
|
382
|
-
break;
|
|
383
|
-
default:
|
|
384
|
-
info.status = MediaStatus.UNKNOWN;
|
|
385
|
-
break;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
info.season = $('.entity-scroll > .detail').find("div:contains('Premiered') > span").text().trim();
|
|
389
|
-
|
|
390
|
-
const ani_id = $('.rate-box#anime-rating').attr('data-id');
|
|
391
|
-
const episodesAjax = await axios.get(
|
|
392
|
-
`${this.baseUrl}/ajax/episodes/list?ani_id=${ani_id}&_=${GenerateToken(ani_id!)}`,
|
|
393
|
-
{
|
|
394
|
-
headers: {
|
|
395
|
-
'X-Requested-With': 'XMLHttpRequest',
|
|
396
|
-
'Referer': `${this.baseUrl}/watch/${id}`,
|
|
397
|
-
...this.Headers(),
|
|
398
|
-
},
|
|
399
|
-
}
|
|
400
|
-
);
|
|
401
|
-
const $$ = load(episodesAjax.data.result);
|
|
402
|
-
|
|
403
|
-
// Pre-calculate values used for all episodes
|
|
404
|
-
const episodeElements = $$('div.eplist > ul > li > a');
|
|
405
|
-
const subCount = parseInt($('.entity-scroll > .info > span.sub').text().trim()) || 0;
|
|
406
|
-
const dubCount = parseInt($('.entity-scroll > .info > span.dub').text().trim()) || 0;
|
|
407
|
-
|
|
408
|
-
info.totalEpisodes = $$('div.eplist > ul > li').length;
|
|
409
|
-
info.episodes = [];
|
|
410
|
-
|
|
411
|
-
episodeElements.each((i, el) => {
|
|
412
|
-
const $el = $$(el);
|
|
413
|
-
const href = `${$el.attr('href')}ep=${$el.attr('num')}` || '';
|
|
414
|
-
const number = parseInt($el.attr('data-number') || '0');
|
|
415
|
-
const episodeId = `${info.id}$ep=${$$(el).attr('num')}$token=${$$(el).attr('token')}`; //appending token to episode id, as it is required to fetch servers keeping the structure same as other providers
|
|
416
|
-
|
|
417
|
-
info.episodes?.push({
|
|
418
|
-
id: episodeId,
|
|
419
|
-
number: number,
|
|
420
|
-
title: $el.children('span').text().trim(),
|
|
421
|
-
isFiller: $el.hasClass('filler'),
|
|
422
|
-
isSubbed: number <= subCount,
|
|
423
|
-
isDubbed: number <= dubCount,
|
|
424
|
-
url: this.baseUrl + href,
|
|
425
|
-
});
|
|
426
|
-
});
|
|
427
|
-
|
|
428
|
-
return info;
|
|
429
|
-
} catch (err) {
|
|
430
|
-
throw new Error((err as Error).message);
|
|
431
|
-
}
|
|
432
|
-
};
|
|
433
|
-
|
|
434
|
-
/**
|
|
435
|
-
*
|
|
436
|
-
* @param episodeId Episode id
|
|
437
|
-
* @param server server type (default `VidCloud`) (optional)
|
|
438
|
-
* @param subOrDub sub or dub (default `SubOrDub.SUB`) (optional)
|
|
439
|
-
*/
|
|
440
|
-
override fetchEpisodeSources = async (
|
|
441
|
-
episodeId: string,
|
|
442
|
-
server: StreamingServers = StreamingServers.MegaUp,
|
|
443
|
-
subOrDub: SubOrDub = SubOrDub.SUB
|
|
444
|
-
): Promise<ISource> => {
|
|
445
|
-
if (episodeId.startsWith('http')) {
|
|
446
|
-
const serverUrl = new URL(episodeId);
|
|
447
|
-
switch (server) {
|
|
448
|
-
case StreamingServers.MegaUp:
|
|
449
|
-
return {
|
|
450
|
-
headers: { Referer: serverUrl.href },
|
|
451
|
-
...(await new MegaUp().extract(serverUrl)),
|
|
452
|
-
download: serverUrl.href.replace(/\/e\//, '/download/'),
|
|
453
|
-
};
|
|
454
|
-
default:
|
|
455
|
-
return {
|
|
456
|
-
headers: { Referer: serverUrl.href },
|
|
457
|
-
...(await new MegaUp().extract(serverUrl)),
|
|
458
|
-
download: serverUrl.href.replace(/\/e\//, '/download/'),
|
|
459
|
-
};
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
try {
|
|
464
|
-
const servers = await this.fetchEpisodeServers(episodeId, subOrDub);
|
|
465
|
-
const i = servers.findIndex((s) => s.name.toLowerCase().includes(server)); //for now only megaup is available, hence directly using it
|
|
466
|
-
|
|
467
|
-
if (i === -1) {
|
|
468
|
-
throw new Error(`Server ${server} not found`);
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
const serverUrl: URL = new URL(servers[i]!.url);
|
|
472
|
-
const sources = await this.fetchEpisodeSources(serverUrl.href, server, subOrDub);
|
|
473
|
-
sources.intro = servers[i]?.intro as Intro;
|
|
474
|
-
sources.outro = servers[i]?.outro as Intro;
|
|
475
|
-
return sources;
|
|
476
|
-
} catch (err) {
|
|
477
|
-
throw new Error((err as Error).message);
|
|
478
|
-
}
|
|
479
|
-
};
|
|
480
|
-
|
|
481
|
-
/**
|
|
482
|
-
* @param url string
|
|
483
|
-
*/
|
|
484
|
-
private scrapeCardPage = async (url: string): Promise<ISearch<IAnimeResult>> => {
|
|
485
|
-
try {
|
|
486
|
-
const res: ISearch<IAnimeResult> = {
|
|
487
|
-
currentPage: 0,
|
|
488
|
-
hasNextPage: false,
|
|
489
|
-
totalPages: 0,
|
|
490
|
-
results: [],
|
|
491
|
-
};
|
|
492
|
-
const { data } = await axios.get(url, {
|
|
493
|
-
headers: this.Headers(),
|
|
494
|
-
});
|
|
495
|
-
const $ = load(data);
|
|
496
|
-
|
|
497
|
-
const pagination = $('ul.pagination');
|
|
498
|
-
res.currentPage = parseInt(pagination.find('.page-item.active span.page-link').text().trim()) || 0;
|
|
499
|
-
const nextPage = pagination.find('.page-item.active').next().find('a.page-link').attr('href')?.split('page=')[1];
|
|
500
|
-
if (nextPage !== undefined && nextPage !== '') {
|
|
501
|
-
res.hasNextPage = true;
|
|
502
|
-
}
|
|
503
|
-
const totalPages = pagination.find('.page-item:last-child a.page-link').attr('href')?.split('page=')[1];
|
|
504
|
-
if (totalPages === undefined || totalPages === '') {
|
|
505
|
-
res.totalPages = res.currentPage;
|
|
506
|
-
} else {
|
|
507
|
-
res.totalPages = parseInt(totalPages) || 0;
|
|
508
|
-
}
|
|
509
|
-
res.results = await this.scrapeCard($);
|
|
510
|
-
if (res.results.length === 0) {
|
|
511
|
-
res.currentPage = 0;
|
|
512
|
-
res.hasNextPage = false;
|
|
513
|
-
res.totalPages = 0;
|
|
514
|
-
}
|
|
515
|
-
return res;
|
|
516
|
-
} catch (err) {
|
|
517
|
-
throw new Error('Something went wrong. Please try again later.');
|
|
518
|
-
}
|
|
519
|
-
};
|
|
520
|
-
|
|
521
|
-
/**
|
|
522
|
-
* @param $ cheerio instance
|
|
523
|
-
*/
|
|
524
|
-
private scrapeCard = async ($: CheerioAPI): Promise<IAnimeResult[]> => {
|
|
525
|
-
try {
|
|
526
|
-
const results: IAnimeResult[] = [];
|
|
527
|
-
|
|
528
|
-
$('.aitem').each((i, ele) => {
|
|
529
|
-
const card = $(ele);
|
|
530
|
-
const atag = card.find('div.inner > a');
|
|
531
|
-
const id = atag.attr('href')?.replace('/watch/', '');
|
|
532
|
-
const type = card.find('.info').children().last()?.text().trim();
|
|
533
|
-
results.push({
|
|
534
|
-
id: id!,
|
|
535
|
-
title: atag.text().trim(),
|
|
536
|
-
url: `${this.baseUrl}${atag.attr('href')}`,
|
|
537
|
-
image: card.find('img')?.attr('data-src') ?? card.find('img')?.attr('src'),
|
|
538
|
-
// duration: card.find('.fdi-duration')?.text(),
|
|
539
|
-
japaneseTitle: card.find('a.title')?.attr('data-jp')?.trim(),
|
|
540
|
-
type: type as MediaFormat,
|
|
541
|
-
// nsfw: card.find('.tick-rate')?.text() === '18+' ? true : false,
|
|
542
|
-
sub: parseInt(card.find('.info span.sub')?.text()) || 0,
|
|
543
|
-
dub: parseInt(card.find('.info span.dub')?.text()) || 0,
|
|
544
|
-
episodes:
|
|
545
|
-
parseInt(card.find('.info').children().eq(-2).text().trim() ?? card.find('.info span.sub')?.text()) || 0, //if no direct episode count, then just use sub count
|
|
546
|
-
});
|
|
547
|
-
});
|
|
548
|
-
return results;
|
|
549
|
-
} catch (err) {
|
|
550
|
-
throw new Error('Something went wrong. Please try again later.');
|
|
551
|
-
}
|
|
552
|
-
};
|
|
553
|
-
/**
|
|
554
|
-
* @param episodeId Episode id
|
|
555
|
-
* @param subOrDub sub or dub (default `sub`) (optional)
|
|
556
|
-
*/
|
|
557
|
-
override fetchEpisodeServers = async (
|
|
558
|
-
episodeId: string,
|
|
559
|
-
subOrDub: SubOrDub = SubOrDub.SUB
|
|
560
|
-
): Promise<IEpisodeServer[]> => {
|
|
561
|
-
if (!episodeId.startsWith(this.baseUrl + '/ajax'))
|
|
562
|
-
episodeId = `${this.baseUrl}/ajax/links/list?token=${episodeId.split('$token=')[1]}&_=${GenerateToken(
|
|
563
|
-
episodeId.split('$token=')[1]!
|
|
564
|
-
)}`;
|
|
565
|
-
try {
|
|
566
|
-
const { data } = await axios.get(episodeId, {
|
|
567
|
-
headers: this.Headers(),
|
|
568
|
-
});
|
|
569
|
-
const $ = load(data.result);
|
|
570
|
-
const servers: IEpisodeServer[] = [];
|
|
571
|
-
const serverItems = $(`.server-items.lang-group[data-id="${subOrDub}"] .server`);
|
|
572
|
-
await Promise.all(
|
|
573
|
-
serverItems.map(async (i, server) => {
|
|
574
|
-
const id = $(server).attr('data-lid');
|
|
575
|
-
const { data } = await axios.get(`${this.baseUrl}/ajax/links/view?id=${id}&_=${GenerateToken(id!)}`, {
|
|
576
|
-
headers: this.Headers(),
|
|
577
|
-
});
|
|
578
|
-
const decodedData = JSON.parse(Decode(data.result));
|
|
579
|
-
servers.push({
|
|
580
|
-
name: `MegaUp ${$(server).text().trim()}`!, //megaup is the only server for now
|
|
581
|
-
url: decodedData.url,
|
|
582
|
-
intro: {
|
|
583
|
-
start: decodedData?.skip.intro[0],
|
|
584
|
-
end: decodedData?.skip.intro[1],
|
|
585
|
-
},
|
|
586
|
-
outro: {
|
|
587
|
-
start: decodedData?.skip.outro[0],
|
|
588
|
-
end: decodedData?.skip.outro[1],
|
|
589
|
-
},
|
|
590
|
-
});
|
|
591
|
-
})
|
|
592
|
-
);
|
|
593
|
-
return servers;
|
|
594
|
-
} catch (err) {
|
|
595
|
-
throw new Error((err as Error).message);
|
|
596
|
-
}
|
|
597
|
-
};
|
|
598
|
-
|
|
599
|
-
private Headers(): Record<string, string> {
|
|
600
|
-
return {
|
|
601
|
-
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:134.0) Gecko/20100101 Firefox/134.0',
|
|
602
|
-
'Accept': 'text/html, */*; q=0.01',
|
|
603
|
-
'Accept-Language': 'en-US,en;q=0.5',
|
|
604
|
-
'Sec-GPC': '1',
|
|
605
|
-
'Sec-Fetch-Dest': 'empty',
|
|
606
|
-
'Sec-Fetch-Mode': 'cors',
|
|
607
|
-
'Sec-Fetch-Site': 'same-origin',
|
|
608
|
-
'Priority': 'u=0',
|
|
609
|
-
'Pragma': 'no-cache',
|
|
610
|
-
'Cache-Control': 'no-cache',
|
|
611
|
-
'Referer': `${this.baseUrl}/`,
|
|
612
|
-
'Cookie':
|
|
613
|
-
'usertype=guest; session=hxYne0BNXguMc8zK1FHqQKXPmmoANzBBOuNPM64a; cf_clearance=WfGWV1bKGAaNySbh.yzCyuobBOtjg0ncfPwMhtsvsrs-1737611098-1.2.1.1-zWHcaytuokjFTKbCAxnSPDc_BWAeubpf9TAAVfuJ2vZuyYXByqZBXAZDl_VILwkO5NOLck8N0C4uQr4yGLbXRcZ_7jfWUvfPGayTADQLuh.SH.7bvhC7DmxrMGZ8SW.hGKEQzRJf8N7h6ZZ27GMyqOfz1zfrOiu9W30DhEtW2N7FAXUPrdolyKjCsP1AK3DqsDtYOiiPNLnu47l.zxK80XogfBRQkiGecCBaeDOJHenjn._Zgykkr.F_2bj2C3AS3A5mCpZSlWK5lqhV6jQSQLF9wKWitHye39V.6NoE3RE',
|
|
614
|
-
};
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
// (async () => {
|
|
619
|
-
// const animekai = new AnimeKai();
|
|
620
|
-
// const anime = await animekai.search('dandadan');
|
|
621
|
-
// const info = await animekai.fetchAnimeInfo('solo-leveling-season-2-arise-from-the-shadow-x7rq');
|
|
622
|
-
// console.log(info.episodes);
|
|
623
|
-
// const sources = await animekai.fetchEpisodeSources(info?.episodes![0]?.id!);
|
|
624
|
-
// console.log(sources);
|
|
625
|
-
// })();
|
|
626
|
-
|
|
627
|
-
export default AnimeKai;
|