react-native-consumet 0.7.1 → 0.7.2
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/android/build.gradle +1 -0
- package/android/generated/java/com/consumet/NativeConsumetSpec.java +4 -4
- package/android/generated/jni/RNConsumetSpec-generated.cpp +6 -6
- package/android/generated/jni/react/renderer/components/RNConsumetSpec/RNConsumetSpecJSI-generated.cpp +7 -8
- package/android/generated/jni/react/renderer/components/RNConsumetSpec/RNConsumetSpecJSI.h +9 -9
- package/android/src/main/java/com/consumet/ConsumetModule.kt +6 -103
- package/android/src/main/java/com/consumet/DeobfuscatorModule.kt +90 -0
- package/ios/generated/RNConsumetSpec/RNConsumetSpec-generated.mm +7 -7
- package/ios/generated/RNConsumetSpec/RNConsumetSpec.h +3 -4
- package/ios/generated/RNConsumetSpecJSI-generated.cpp +7 -8
- package/ios/generated/RNConsumetSpecJSI.h +9 -9
- package/lib/commonjs/NativeConsumet.ts +2 -2
- package/lib/commonjs/extractors/index.js +7 -0
- package/lib/commonjs/extractors/index.js.map +1 -1
- package/lib/commonjs/extractors/luffy.js +38 -0
- package/lib/commonjs/extractors/luffy.js.map +1 -0
- package/lib/commonjs/extractors/megacloud/index.js +25 -8
- package/lib/commonjs/extractors/megacloud/index.js.map +1 -1
- package/lib/commonjs/extractors/streamwish.js +2 -2
- package/lib/commonjs/extractors/streamwish.js.map +1 -1
- package/lib/commonjs/extractors/vidcloud.js +24 -15
- package/lib/commonjs/extractors/vidcloud.js.map +1 -1
- package/lib/commonjs/extractors/vidhide.js +2 -2
- package/lib/commonjs/extractors/vidhide.js.map +1 -1
- package/lib/commonjs/extractors/voe.js +57 -32
- package/lib/commonjs/extractors/voe.js.map +1 -1
- package/lib/commonjs/index.js +6 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/types.js +1 -0
- package/lib/commonjs/models/types.js.map +1 -1
- package/lib/commonjs/providers/anime/animeowl.js +499 -0
- package/lib/commonjs/providers/anime/animeowl.js.map +1 -0
- package/lib/commonjs/providers/anime/index.js +3 -1
- package/lib/commonjs/providers/anime/index.js.map +1 -1
- package/lib/commonjs/providers/anime/zoro.js +1 -2
- package/lib/commonjs/providers/anime/zoro.js.map +1 -1
- package/lib/commonjs/providers/meta/anilist.js +6 -5
- package/lib/commonjs/providers/meta/anilist.js.map +1 -1
- package/lib/commonjs/utils/index.js +6 -0
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/providers-list.js +1 -1
- package/lib/commonjs/utils/providers-list.js.map +1 -1
- package/lib/module/NativeConsumet.ts +2 -2
- package/lib/module/extractors/index.js +2 -1
- package/lib/module/extractors/index.js.map +1 -1
- package/lib/module/extractors/luffy.js +34 -0
- package/lib/module/extractors/luffy.js.map +1 -0
- package/lib/module/extractors/megacloud/index.js +24 -8
- package/lib/module/extractors/megacloud/index.js.map +1 -1
- package/lib/module/extractors/streamwish.js +2 -2
- package/lib/module/extractors/streamwish.js.map +1 -1
- package/lib/module/extractors/vidcloud.js +23 -15
- package/lib/module/extractors/vidcloud.js.map +1 -1
- package/lib/module/extractors/vidhide.js +2 -2
- package/lib/module/extractors/vidhide.js.map +1 -1
- package/lib/module/extractors/voe.js +57 -32
- package/lib/module/extractors/voe.js.map +1 -1
- package/lib/module/index.js +2 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/types.js +1 -0
- package/lib/module/models/types.js.map +1 -1
- package/lib/module/providers/anime/animeowl.js +495 -0
- package/lib/module/providers/anime/animeowl.js.map +1 -0
- package/lib/module/providers/anime/index.js +3 -1
- package/lib/module/providers/anime/index.js.map +1 -1
- package/lib/module/providers/anime/zoro.js +1 -2
- package/lib/module/providers/anime/zoro.js.map +1 -1
- package/lib/module/providers/meta/anilist.js +6 -5
- package/lib/module/providers/meta/anilist.js.map +1 -1
- package/lib/module/utils/index.js +2 -2
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/providers-list.js +1 -1
- package/lib/module/utils/providers-list.js.map +1 -1
- package/lib/typescript/commonjs/src/NativeConsumet.d.ts +2 -2
- package/lib/typescript/commonjs/src/NativeConsumet.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/extractors/index.d.ts +2 -1
- package/lib/typescript/commonjs/src/extractors/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/extractors/luffy.d.ts +9 -0
- package/lib/typescript/commonjs/src/extractors/luffy.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/extractors/megacloud/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/extractors/streamwish.d.ts +1 -1
- package/lib/typescript/commonjs/src/extractors/streamwish.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/extractors/vidcloud.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/extractors/voe.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +2 -2
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/models/types.d.ts +2 -1
- package/lib/typescript/commonjs/src/models/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/providers/anime/animeowl.d.ts +76 -0
- package/lib/typescript/commonjs/src/providers/anime/animeowl.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/providers/anime/index.d.ts +2 -0
- package/lib/typescript/commonjs/src/providers/anime/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/providers/anime/zoro.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/index.d.ts +2 -2
- package/lib/typescript/commonjs/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/providers-list.d.ts +1 -1
- package/lib/typescript/commonjs/src/utils/providers-list.d.ts.map +1 -1
- package/lib/typescript/module/src/NativeConsumet.d.ts +2 -2
- package/lib/typescript/module/src/NativeConsumet.d.ts.map +1 -1
- package/lib/typescript/module/src/extractors/index.d.ts +2 -1
- package/lib/typescript/module/src/extractors/index.d.ts.map +1 -1
- package/lib/typescript/module/src/extractors/luffy.d.ts +9 -0
- package/lib/typescript/module/src/extractors/luffy.d.ts.map +1 -0
- package/lib/typescript/module/src/extractors/megacloud/index.d.ts.map +1 -1
- package/lib/typescript/module/src/extractors/streamwish.d.ts +1 -1
- package/lib/typescript/module/src/extractors/streamwish.d.ts.map +1 -1
- package/lib/typescript/module/src/extractors/vidcloud.d.ts.map +1 -1
- package/lib/typescript/module/src/extractors/voe.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +2 -2
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/models/types.d.ts +2 -1
- package/lib/typescript/module/src/models/types.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/anime/animeowl.d.ts +76 -0
- package/lib/typescript/module/src/providers/anime/animeowl.d.ts.map +1 -0
- package/lib/typescript/module/src/providers/anime/index.d.ts +2 -0
- package/lib/typescript/module/src/providers/anime/index.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/anime/zoro.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/index.d.ts +2 -2
- package/lib/typescript/module/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/providers-list.d.ts +1 -1
- package/lib/typescript/module/src/utils/providers-list.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/NativeConsumet.ts +2 -2
- package/src/extractors/index.ts +2 -0
- package/src/extractors/luffy.ts +32 -0
- package/src/extractors/megacloud/index.ts +25 -8
- package/src/extractors/streamwish.ts +2 -2
- package/src/extractors/vidcloud.ts +22 -15
- package/src/extractors/vidhide.ts +2 -2
- package/src/extractors/voe.ts +66 -34
- package/src/index.tsx +2 -0
- package/src/models/types.ts +1 -0
- package/src/providers/anime/animeowl.ts +564 -0
- package/src/providers/anime/index.ts +2 -0
- package/src/providers/anime/zoro.ts +1 -2
- package/src/providers/meta/anilist.ts +5 -5
- package/src/utils/index.ts +2 -0
- package/src/utils/providers-list.ts +1 -0
- package/android/src/main/assets/crypto-js.js +0 -1
- package/android/src/main/assets/megacloud.decodedpng.js +0 -606
- package/android/src/main/assets/megacloud.getsrcs.js +0 -832
|
@@ -0,0 +1,564 @@
|
|
|
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
|
+
SubOrSub,
|
|
13
|
+
type IAnimeEpisode,
|
|
14
|
+
MediaStatus,
|
|
15
|
+
} from '../../models';
|
|
16
|
+
|
|
17
|
+
import { Luffy } from '../../utils';
|
|
18
|
+
|
|
19
|
+
class AnimeOwl extends AnimeParser {
|
|
20
|
+
override readonly name = 'AnimeOwl';
|
|
21
|
+
protected override baseUrl = 'https://animeowl.me';
|
|
22
|
+
protected apiUrl = 'https://animeowl.me/api';
|
|
23
|
+
protected override logo = 'https://animeowl.me/images/favicon-96x96.png';
|
|
24
|
+
protected override classPath = 'ANIME.AnimeOwl';
|
|
25
|
+
|
|
26
|
+
constructor(customBaseURL?: string) {
|
|
27
|
+
super(...arguments);
|
|
28
|
+
if (customBaseURL) {
|
|
29
|
+
if (customBaseURL.startsWith('http://') || customBaseURL.startsWith('https://')) {
|
|
30
|
+
this.baseUrl = customBaseURL;
|
|
31
|
+
} else {
|
|
32
|
+
this.baseUrl = `http://${customBaseURL}`;
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
this.baseUrl = this.baseUrl;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @param query Search query
|
|
41
|
+
* @param page Page number (optional)
|
|
42
|
+
*/
|
|
43
|
+
override search = async (query: string, page: number = 1): Promise<ISearch<IAnimeResult>> => {
|
|
44
|
+
if (0 >= page) {
|
|
45
|
+
page = 1;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const { data } = await this.client.post(`${this.apiUrl}/advance-search`, {
|
|
49
|
+
clicked: false,
|
|
50
|
+
limit: 24,
|
|
51
|
+
page: page - 1,
|
|
52
|
+
pageCount: 1,
|
|
53
|
+
value: query,
|
|
54
|
+
selected: {
|
|
55
|
+
type: [],
|
|
56
|
+
genre: [],
|
|
57
|
+
year: [],
|
|
58
|
+
country: [],
|
|
59
|
+
season: [],
|
|
60
|
+
status: [],
|
|
61
|
+
sort: [],
|
|
62
|
+
language: [],
|
|
63
|
+
},
|
|
64
|
+
results: [],
|
|
65
|
+
lang22: 3,
|
|
66
|
+
sortt: 4,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const res: ISearch<IAnimeResult> = {
|
|
70
|
+
currentPage: page,
|
|
71
|
+
hasNextPage: page < Math.ceil(data.total / 24),
|
|
72
|
+
totalPages: Math.ceil(data.total / 24),
|
|
73
|
+
results: [],
|
|
74
|
+
};
|
|
75
|
+
res.results = data.results.map(
|
|
76
|
+
(item: any): IAnimeResult => ({
|
|
77
|
+
id: `${item.anime_slug}$${item.anime_id}`,
|
|
78
|
+
title: item.en_name || item.anime_name,
|
|
79
|
+
url: `${this.baseUrl}/anime/${item.anime_slug}`,
|
|
80
|
+
image: `${this.baseUrl}${item.image}` || `${this.baseUrl}${item.thumbnail}` || `${this.baseUrl}${item.webp}`,
|
|
81
|
+
japaneseTitle: item.jp_name,
|
|
82
|
+
sub: parseInt(item.total_episodes) || 0,
|
|
83
|
+
dub: parseInt(item.total_dub_episodes) || 0,
|
|
84
|
+
episodes: parseInt(item.total_episodes) || 0,
|
|
85
|
+
})
|
|
86
|
+
);
|
|
87
|
+
return res;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @param page number
|
|
92
|
+
*/
|
|
93
|
+
fetchTopAiring(page: number = 1): Promise<ISearch<IAnimeResult>> {
|
|
94
|
+
if (0 >= page) {
|
|
95
|
+
page = 1;
|
|
96
|
+
}
|
|
97
|
+
return this.scrapeCardPage(`${this.baseUrl}/trending?page=${page}`);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* @param page number
|
|
101
|
+
*/
|
|
102
|
+
fetchRecentlyUpdated(page: number = 1): Promise<ISearch<IAnimeResult>> {
|
|
103
|
+
if (0 >= page) {
|
|
104
|
+
page = 1;
|
|
105
|
+
}
|
|
106
|
+
return this.scrapeCardPage(`${this.baseUrl}/recent-episode/sub?page=${page}`);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* @param page number
|
|
110
|
+
*/
|
|
111
|
+
fetchMovie(page: number = 1): Promise<ISearch<IAnimeResult>> {
|
|
112
|
+
if (0 >= page) {
|
|
113
|
+
page = 1;
|
|
114
|
+
}
|
|
115
|
+
return this.scrapeCardPage(`${this.baseUrl}/type/movie?page=${page}`);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* @param page number
|
|
119
|
+
*/
|
|
120
|
+
fetchTV(page: number = 1): Promise<ISearch<IAnimeResult>> {
|
|
121
|
+
if (0 >= page) {
|
|
122
|
+
page = 1;
|
|
123
|
+
}
|
|
124
|
+
return this.scrapeCardPage(`${this.baseUrl}/type/tv?page=${page}`);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* @param page number
|
|
128
|
+
*/
|
|
129
|
+
fetchOVA(page: number = 1): Promise<ISearch<IAnimeResult>> {
|
|
130
|
+
if (0 >= page) {
|
|
131
|
+
page = 1;
|
|
132
|
+
}
|
|
133
|
+
return this.scrapeCardPage(`${this.baseUrl}/type/ova?page=${page}`);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* @param page number
|
|
137
|
+
*/
|
|
138
|
+
fetchONA(page: number = 1): Promise<ISearch<IAnimeResult>> {
|
|
139
|
+
if (0 >= page) {
|
|
140
|
+
page = 1;
|
|
141
|
+
}
|
|
142
|
+
return this.scrapeCardPage(`${this.baseUrl}/type/ona?page=${page}`);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* @param page number
|
|
146
|
+
*/
|
|
147
|
+
fetchSpecial(page: number = 1): Promise<ISearch<IAnimeResult>> {
|
|
148
|
+
if (0 >= page) {
|
|
149
|
+
page = 1;
|
|
150
|
+
}
|
|
151
|
+
return this.scrapeCardPage(`${this.baseUrl}/type/special?page=${page}`);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
async fetchGenres(): Promise<string[]> {
|
|
155
|
+
try {
|
|
156
|
+
const res: string[] = [];
|
|
157
|
+
const { data } = await this.client.get(`${this.baseUrl}/home`);
|
|
158
|
+
const $ = load(data);
|
|
159
|
+
|
|
160
|
+
$('.nav-genre > .sidebar-grid a').each((i, el) => {
|
|
161
|
+
res.push($(el).text().trim().toLowerCase());
|
|
162
|
+
});
|
|
163
|
+
return res;
|
|
164
|
+
} catch (err) {
|
|
165
|
+
throw new Error('Something went wrong. Please try again later.');
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* @param page number
|
|
170
|
+
*/
|
|
171
|
+
genreSearch(genre: string, page: number = 1): Promise<ISearch<IAnimeResult>> {
|
|
172
|
+
if (genre == '') {
|
|
173
|
+
throw new Error('genre is empty');
|
|
174
|
+
}
|
|
175
|
+
if (0 >= page) {
|
|
176
|
+
page = 1;
|
|
177
|
+
}
|
|
178
|
+
return this.scrapeCardPage(`${this.baseUrl}/genre/${genre}?page=${page}`);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
async fetchSpotlight(): Promise<ISearch<IAnimeResult>> {
|
|
182
|
+
try {
|
|
183
|
+
const res: ISearch<IAnimeResult> = { results: [] };
|
|
184
|
+
const { data } = await this.client.get(`${this.baseUrl}/home`);
|
|
185
|
+
const $ = load(data);
|
|
186
|
+
|
|
187
|
+
$('.carousel-inner > .carousel-item').each((i, el) => {
|
|
188
|
+
const card = $(el);
|
|
189
|
+
const titleElement = card.find('.slide-title');
|
|
190
|
+
const id = card.find('a.anime-play').attr('href')?.split(`${this.baseUrl}/anime/`)[1]!;
|
|
191
|
+
const img = card.find('img.film-poster-img');
|
|
192
|
+
res.results.push({
|
|
193
|
+
id: id!,
|
|
194
|
+
title: titleElement.text().trim(),
|
|
195
|
+
banner: card
|
|
196
|
+
.find('.main-bg')
|
|
197
|
+
?.css('background')
|
|
198
|
+
?.replace(/url\(["']?(.+?)["']?\)/, '$1')
|
|
199
|
+
.trim(),
|
|
200
|
+
url: `${this.baseUrl}/anime/${id}`,
|
|
201
|
+
type: card.find('.anime-type span').text().trim() as MediaFormat,
|
|
202
|
+
duration: card.find('.anime-duration span').first().text().trim(),
|
|
203
|
+
episodes: parseInt(card.find('.anime-duration.bg-purple span').text()) || 0,
|
|
204
|
+
description: card
|
|
205
|
+
.find('.anime-desc')
|
|
206
|
+
.text()
|
|
207
|
+
.replace(/\s*\n\s*/g, ' ')
|
|
208
|
+
.trim(),
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
return res;
|
|
213
|
+
} catch (error) {
|
|
214
|
+
throw new Error('Something went wrong. Please try again later.');
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
async fetchSearchSuggestions(query: string): Promise<ISearch<IAnimeResult>> {
|
|
219
|
+
try {
|
|
220
|
+
const encodedQuery = encodeURIComponent(query);
|
|
221
|
+
const { data } = await this.client.get(`${this.apiUrl}/live-search/${encodedQuery}`);
|
|
222
|
+
const res: ISearch<IAnimeResult> = {
|
|
223
|
+
results: [],
|
|
224
|
+
};
|
|
225
|
+
data.map((item: any) => {
|
|
226
|
+
res.results.push({
|
|
227
|
+
image: `${this.baseUrl}${item.thumbnail}` || `${this.baseUrl}${item.webp}`,
|
|
228
|
+
id: `${item.slug}$${item.id}`!,
|
|
229
|
+
title: item.en_name,
|
|
230
|
+
japaneseTitle: item.anime_name,
|
|
231
|
+
releaseDate: item.year_name,
|
|
232
|
+
url: `${this.baseUrl}/anime/${item.slug}`,
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
return res;
|
|
237
|
+
} catch (error) {
|
|
238
|
+
throw new Error('Something went wrong. Please try again later.');
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* @param id Anime id
|
|
244
|
+
*/
|
|
245
|
+
override fetchAnimeInfo = async (id: string): Promise<IAnimeInfo> => {
|
|
246
|
+
const info: IAnimeInfo = {
|
|
247
|
+
id: id,
|
|
248
|
+
title: '',
|
|
249
|
+
};
|
|
250
|
+
try {
|
|
251
|
+
const { data } = await this.client.get(`${this.baseUrl}/anime/${id.split('$')[0]}`);
|
|
252
|
+
const $ = load(data);
|
|
253
|
+
|
|
254
|
+
info.title = $('h1.anime-name').text();
|
|
255
|
+
info.japaneseTitle = $('h2.anime-romaji').text();
|
|
256
|
+
info.image = `${this.baseUrl}${$('div.cover-img-container >img').attr('src')}`;
|
|
257
|
+
info.description = $('div.anime-desc')
|
|
258
|
+
.text()
|
|
259
|
+
.replace(/\s*\n\s*/g, ' ')
|
|
260
|
+
.trim();
|
|
261
|
+
// Movie, TV, OVA, ONA, Special, Music
|
|
262
|
+
info.type = $('div.type > a').text().toUpperCase() as MediaFormat;
|
|
263
|
+
info.url = `${this.baseUrl}/anime/${id.split('$')[0]}`;
|
|
264
|
+
// info.recommendations = await this.scrapeCard($);
|
|
265
|
+
|
|
266
|
+
const hasSub: boolean =
|
|
267
|
+
$('div#anime-cover-sub-content > div.nav-container > ul#episode-list > li.nav-item').length > 0;
|
|
268
|
+
const hasDub: boolean =
|
|
269
|
+
$('div#anime-cover-dub-content > div.nav-container > ul#episode-list > li.nav-item').length > 0;
|
|
270
|
+
|
|
271
|
+
if (hasSub) {
|
|
272
|
+
info.subOrDub = SubOrSub.SUB;
|
|
273
|
+
info.hasSub = hasSub;
|
|
274
|
+
}
|
|
275
|
+
if (hasDub) {
|
|
276
|
+
info.subOrDub = SubOrSub.DUB;
|
|
277
|
+
info.hasDub = hasDub;
|
|
278
|
+
}
|
|
279
|
+
if (hasSub && hasDub) {
|
|
280
|
+
info.subOrDub = SubOrSub.BOTH;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
info.genres = [];
|
|
284
|
+
$('div.genre')
|
|
285
|
+
.find('a')
|
|
286
|
+
.each(function () {
|
|
287
|
+
const genre = $(this).text().trim();
|
|
288
|
+
if (genre != undefined) info.genres?.push(genre);
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
switch ($('div.status > span').text().trim()) {
|
|
292
|
+
case 'Finished Airing':
|
|
293
|
+
info.status = MediaStatus.COMPLETED;
|
|
294
|
+
break;
|
|
295
|
+
case 'Currently Airing':
|
|
296
|
+
info.status = MediaStatus.ONGOING;
|
|
297
|
+
break;
|
|
298
|
+
case 'Not yet aired':
|
|
299
|
+
info.status = MediaStatus.NOT_YET_AIRED;
|
|
300
|
+
break;
|
|
301
|
+
default:
|
|
302
|
+
info.status = MediaStatus.UNKNOWN;
|
|
303
|
+
break;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
info.season = $('div.premiered')
|
|
307
|
+
.text()
|
|
308
|
+
.replace(/\s*\n\s*/g, ' ')
|
|
309
|
+
.replace('Premiered: ', '')
|
|
310
|
+
.trim();
|
|
311
|
+
let totalSubEpisodes = parseInt(
|
|
312
|
+
$('div#anime-cover-sub-content > div.nav-container > ul#episode-list > li.nav-item')
|
|
313
|
+
.last()
|
|
314
|
+
.text()
|
|
315
|
+
.split('-')[1]!
|
|
316
|
+
.trim()
|
|
317
|
+
);
|
|
318
|
+
let totalDubEpisodes = parseInt(
|
|
319
|
+
$('div#anime-cover-dub-content > div.nav-container > ul#episode-list > li.nav-item')
|
|
320
|
+
.last()
|
|
321
|
+
.text()
|
|
322
|
+
.split('-')[1]
|
|
323
|
+
?.trim() ?? '0'
|
|
324
|
+
);
|
|
325
|
+
info.totalEpisodes = totalSubEpisodes > totalDubEpisodes ? totalSubEpisodes : totalDubEpisodes;
|
|
326
|
+
info.episodes = [];
|
|
327
|
+
|
|
328
|
+
const subEpisodes = this.parseEpisodes($, '#anime-cover-sub-content .episode-node', SubOrSub.SUB);
|
|
329
|
+
const dubEpisodes = this.parseEpisodes($, '#anime-cover-dub-content .episode-node', SubOrSub.DUB);
|
|
330
|
+
|
|
331
|
+
const groupedMap = new Map<string, IAnimeEpisode>();
|
|
332
|
+
|
|
333
|
+
//passing the anime id with episode id for get request in fetchEpisodeServers
|
|
334
|
+
for (const sub of subEpisodes) {
|
|
335
|
+
groupedMap.set(sub.title!, {
|
|
336
|
+
id: `${id.split('$')[0]}$${sub.id!}`,
|
|
337
|
+
title: sub.title!,
|
|
338
|
+
number: sub.number!,
|
|
339
|
+
url: sub.url,
|
|
340
|
+
isSubbed: true,
|
|
341
|
+
isDubbed: false,
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
for (const dub of dubEpisodes) {
|
|
346
|
+
if (groupedMap.has(dub.title!)) {
|
|
347
|
+
const entry = groupedMap.get(dub.title!)!;
|
|
348
|
+
entry.id = `${entry.id}&${dub.id}`; //combining the sub and dub episode ids
|
|
349
|
+
entry.isDubbed = true;
|
|
350
|
+
} else {
|
|
351
|
+
groupedMap.set(dub.title!, {
|
|
352
|
+
id: `${id.split('$')[0]}$${dub.id!}`,
|
|
353
|
+
title: dub.title!,
|
|
354
|
+
number: dub.number!,
|
|
355
|
+
url: dub.url,
|
|
356
|
+
isSubbed: false,
|
|
357
|
+
isDubbed: true,
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
info.episodes = Array.from(groupedMap.values());
|
|
363
|
+
|
|
364
|
+
return info;
|
|
365
|
+
} catch (err) {
|
|
366
|
+
throw new Error((err as Error).message);
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
*
|
|
372
|
+
* @param episodeId Episode id
|
|
373
|
+
* @param server server type (default `VidCloud`) (optional)
|
|
374
|
+
* @param subOrDub sub or dub (default `SubOrSub.SUB`) (optional)
|
|
375
|
+
*/
|
|
376
|
+
override fetchEpisodeSources = async (
|
|
377
|
+
episodeId: string,
|
|
378
|
+
server: StreamingServers = StreamingServers.Luffy,
|
|
379
|
+
subOrDub: SubOrSub = SubOrSub.SUB
|
|
380
|
+
): Promise<ISource> => {
|
|
381
|
+
if (episodeId.startsWith('http')) {
|
|
382
|
+
const serverUrl = new URL(episodeId);
|
|
383
|
+
|
|
384
|
+
switch (server) {
|
|
385
|
+
case StreamingServers.Luffy:
|
|
386
|
+
return {
|
|
387
|
+
headers: { Referer: serverUrl.href },
|
|
388
|
+
sources: await new Luffy().extract(serverUrl),
|
|
389
|
+
};
|
|
390
|
+
default:
|
|
391
|
+
return {
|
|
392
|
+
headers: { Referer: serverUrl.href },
|
|
393
|
+
sources: await new Luffy().extract(serverUrl),
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
try {
|
|
399
|
+
const servers = await this.fetchEpisodeServers(episodeId, subOrDub);
|
|
400
|
+
const i = servers.findIndex((s) => s.name.toLowerCase() === server.toLowerCase());
|
|
401
|
+
|
|
402
|
+
if (i === -1) {
|
|
403
|
+
throw new Error(`Server ${server} not found`);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
const serverUrl: URL = new URL(servers[i]!.url);
|
|
407
|
+
const sources = await this.fetchEpisodeSources(serverUrl.href, server, subOrDub);
|
|
408
|
+
return sources;
|
|
409
|
+
} catch (err) {
|
|
410
|
+
throw err;
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* @param url string
|
|
416
|
+
*/
|
|
417
|
+
private scrapeCardPage = async (url: string, headers?: object): Promise<ISearch<IAnimeResult>> => {
|
|
418
|
+
try {
|
|
419
|
+
const res: ISearch<IAnimeResult> = {
|
|
420
|
+
currentPage: 0,
|
|
421
|
+
hasNextPage: false,
|
|
422
|
+
totalPages: 0,
|
|
423
|
+
results: [],
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
const { data } = await this.client.get(url, headers);
|
|
427
|
+
const $ = load(data);
|
|
428
|
+
|
|
429
|
+
const pagination = $('ul.pagination');
|
|
430
|
+
res.currentPage = parseInt(pagination.find('li.page-item.active')?.text()) || 1;
|
|
431
|
+
const nextPage = pagination.find('li:has(a[aria-label="Next page"])');
|
|
432
|
+
res.hasNextPage = !nextPage.hasClass('disabled');
|
|
433
|
+
let lastPageText = 0;
|
|
434
|
+
pagination.find('li.page-item a').each((_, el) => {
|
|
435
|
+
const text = parseInt($(el).text().trim());
|
|
436
|
+
if (!isNaN(text)) {
|
|
437
|
+
lastPageText = Math.max(lastPageText, text);
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
res.totalPages = lastPageText || res.currentPage;
|
|
441
|
+
|
|
442
|
+
res.results = await this.scrapeCard($);
|
|
443
|
+
if (res.results.length === 0) {
|
|
444
|
+
res.currentPage = 0;
|
|
445
|
+
res.hasNextPage = false;
|
|
446
|
+
res.totalPages = 0;
|
|
447
|
+
}
|
|
448
|
+
return res;
|
|
449
|
+
} catch (err) {
|
|
450
|
+
throw new Error('Something went wrong. Please try again later.');
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* @param $ cheerio instance
|
|
456
|
+
*/
|
|
457
|
+
private scrapeCard = async ($: CheerioAPI): Promise<IAnimeResult[]> => {
|
|
458
|
+
try {
|
|
459
|
+
const results: IAnimeResult[] = [];
|
|
460
|
+
|
|
461
|
+
$('#anime-list .recent-anime.anime-vertical').each((i, ele) => {
|
|
462
|
+
const card = $(ele);
|
|
463
|
+
const atag = card.find('a.post-thumb');
|
|
464
|
+
const id = atag.attr('href')?.split(`${this.baseUrl}/anime/`)[1];
|
|
465
|
+
const type = card.find('.anime-type span').text().trim();
|
|
466
|
+
results.push({
|
|
467
|
+
id: id!,
|
|
468
|
+
title: card.find('img')?.attr('alt')!,
|
|
469
|
+
url: `${atag.attr('href')}`,
|
|
470
|
+
image: card.find('img')?.attr('data-src') || card.find('img')?.attr('src'),
|
|
471
|
+
type: type as MediaFormat,
|
|
472
|
+
sub: parseInt(card.find('.misc-info .anime-duration span')?.eq(0).text()) || 0,
|
|
473
|
+
dub: parseInt(card.find('.misc-info .anime-duration span')?.eq(1).text()) || 0,
|
|
474
|
+
episodes: parseInt(card.find('.misc-info .anime-duration span')?.eq(0).text()) || 0,
|
|
475
|
+
});
|
|
476
|
+
});
|
|
477
|
+
return results;
|
|
478
|
+
} catch (err) {
|
|
479
|
+
throw new Error('Something went wrong. Please try again later.');
|
|
480
|
+
}
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* @param episodeId Episode id
|
|
485
|
+
* @param subOrDub sub or dub (default `sub`) (optional)
|
|
486
|
+
*/
|
|
487
|
+
override fetchEpisodeServers = async (
|
|
488
|
+
episodeId: string,
|
|
489
|
+
subOrDub: SubOrSub = SubOrSub.SUB
|
|
490
|
+
): Promise<IEpisodeServer[]> => {
|
|
491
|
+
const subEpisodeId = episodeId.split('$')[1]!.split('&')[0];
|
|
492
|
+
const dubEpisodeId = episodeId.split('&')[1];
|
|
493
|
+
const id = episodeId.split('$')[0];
|
|
494
|
+
const { data } = await this.client.get(`${this.baseUrl}/anime/${id}`);
|
|
495
|
+
const $ = load(data);
|
|
496
|
+
const subEpisode = this.parseEpisodes($, '#anime-cover-sub-content .episode-node', SubOrSub.SUB).filter(
|
|
497
|
+
(item) => item.id === subEpisodeId
|
|
498
|
+
);
|
|
499
|
+
const dubEpisode = this.parseEpisodes($, '#anime-cover-dub-content .episode-node', SubOrSub.DUB).filter(
|
|
500
|
+
(item) => item.id === dubEpisodeId
|
|
501
|
+
);
|
|
502
|
+
|
|
503
|
+
let directLink: string | undefined = '';
|
|
504
|
+
|
|
505
|
+
if (subOrDub === SubOrSub.SUB) {
|
|
506
|
+
const { data: intermediary } = await this.client.get(subEpisode[0]!.url!);
|
|
507
|
+
const $ = load(intermediary);
|
|
508
|
+
directLink = $('button#hot-anime-tab')?.attr('data-source');
|
|
509
|
+
}
|
|
510
|
+
if (subOrDub === SubOrSub.DUB) {
|
|
511
|
+
const { data: intermediary } = await this.client.get(dubEpisode[0]!.url!);
|
|
512
|
+
const $ = load(intermediary);
|
|
513
|
+
directLink = $('button#hot-anime-tab')?.attr('data-source');
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
const { data: server } = await this.client.get(`${this.baseUrl}${directLink}`);
|
|
517
|
+
const servers: IEpisodeServer[] = [];
|
|
518
|
+
server['luffy']?.map((item: any) => {
|
|
519
|
+
servers.push({
|
|
520
|
+
name: 'luffy',
|
|
521
|
+
url: `${this.baseUrl}${directLink!}`,
|
|
522
|
+
});
|
|
523
|
+
});
|
|
524
|
+
|
|
525
|
+
return servers;
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
private parseEpisodes = ($: any, selector: string, subOrDub: SubOrSub): IAnimeEpisode[] => {
|
|
529
|
+
return $(selector)
|
|
530
|
+
.map((idx: number, el: CheerioAPI) => {
|
|
531
|
+
const $el = $(el);
|
|
532
|
+
const title = $el.attr('title') ?? '';
|
|
533
|
+
const id = $el.attr('id') ?? '';
|
|
534
|
+
const url = $el.attr('href')?.startsWith('http') ? $el.attr('href')! : $el.prop('href');
|
|
535
|
+
const episodeNumber = Number(title);
|
|
536
|
+
|
|
537
|
+
// Skip if the episode number is a float
|
|
538
|
+
if (!Number.isInteger(episodeNumber)) {
|
|
539
|
+
return null;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
return {
|
|
543
|
+
id: id,
|
|
544
|
+
number: parseInt(title),
|
|
545
|
+
title: `Ep-${title}`,
|
|
546
|
+
url: url || '',
|
|
547
|
+
isSubbed: subOrDub === SubOrSub.SUB,
|
|
548
|
+
isDubbed: subOrDub === SubOrSub.DUB,
|
|
549
|
+
};
|
|
550
|
+
})
|
|
551
|
+
.get()
|
|
552
|
+
.filter(Boolean);
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
(async () => {
|
|
557
|
+
const animeowl = new AnimeOwl();
|
|
558
|
+
const search = await animeowl.fetchSpotlight();
|
|
559
|
+
const info = await animeowl.fetchAnimeInfo(search.results[0]!.id);
|
|
560
|
+
// const sources = await animeowl.fetchEpisodeSources(info.episodes![0].id,StreamingServers.Luffy, SubOrSub.DUB);
|
|
561
|
+
// console.log(info);
|
|
562
|
+
})();
|
|
563
|
+
|
|
564
|
+
export default AnimeOwl;
|
|
@@ -11,6 +11,7 @@ import AnimeUnity from './animeunity';
|
|
|
11
11
|
import MonosChinos from './monoschinos';
|
|
12
12
|
import Anix from './anix';
|
|
13
13
|
import AnimeKai from './animekai';
|
|
14
|
+
import AnimeOwl from './animeowl';
|
|
14
15
|
|
|
15
16
|
export default {
|
|
16
17
|
Gogoanime,
|
|
@@ -26,4 +27,5 @@ export default {
|
|
|
26
27
|
MonosChinos,
|
|
27
28
|
Anix,
|
|
28
29
|
AnimeKai,
|
|
30
|
+
AnimeOwl,
|
|
29
31
|
};
|
|
@@ -21,7 +21,7 @@ import axios from 'axios';
|
|
|
21
21
|
|
|
22
22
|
class Zoro extends AnimeParser {
|
|
23
23
|
override readonly name = 'Zoro';
|
|
24
|
-
protected override baseUrl = 'https://hianime.
|
|
24
|
+
protected override baseUrl = 'https://hianime.to';
|
|
25
25
|
protected override logo =
|
|
26
26
|
'https://is3-ssl.mzstatic.com/image/thumb/Purple112/v4/7e/91/00/7e9100ee-2b62-0942-4cdc-e9b93252ce1c/source/512x512bb.jpg';
|
|
27
27
|
protected override classPath = 'ANIME.Zoro';
|
|
@@ -677,7 +677,6 @@ class Zoro extends AnimeParser {
|
|
|
677
677
|
if (episodeId.startsWith('http')) {
|
|
678
678
|
const serverUrl = new URL(episodeId);
|
|
679
679
|
switch (server) {
|
|
680
|
-
case StreamingServers.VidStreaming:
|
|
681
680
|
case StreamingServers.VidCloud:
|
|
682
681
|
return {
|
|
683
682
|
headers: { Referer: serverUrl.href },
|
|
@@ -1222,11 +1222,11 @@ class Anilist extends AnimeParser {
|
|
|
1222
1222
|
});
|
|
1223
1223
|
}
|
|
1224
1224
|
|
|
1225
|
-
console.log({
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
});
|
|
1225
|
+
// console.log({
|
|
1226
|
+
// normalizedEpisodes,
|
|
1227
|
+
// providerEpisodes,
|
|
1228
|
+
// merged: mergeEpisodes(normalizedEpisodes, providerEpisodes),
|
|
1229
|
+
// });
|
|
1230
1230
|
possibleAnimeEpisodes = mergeEpisodes(normalizedEpisodes, providerEpisodes);
|
|
1231
1231
|
if (!possibleAnimeEpisodes.length) {
|
|
1232
1232
|
possibleAnimeEpisodes = await this.fetchDefaultEpisodeList(Media);
|
package/src/utils/index.ts
CHANGED