react-native-consumet 1.0.0-rc.0 → 1.0.0-rc.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/generated/java/com/consumet/NativeConsumetSpec.java +4 -0
- package/android/generated/jni/RNConsumetSpec-generated.cpp +6 -0
- package/android/generated/jni/react/renderer/components/RNConsumetSpec/RNConsumetSpecJSI-generated.cpp +8 -0
- package/android/generated/jni/react/renderer/components/RNConsumetSpec/RNConsumetSpecJSI.h +9 -0
- package/android/src/main/java/com/consumet/ConsumetModule.kt +7 -0
- package/android/src/main/java/com/consumet/DdosGuardModule.kt +248 -189
- package/ios/generated/RNConsumetSpec/RNConsumetSpec-generated.mm +7 -0
- package/ios/generated/RNConsumetSpec/RNConsumetSpec.h +2 -0
- package/ios/generated/RNConsumetSpecJSI-generated.cpp +8 -0
- package/ios/generated/RNConsumetSpecJSI.h +9 -0
- package/lib/commonjs/NativeConsumet.ts +28 -26
- package/lib/commonjs/extension-registry.json +13 -13
- package/lib/commonjs/extractors/filemoon.js +2 -2
- package/lib/commonjs/extractors/kwik.js +60 -15
- package/lib/commonjs/extractors/kwik.js.map +1 -1
- package/lib/commonjs/extractors/megacloud.js +6 -6
- package/lib/commonjs/index.js +2 -11
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/types.js +4 -4
- package/lib/commonjs/models/video-extractor.js +4 -4
- package/lib/commonjs/providers/anime/animedrive.js +12 -12
- package/lib/commonjs/providers/anime/animekai.js +41 -41
- package/lib/commonjs/providers/anime/animepahe/animepahe.js +16 -15
- package/lib/commonjs/providers/anime/animepahe/animepahe.js.map +1 -1
- package/lib/commonjs/providers/anime/animepahe/create-animepahe.js +12 -9
- package/lib/commonjs/providers/anime/animepahe/create-animepahe.js.map +1 -1
- package/lib/commonjs/providers/anime/animesuge/animesuge.js +78 -0
- package/lib/commonjs/providers/anime/animesuge/animesuge.js.map +1 -0
- package/lib/commonjs/providers/anime/animesuge/create-animesuge.js +312 -0
- package/lib/commonjs/providers/anime/animesuge/create-animesuge.js.map +1 -0
- package/lib/commonjs/providers/anime/animeunity.js +13 -13
- package/lib/commonjs/providers/anime/index.js +4 -4
- package/lib/commonjs/providers/anime/index.js.map +1 -1
- package/lib/commonjs/providers/anime/marin.js +12 -12
- package/lib/commonjs/providers/anime/zoro/create-zoro.js +2 -2
- package/lib/commonjs/providers/anime/zoro/create-zoro.js.map +1 -1
- package/lib/commonjs/providers/anime/zoro/zoro.js +76 -74
- package/lib/commonjs/providers/anime/zoro/zoro.js.map +1 -1
- package/lib/commonjs/providers/manga/brmangas.js +3 -3
- package/lib/commonjs/providers/meta/anilist.js +91 -91
- package/lib/commonjs/providers/meta/mal.js +12 -12
- package/lib/commonjs/providers/meta/tmdb.js +21 -21
- package/lib/commonjs/providers/movies/himovies/create-himovies.js +16 -16
- package/lib/commonjs/providers/movies/himovies/himovies.js +16 -16
- package/lib/commonjs/providers/movies/multimovies.js +15 -15
- package/lib/commonjs/providers/movies/multistream/index.js +21 -20
- package/lib/commonjs/providers/movies/multistream/index.js.map +1 -1
- package/lib/commonjs/providers/movies/multistream/utils.js +142 -130
- package/lib/commonjs/providers/movies/multistream/utils.js.map +1 -1
- package/lib/commonjs/utils/ExtractorManager.js +15 -15
- package/lib/commonjs/utils/ExtractorManager.js.map +1 -1
- package/lib/commonjs/utils/ProviderManager.js +2 -1
- package/lib/commonjs/utils/ProviderManager.js.map +1 -1
- package/lib/commonjs/utils/create-extractor-context.js +9 -1
- package/lib/commonjs/utils/create-extractor-context.js.map +1 -1
- package/lib/commonjs/utils/create-provider-context.js +6 -2
- package/lib/commonjs/utils/create-provider-context.js.map +1 -1
- package/lib/commonjs/utils/extension-utils.js +44 -54
- package/lib/commonjs/utils/extension-utils.js.map +1 -1
- package/lib/commonjs/utils/index.js +2 -2
- package/lib/commonjs/utils/provider-maps.js +31 -0
- package/lib/commonjs/utils/provider-maps.js.map +1 -0
- package/lib/commonjs/utils/providers-list.js +4 -4
- package/lib/commonjs/utils/url-polyfill.js +4 -4
- package/lib/module/NativeConsumet.ts +28 -26
- package/lib/module/extension-registry.json +13 -13
- package/lib/module/extractors/filemoon.js +2 -2
- package/lib/module/extractors/kwik.js +60 -15
- package/lib/module/extractors/kwik.js.map +1 -1
- package/lib/module/extractors/megacloud.js +6 -6
- package/lib/module/index.js +3 -7
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/types.js +4 -4
- package/lib/module/models/video-extractor.js +4 -4
- package/lib/module/providers/anime/animedrive.js +12 -12
- package/lib/module/providers/anime/animekai.js +41 -41
- package/lib/module/providers/anime/animepahe/animepahe.js +14 -14
- package/lib/module/providers/anime/animepahe/animepahe.js.map +1 -1
- package/lib/module/providers/anime/animepahe/create-animepahe.js +13 -9
- package/lib/module/providers/anime/animepahe/create-animepahe.js.map +1 -1
- package/lib/module/providers/anime/animesuge/animesuge.js +73 -0
- package/lib/module/providers/anime/animesuge/animesuge.js.map +1 -0
- package/lib/module/providers/anime/animesuge/create-animesuge.js +309 -0
- package/lib/module/providers/anime/animesuge/create-animesuge.js.map +1 -0
- package/lib/module/providers/anime/animeunity.js +13 -13
- package/lib/module/providers/anime/index.js +2 -2
- package/lib/module/providers/anime/index.js.map +1 -1
- package/lib/module/providers/anime/marin.js +12 -12
- package/lib/module/providers/anime/zoro/create-zoro.js +3 -2
- package/lib/module/providers/anime/zoro/create-zoro.js.map +1 -1
- package/lib/module/providers/anime/zoro/zoro.js +74 -73
- package/lib/module/providers/anime/zoro/zoro.js.map +1 -1
- package/lib/module/providers/manga/brmangas.js +3 -3
- package/lib/module/providers/meta/anilist.js +91 -91
- package/lib/module/providers/meta/mal.js +12 -12
- package/lib/module/providers/meta/tmdb.js +21 -21
- package/lib/module/providers/movies/himovies/create-himovies.js +16 -16
- package/lib/module/providers/movies/himovies/himovies.js +16 -16
- package/lib/module/providers/movies/multimovies.js +15 -15
- package/lib/module/providers/movies/multistream/index.js +21 -20
- package/lib/module/providers/movies/multistream/index.js.map +1 -1
- package/lib/module/providers/movies/multistream/utils.js +141 -129
- package/lib/module/providers/movies/multistream/utils.js.map +1 -1
- package/lib/module/utils/ExtractorManager.js +16 -16
- package/lib/module/utils/ExtractorManager.js.map +1 -1
- package/lib/module/utils/ProviderManager.js +2 -1
- package/lib/module/utils/ProviderManager.js.map +1 -1
- package/lib/module/utils/create-extractor-context.js +10 -1
- package/lib/module/utils/create-extractor-context.js.map +1 -1
- package/lib/module/utils/create-provider-context.js +8 -4
- package/lib/module/utils/create-provider-context.js.map +1 -1
- package/lib/module/utils/extension-utils.js +23 -33
- package/lib/module/utils/extension-utils.js.map +1 -1
- package/lib/module/utils/index.js +1 -1
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/provider-maps.js +27 -0
- package/lib/module/utils/provider-maps.js.map +1 -0
- package/lib/module/utils/providers-list.js +4 -4
- package/lib/module/utils/url-polyfill.js +4 -4
- package/lib/typescript/commonjs/src/NativeConsumet.d.ts +2 -0
- package/lib/typescript/commonjs/src/NativeConsumet.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/extractors/kwik.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +6 -6
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/models/extractor-context.d.ts +8 -0
- package/lib/typescript/commonjs/src/models/extractor-context.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/models/index.d.ts +2 -2
- package/lib/typescript/commonjs/src/models/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/models/provider-context.d.ts +6 -2
- package/lib/typescript/commonjs/src/models/provider-context.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/providers/anime/animepahe/animepahe.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/providers/anime/animepahe/create-animepahe.d.ts +1 -1
- package/lib/typescript/commonjs/src/providers/anime/animepahe/create-animepahe.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/providers/anime/animesuge/animesuge.d.ts +34 -0
- package/lib/typescript/commonjs/src/providers/anime/animesuge/animesuge.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/providers/anime/animesuge/create-animesuge.d.ts +14 -0
- package/lib/typescript/commonjs/src/providers/anime/animesuge/create-animesuge.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/providers/anime/index.d.ts +2 -2
- package/lib/typescript/commonjs/src/providers/anime/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/providers/anime/zoro/create-zoro.d.ts +1 -1
- package/lib/typescript/commonjs/src/providers/anime/zoro/create-zoro.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/providers/anime/zoro/zoro.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/providers/movies/multistream/index.d.ts +1 -1
- package/lib/typescript/commonjs/src/providers/movies/multistream/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/providers/movies/multistream/utils.d.ts +2 -2
- package/lib/typescript/commonjs/src/providers/movies/multistream/utils.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/ProviderManager.d.ts +1 -1
- package/lib/typescript/commonjs/src/utils/ProviderManager.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/create-extractor-context.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/create-provider-context.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/extension-utils.d.ts +1 -20
- package/lib/typescript/commonjs/src/utils/extension-utils.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/index.d.ts +2 -1
- package/lib/typescript/commonjs/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/provider-maps.d.ts +27 -0
- package/lib/typescript/commonjs/src/utils/provider-maps.d.ts.map +1 -0
- package/lib/typescript/module/src/NativeConsumet.d.ts +2 -0
- package/lib/typescript/module/src/NativeConsumet.d.ts.map +1 -1
- package/lib/typescript/module/src/extractors/kwik.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +6 -6
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/models/extractor-context.d.ts +8 -0
- package/lib/typescript/module/src/models/extractor-context.d.ts.map +1 -1
- package/lib/typescript/module/src/models/index.d.ts +2 -2
- package/lib/typescript/module/src/models/index.d.ts.map +1 -1
- package/lib/typescript/module/src/models/provider-context.d.ts +6 -2
- package/lib/typescript/module/src/models/provider-context.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/anime/animepahe/animepahe.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/anime/animepahe/create-animepahe.d.ts +1 -1
- package/lib/typescript/module/src/providers/anime/animepahe/create-animepahe.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/anime/animesuge/animesuge.d.ts +34 -0
- package/lib/typescript/module/src/providers/anime/animesuge/animesuge.d.ts.map +1 -0
- package/lib/typescript/module/src/providers/anime/animesuge/create-animesuge.d.ts +14 -0
- package/lib/typescript/module/src/providers/anime/animesuge/create-animesuge.d.ts.map +1 -0
- package/lib/typescript/module/src/providers/anime/index.d.ts +2 -2
- package/lib/typescript/module/src/providers/anime/index.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/anime/zoro/create-zoro.d.ts +1 -1
- package/lib/typescript/module/src/providers/anime/zoro/create-zoro.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/anime/zoro/zoro.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/movies/multistream/index.d.ts +1 -1
- package/lib/typescript/module/src/providers/movies/multistream/index.d.ts.map +1 -1
- package/lib/typescript/module/src/providers/movies/multistream/utils.d.ts +2 -2
- package/lib/typescript/module/src/providers/movies/multistream/utils.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/ProviderManager.d.ts +1 -1
- package/lib/typescript/module/src/utils/ProviderManager.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/create-extractor-context.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/create-provider-context.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/extension-utils.d.ts +1 -20
- package/lib/typescript/module/src/utils/extension-utils.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/index.d.ts +2 -1
- package/lib/typescript/module/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/provider-maps.d.ts +27 -0
- package/lib/typescript/module/src/utils/provider-maps.d.ts.map +1 -0
- package/package.json +6 -2
- package/src/NativeConsumet.ts +2 -0
- package/src/extension-registry.json +81 -81
- package/src/extractors/StreamP2P.ts +60 -60
- package/src/extractors/filemoon.ts +58 -58
- package/src/extractors/index.ts +41 -41
- package/src/extractors/kwik.ts +113 -50
- package/src/extractors/megacloud.ts +163 -163
- package/src/extractors/mixdrop.ts +31 -31
- package/src/extractors/mp4upload.ts +31 -31
- package/src/extractors/streamhub.ts +58 -58
- package/src/extractors/streamwish.ts +120 -120
- package/src/extractors/vidhide.ts +59 -59
- package/src/index.tsx +176 -175
- package/src/models/extension-manifest.ts +77 -77
- package/src/models/extractor-context.ts +55 -41
- package/src/models/index.ts +107 -106
- package/src/models/provider-context.ts +192 -182
- package/src/models/types.ts +531 -531
- package/src/models/video-extractor.ts +48 -48
- package/src/providers/anime/animedrive.ts +245 -245
- package/src/providers/anime/animekai.ts +627 -627
- package/src/providers/anime/animepahe/animepahe.ts +76 -76
- package/src/providers/anime/animepahe/create-animepahe.ts +350 -348
- package/src/providers/anime/animesuge/animesuge.ts +77 -0
- package/src/providers/anime/animesuge/create-animesuge.ts +327 -0
- package/src/providers/anime/animeunity.ts +216 -216
- package/src/providers/anime/index.ts +21 -21
- package/src/providers/anime/marin.ts +319 -319
- package/src/providers/anime/zoro/create-zoro.ts +656 -655
- package/src/providers/anime/zoro/zoro.ts +198 -197
- package/src/providers/index.ts +7 -7
- package/src/providers/manga/brmangas.ts +144 -144
- package/src/providers/meta/anilist.ts +2108 -2108
- package/src/providers/meta/mal.ts +635 -635
- package/src/providers/meta/tmdb.ts +470 -470
- package/src/providers/movies/himovies/create-himovies.ts +529 -529
- package/src/providers/movies/himovies/himovies.ts +90 -90
- package/src/providers/movies/index.ts +15 -15
- package/src/providers/movies/multimovies.ts +495 -495
- package/src/providers/movies/multistream/index.ts +232 -231
- package/src/providers/movies/multistream/utils.ts +147 -270
- package/src/utils/ExtractorManager.ts +311 -311
- package/src/utils/ProviderManager.ts +423 -424
- package/src/utils/create-extractor-context.ts +36 -22
- package/src/utils/create-provider-context.ts +117 -107
- package/src/utils/extension-utils.ts +105 -114
- package/src/utils/index.ts +96 -95
- package/src/utils/provider-maps.ts +31 -0
- package/src/utils/providers-list.ts +27 -27
- package/src/utils/url-polyfill.ts +642 -642
- package/src/utils/utils.ts +374 -374
|
@@ -1,348 +1,350 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type SubOrDub,
|
|
3
|
-
type ISearch,
|
|
4
|
-
type IAnimeInfo,
|
|
5
|
-
type IAnimeResult,
|
|
6
|
-
type ISource,
|
|
7
|
-
type IEpisodeServer,
|
|
8
|
-
type StreamingServers,
|
|
9
|
-
type MediaFormat,
|
|
10
|
-
type ProviderContext,
|
|
11
|
-
type ProviderConfig,
|
|
12
|
-
type MediaStatus,
|
|
13
|
-
type IAnimeEpisode,
|
|
14
|
-
} from '../../../models';
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const { axios, load, extractors, enums, createCustomBaseUrl, PolyURL, NativeConsumet } = ctx;
|
|
18
|
-
const { Kwik } = extractors;
|
|
19
|
-
const { StreamingServers: StreamingServersEnum, SubOrDub: SubOrDubEnum, MediaStatus: MediaStatusEnum } = enums;
|
|
20
|
-
const { getDdosGuardCookiesWithWebView } = NativeConsumet;
|
|
21
|
-
// Provider configuration - use the standardized base URL creation
|
|
22
|
-
const baseUrl = createCustomBaseUrl('https://animepahe.
|
|
23
|
-
|
|
24
|
-
const config: ProviderConfig = {
|
|
25
|
-
name: '
|
|
26
|
-
languages: 'en',
|
|
27
|
-
classPath: 'ANIME.
|
|
28
|
-
logo: 'https://
|
|
29
|
-
baseUrl,
|
|
30
|
-
isNSFW: false,
|
|
31
|
-
isWorking: true,
|
|
32
|
-
isDubAvailableSeparately: true,
|
|
33
|
-
};
|
|
34
|
-
let ddgCookie:
|
|
35
|
-
| {
|
|
36
|
-
cookie: string;
|
|
37
|
-
}
|
|
38
|
-
| null
|
|
39
|
-
| string = null;
|
|
40
|
-
const initDdgCookie = async (): Promise<void> => {
|
|
41
|
-
try {
|
|
42
|
-
try {
|
|
43
|
-
ddgCookie = await getDdosGuardCookiesWithWebView(config.baseUrl);
|
|
44
|
-
// console.log('DDoS-Guard cookie obtained (WebView):', ddgCookie);
|
|
45
|
-
} catch (err) {
|
|
46
|
-
console.error('Failed to bypass DDoS-Guard with WebView:', err);
|
|
47
|
-
}
|
|
48
|
-
} catch (error) {
|
|
49
|
-
console.error('Failed to initialize DDoS-Guard cookie:', error);
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
function Headers(sessionId: string | false) {
|
|
54
|
-
const headers: Record<string, string> = {
|
|
55
|
-
'authority': 'animepahe.ru',
|
|
56
|
-
'accept': 'application/json, text/javascript, */*; q=0.01',
|
|
57
|
-
'sec-ch-ua': '"Not A(Brand";v="99", "Microsoft Edge";v="121", "Chromium";v="121"',
|
|
58
|
-
'sec-ch-ua-mobile': '?0',
|
|
59
|
-
'sec-ch-ua-platform': '"Windows"',
|
|
60
|
-
'sec-fetch-dest': 'empty',
|
|
61
|
-
'sec-fetch-mode': 'cors',
|
|
62
|
-
'sec-fetch-site': 'same-origin',
|
|
63
|
-
'x-requested-with': 'XMLHttpRequest',
|
|
64
|
-
'Referer': sessionId ? `${config.baseUrl}/anime/${sessionId}` : `${config.baseUrl}`,
|
|
65
|
-
'user-agent':
|
|
66
|
-
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36',
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
if (ddgCookie) {
|
|
70
|
-
headers.Cookie = typeof ddgCookie === 'object' && ddgCookie !== null ? ddgCookie.cookie : ddgCookie || '';
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return headers;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const fetchEpisodes = async (session: string, page: number): Promise<IAnimeEpisode[]> => {
|
|
77
|
-
const res = await axios.get(`${config.baseUrl}/api?m=release&id=${session}&sort=episode_asc&page=${page}`, {
|
|
78
|
-
headers: Headers(session),
|
|
79
|
-
});
|
|
80
|
-
const epData = res.data.data;
|
|
81
|
-
|
|
82
|
-
return [
|
|
83
|
-
...epData.map(
|
|
84
|
-
(item: any): IAnimeEpisode => ({
|
|
85
|
-
id: `${session}/${item.session}`,
|
|
86
|
-
number: item.episode,
|
|
87
|
-
title: item.title,
|
|
88
|
-
image: item.snapshot,
|
|
89
|
-
duration: item.duration,
|
|
90
|
-
isSubbed: item.audio === 'jpn' || item.audio === 'eng',
|
|
91
|
-
isDubbed: item.audio === 'eng',
|
|
92
|
-
releaseDate: item.created_at,
|
|
93
|
-
url: `${config.baseUrl}/play/${session}/${item.session}`,
|
|
94
|
-
})
|
|
95
|
-
),
|
|
96
|
-
] as IAnimeEpisode[];
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
const search = async (query: string, page: number = 1): Promise<ISearch<IAnimeResult>> => {
|
|
100
|
-
try {
|
|
101
|
-
if (!ddgCookie) {
|
|
102
|
-
await initDdgCookie();
|
|
103
|
-
}
|
|
104
|
-
const { data } = await axios.get(`${config.baseUrl}/api?m=search&q=${encodeURIComponent(query)}`, {
|
|
105
|
-
headers: Headers(false),
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
const res = {
|
|
109
|
-
results: data.data.map((item: any) => ({
|
|
110
|
-
id: item.session,
|
|
111
|
-
title: item.title,
|
|
112
|
-
image: item.poster,
|
|
113
|
-
rating: item.score,
|
|
114
|
-
releaseDate: item.year,
|
|
115
|
-
type: item.type,
|
|
116
|
-
})),
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
return res;
|
|
120
|
-
} catch (err) {
|
|
121
|
-
//console.log(err);
|
|
122
|
-
throw new Error((err as Error).message);
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
const fetchAnimeInfo = async (id: string, episodePage: number = -1): Promise<IAnimeInfo> => {
|
|
127
|
-
const animeInfo: IAnimeInfo = {
|
|
128
|
-
id: id,
|
|
129
|
-
title: '',
|
|
130
|
-
};
|
|
131
|
-
try {
|
|
132
|
-
if (!ddgCookie) {
|
|
133
|
-
await initDdgCookie();
|
|
134
|
-
}
|
|
135
|
-
const res = await fetch(`${config.baseUrl}/anime/${id}`, {
|
|
136
|
-
headers: Headers(id),
|
|
137
|
-
});
|
|
138
|
-
const data = await res.text();
|
|
139
|
-
const $ = load(data);
|
|
140
|
-
|
|
141
|
-
animeInfo.title = $('div.title-wrapper > h1 > span').first().text();
|
|
142
|
-
animeInfo.image = $('div.anime-poster a').attr('href');
|
|
143
|
-
animeInfo.cover = `https:${$('div.anime-cover').attr('data-src')}`;
|
|
144
|
-
animeInfo.description = $('div.anime-summary').text().trim();
|
|
145
|
-
animeInfo.genres = $('div.anime-genre ul li')
|
|
146
|
-
.map((i, el) => $(el).find('a').attr('title'))
|
|
147
|
-
.get();
|
|
148
|
-
animeInfo.hasSub = true;
|
|
149
|
-
|
|
150
|
-
switch ($('div.anime-info p:icontains("Status:") a').text().trim()) {
|
|
151
|
-
case 'Currently Airing':
|
|
152
|
-
animeInfo.status = MediaStatusEnum.ONGOING;
|
|
153
|
-
break;
|
|
154
|
-
case 'Finished Airing':
|
|
155
|
-
animeInfo.status = MediaStatusEnum.COMPLETED;
|
|
156
|
-
break;
|
|
157
|
-
default:
|
|
158
|
-
animeInfo.status = MediaStatusEnum.UNKNOWN;
|
|
159
|
-
}
|
|
160
|
-
animeInfo.type = $('div.anime-info > p:contains("Type:") > a').text().trim().toUpperCase() as MediaFormat;
|
|
161
|
-
animeInfo.releaseDate = $('div.anime-info > p:contains("Aired:")')
|
|
162
|
-
.text()
|
|
163
|
-
.split('to')[0]!
|
|
164
|
-
.replace('Aired:', '')
|
|
165
|
-
.trim();
|
|
166
|
-
animeInfo.studios = $('div.anime-info > p:contains("Studio:")').text().replace('Studio:', '').trim().split('\n');
|
|
167
|
-
animeInfo.totalEpisodes = parseInt($('div.anime-info > p:contains("Episodes:")').text().replace('Episodes:', ''));
|
|
168
|
-
animeInfo.recommendations = [];
|
|
169
|
-
$('div.anime-recommendation .col-sm-6').each((i, el) => {
|
|
170
|
-
animeInfo.recommendations?.push({
|
|
171
|
-
id: $(el).find('.col-2 > a').attr('href')?.split('/')[2]!,
|
|
172
|
-
title: $(el).find('.col-2 > a').attr('title')!,
|
|
173
|
-
image: $(el).find('.col-2 > a > img').attr('src') || $(el).find('.col-2 > a > img').attr('data-src'),
|
|
174
|
-
url: `${config.baseUrl}/anime/${$(el).find('.col-2 > a').attr('href')?.split('/')[2]}`,
|
|
175
|
-
releaseDate: $(el).find('div.col-9 > a').text().trim(),
|
|
176
|
-
status: $(el).find('div.col-9 > strong').text().trim() as MediaStatus,
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
animeInfo.relations = [];
|
|
181
|
-
$('div.anime-relation .col-sm-6').each((i, el) => {
|
|
182
|
-
animeInfo.relations?.push({
|
|
183
|
-
id: $(el).find('.col-2 > a').attr('href')?.split('/')[2]!,
|
|
184
|
-
title: $(el).find('.col-2 > a').attr('title')!,
|
|
185
|
-
image: $(el).find('.col-2 > a > img').attr('src') || $(el).find('.col-2 > a > img').attr('data-src'),
|
|
186
|
-
url: `${config.baseUrl}/anime/${$(el).find('.col-2 > a').attr('href')?.split('/')[2]}`,
|
|
187
|
-
releaseDate: $(el).find('div.col-9 > a').text().trim(),
|
|
188
|
-
status: $(el).find('div.col-9 > strong').text().trim() as MediaStatus,
|
|
189
|
-
relationType: $(el).find('h4 > span').text().trim(),
|
|
190
|
-
});
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
animeInfo.episodes = [];
|
|
194
|
-
if (episodePage < 0) {
|
|
195
|
-
const {
|
|
196
|
-
data: { last_page, data },
|
|
197
|
-
} = await axios.get(`${config.baseUrl}/api?m=release&id=${id}&sort=episode_asc&page=1`, {
|
|
198
|
-
headers: Headers(id),
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
animeInfo.episodePages = last_page;
|
|
202
|
-
|
|
203
|
-
animeInfo.episodes.push(
|
|
204
|
-
...data.map(
|
|
205
|
-
(item: any) =>
|
|
206
|
-
({
|
|
207
|
-
id: `${id}/${item.session}`,
|
|
208
|
-
number: item.episode,
|
|
209
|
-
title: item.title,
|
|
210
|
-
image: item.snapshot,
|
|
211
|
-
duration: item.duration,
|
|
212
|
-
isSubbed: item.audio === 'jpn' || item.audio === 'eng',
|
|
213
|
-
isDubbed: item.audio === 'eng',
|
|
214
|
-
releaseDate: item.created_at,
|
|
215
|
-
url: `${config.baseUrl}/play/${id}/${item.session}`,
|
|
216
|
-
}) as IAnimeEpisode
|
|
217
|
-
)
|
|
218
|
-
);
|
|
219
|
-
|
|
220
|
-
for (let i = 1; i < last_page; i++) {
|
|
221
|
-
animeInfo.episodes.push(...(await fetchEpisodes(id, i + 1)));
|
|
222
|
-
}
|
|
223
|
-
} else {
|
|
224
|
-
animeInfo.episodes.push(...(await fetchEpisodes(id, episodePage)));
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
return animeInfo;
|
|
228
|
-
} catch (err) {
|
|
229
|
-
throw new Error((err as Error).message);
|
|
230
|
-
}
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
const fetchEpisodeSources = async (
|
|
234
|
-
episodeId: string,
|
|
235
|
-
server: StreamingServers = StreamingServersEnum.Kwik,
|
|
236
|
-
subOrDub: SubOrDub = SubOrDubEnum.SUB
|
|
237
|
-
): Promise<ISource> => {
|
|
238
|
-
if (episodeId.startsWith('http')) {
|
|
239
|
-
const serverUrl = new PolyURL(episodeId);
|
|
240
|
-
switch (server) {
|
|
241
|
-
case StreamingServersEnum.Kwik:
|
|
242
|
-
return {
|
|
243
|
-
headers: { Referer: serverUrl.href },
|
|
244
|
-
...(await Kwik().extract(serverUrl)),
|
|
245
|
-
};
|
|
246
|
-
default:
|
|
247
|
-
return {
|
|
248
|
-
headers: { Referer: serverUrl.href },
|
|
249
|
-
...(await Kwik().extract(serverUrl)),
|
|
250
|
-
};
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
try {
|
|
254
|
-
if (!ddgCookie) {
|
|
255
|
-
await initDdgCookie();
|
|
256
|
-
}
|
|
257
|
-
const { data } = await axios.get(`${config.baseUrl}/play/${episodeId}`, {
|
|
258
|
-
headers: Headers(episodeId.split('/')[0]!),
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
const $ = load(data);
|
|
262
|
-
|
|
263
|
-
const downloads = $('div#pickDownload > a')
|
|
264
|
-
.map((i, el) => ({
|
|
265
|
-
url: $(el).attr('href')!,
|
|
266
|
-
quality: $(el).text(),
|
|
267
|
-
}))
|
|
268
|
-
.get();
|
|
269
|
-
|
|
270
|
-
const iSource: ISource = {
|
|
271
|
-
headers: {
|
|
272
|
-
Referer: 'https://kwik.si/',
|
|
273
|
-
},
|
|
274
|
-
sources: [],
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
iSource.download = downloads;
|
|
278
|
-
const servers = await fetchEpisodeServers(episodeId, subOrDub);
|
|
279
|
-
const i = servers.findIndex((s) => s.name.toLowerCase().includes(server));
|
|
280
|
-
if (i === -1) {
|
|
281
|
-
throw new Error(`Server ${server} not found`);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
const serverUrl: URL = new URL(servers[i]!.url);
|
|
285
|
-
return await fetchEpisodeSources(serverUrl.href, server, subOrDub);
|
|
286
|
-
} catch (err) {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
const
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
const
|
|
306
|
-
const
|
|
307
|
-
const
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
1
|
+
import {
|
|
2
|
+
type SubOrDub,
|
|
3
|
+
type ISearch,
|
|
4
|
+
type IAnimeInfo,
|
|
5
|
+
type IAnimeResult,
|
|
6
|
+
type ISource,
|
|
7
|
+
type IEpisodeServer,
|
|
8
|
+
type StreamingServers,
|
|
9
|
+
type MediaFormat,
|
|
10
|
+
type ProviderContext,
|
|
11
|
+
type ProviderConfig,
|
|
12
|
+
type MediaStatus,
|
|
13
|
+
type IAnimeEpisode,
|
|
14
|
+
} from '../../../models';
|
|
15
|
+
|
|
16
|
+
function createAnimePahe(ctx: ProviderContext, customBaseURL?: string) {
|
|
17
|
+
const { axios, load, extractors, enums, createCustomBaseUrl, PolyURL, NativeConsumet } = ctx;
|
|
18
|
+
const { Kwik } = extractors;
|
|
19
|
+
const { StreamingServers: StreamingServersEnum, SubOrDub: SubOrDubEnum, MediaStatus: MediaStatusEnum } = enums;
|
|
20
|
+
const { getDdosGuardCookiesWithWebView, multiply, bypassDdosGuard } = NativeConsumet;
|
|
21
|
+
// Provider configuration - use the standardized base URL creation
|
|
22
|
+
const baseUrl = createCustomBaseUrl('https://animepahe.si', customBaseURL);
|
|
23
|
+
|
|
24
|
+
const config: ProviderConfig = {
|
|
25
|
+
name: 'AnimePahe',
|
|
26
|
+
languages: 'en',
|
|
27
|
+
classPath: 'ANIME.AnimePahe',
|
|
28
|
+
logo: 'https://animepahe.si//web-app-manifest-512x512.png',
|
|
29
|
+
baseUrl,
|
|
30
|
+
isNSFW: false,
|
|
31
|
+
isWorking: true,
|
|
32
|
+
isDubAvailableSeparately: true,
|
|
33
|
+
};
|
|
34
|
+
let ddgCookie:
|
|
35
|
+
| {
|
|
36
|
+
cookie: string;
|
|
37
|
+
}
|
|
38
|
+
| null
|
|
39
|
+
| string = null;
|
|
40
|
+
const initDdgCookie = async (): Promise<void> => {
|
|
41
|
+
try {
|
|
42
|
+
try {
|
|
43
|
+
ddgCookie = await getDdosGuardCookiesWithWebView(config.baseUrl);
|
|
44
|
+
// console.log('DDoS-Guard cookie obtained (WebView):', ans,ddgCookie);
|
|
45
|
+
} catch (err) {
|
|
46
|
+
console.error('Failed to bypass DDoS-Guard with WebView:', err);
|
|
47
|
+
}
|
|
48
|
+
} catch (error) {
|
|
49
|
+
console.error('Failed to initialize DDoS-Guard cookie:', error);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
function Headers(sessionId: string | false) {
|
|
54
|
+
const headers: Record<string, string> = {
|
|
55
|
+
'authority': 'animepahe.ru',
|
|
56
|
+
'accept': 'application/json, text/javascript, */*; q=0.01',
|
|
57
|
+
'sec-ch-ua': '"Not A(Brand";v="99", "Microsoft Edge";v="121", "Chromium";v="121"',
|
|
58
|
+
'sec-ch-ua-mobile': '?0',
|
|
59
|
+
'sec-ch-ua-platform': '"Windows"',
|
|
60
|
+
'sec-fetch-dest': 'empty',
|
|
61
|
+
'sec-fetch-mode': 'cors',
|
|
62
|
+
'sec-fetch-site': 'same-origin',
|
|
63
|
+
'x-requested-with': 'XMLHttpRequest',
|
|
64
|
+
'Referer': sessionId ? `${config.baseUrl}/anime/${sessionId}` : `${config.baseUrl}`,
|
|
65
|
+
'user-agent':
|
|
66
|
+
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36',
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
if (ddgCookie) {
|
|
70
|
+
headers.Cookie = typeof ddgCookie === 'object' && ddgCookie !== null ? ddgCookie.cookie : ddgCookie || '';
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return headers;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const fetchEpisodes = async (session: string, page: number): Promise<IAnimeEpisode[]> => {
|
|
77
|
+
const res = await axios.get(`${config.baseUrl}/api?m=release&id=${session}&sort=episode_asc&page=${page}`, {
|
|
78
|
+
headers: Headers(session),
|
|
79
|
+
});
|
|
80
|
+
const epData = res.data.data;
|
|
81
|
+
|
|
82
|
+
return [
|
|
83
|
+
...epData.map(
|
|
84
|
+
(item: any): IAnimeEpisode => ({
|
|
85
|
+
id: `${session}/${item.session}`,
|
|
86
|
+
number: item.episode,
|
|
87
|
+
title: item.title,
|
|
88
|
+
image: item.snapshot,
|
|
89
|
+
duration: item.duration,
|
|
90
|
+
isSubbed: item.audio === 'jpn' || item.audio === 'eng',
|
|
91
|
+
isDubbed: item.audio === 'eng',
|
|
92
|
+
releaseDate: item.created_at,
|
|
93
|
+
url: `${config.baseUrl}/play/${session}/${item.session}`,
|
|
94
|
+
})
|
|
95
|
+
),
|
|
96
|
+
] as IAnimeEpisode[];
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const search = async (query: string, page: number = 1): Promise<ISearch<IAnimeResult>> => {
|
|
100
|
+
try {
|
|
101
|
+
if (!ddgCookie) {
|
|
102
|
+
await initDdgCookie();
|
|
103
|
+
}
|
|
104
|
+
const { data } = await axios.get(`${config.baseUrl}/api?m=search&q=${encodeURIComponent(query)}`, {
|
|
105
|
+
headers: Headers(false),
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const res = {
|
|
109
|
+
results: data.data.map((item: any) => ({
|
|
110
|
+
id: item.session,
|
|
111
|
+
title: item.title,
|
|
112
|
+
image: item.poster,
|
|
113
|
+
rating: item.score,
|
|
114
|
+
releaseDate: item.year,
|
|
115
|
+
type: item.type,
|
|
116
|
+
})),
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
return res;
|
|
120
|
+
} catch (err) {
|
|
121
|
+
//console.log(err);
|
|
122
|
+
throw new Error((err as Error).message);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const fetchAnimeInfo = async (id: string, episodePage: number = -1): Promise<IAnimeInfo> => {
|
|
127
|
+
const animeInfo: IAnimeInfo = {
|
|
128
|
+
id: id,
|
|
129
|
+
title: '',
|
|
130
|
+
};
|
|
131
|
+
try {
|
|
132
|
+
if (!ddgCookie) {
|
|
133
|
+
await initDdgCookie();
|
|
134
|
+
}
|
|
135
|
+
const res = await fetch(`${config.baseUrl}/anime/${id}`, {
|
|
136
|
+
headers: Headers(id),
|
|
137
|
+
});
|
|
138
|
+
const data = await res.text();
|
|
139
|
+
const $ = load(data);
|
|
140
|
+
|
|
141
|
+
animeInfo.title = $('div.title-wrapper > h1 > span').first().text();
|
|
142
|
+
animeInfo.image = $('div.anime-poster a').attr('href');
|
|
143
|
+
animeInfo.cover = `https:${$('div.anime-cover').attr('data-src')}`;
|
|
144
|
+
animeInfo.description = $('div.anime-summary').text().trim();
|
|
145
|
+
animeInfo.genres = $('div.anime-genre ul li')
|
|
146
|
+
.map((i, el) => $(el).find('a').attr('title'))
|
|
147
|
+
.get();
|
|
148
|
+
animeInfo.hasSub = true;
|
|
149
|
+
|
|
150
|
+
switch ($('div.anime-info p:icontains("Status:") a').text().trim()) {
|
|
151
|
+
case 'Currently Airing':
|
|
152
|
+
animeInfo.status = MediaStatusEnum.ONGOING;
|
|
153
|
+
break;
|
|
154
|
+
case 'Finished Airing':
|
|
155
|
+
animeInfo.status = MediaStatusEnum.COMPLETED;
|
|
156
|
+
break;
|
|
157
|
+
default:
|
|
158
|
+
animeInfo.status = MediaStatusEnum.UNKNOWN;
|
|
159
|
+
}
|
|
160
|
+
animeInfo.type = $('div.anime-info > p:contains("Type:") > a').text().trim().toUpperCase() as MediaFormat;
|
|
161
|
+
animeInfo.releaseDate = $('div.anime-info > p:contains("Aired:")')
|
|
162
|
+
.text()
|
|
163
|
+
.split('to')[0]!
|
|
164
|
+
.replace('Aired:', '')
|
|
165
|
+
.trim();
|
|
166
|
+
animeInfo.studios = $('div.anime-info > p:contains("Studio:")').text().replace('Studio:', '').trim().split('\n');
|
|
167
|
+
animeInfo.totalEpisodes = parseInt($('div.anime-info > p:contains("Episodes:")').text().replace('Episodes:', ''));
|
|
168
|
+
animeInfo.recommendations = [];
|
|
169
|
+
$('div.anime-recommendation .col-sm-6').each((i, el) => {
|
|
170
|
+
animeInfo.recommendations?.push({
|
|
171
|
+
id: $(el).find('.col-2 > a').attr('href')?.split('/')[2]!,
|
|
172
|
+
title: $(el).find('.col-2 > a').attr('title')!,
|
|
173
|
+
image: $(el).find('.col-2 > a > img').attr('src') || $(el).find('.col-2 > a > img').attr('data-src'),
|
|
174
|
+
url: `${config.baseUrl}/anime/${$(el).find('.col-2 > a').attr('href')?.split('/')[2]}`,
|
|
175
|
+
releaseDate: $(el).find('div.col-9 > a').text().trim(),
|
|
176
|
+
status: $(el).find('div.col-9 > strong').text().trim() as MediaStatus,
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
animeInfo.relations = [];
|
|
181
|
+
$('div.anime-relation .col-sm-6').each((i, el) => {
|
|
182
|
+
animeInfo.relations?.push({
|
|
183
|
+
id: $(el).find('.col-2 > a').attr('href')?.split('/')[2]!,
|
|
184
|
+
title: $(el).find('.col-2 > a').attr('title')!,
|
|
185
|
+
image: $(el).find('.col-2 > a > img').attr('src') || $(el).find('.col-2 > a > img').attr('data-src'),
|
|
186
|
+
url: `${config.baseUrl}/anime/${$(el).find('.col-2 > a').attr('href')?.split('/')[2]}`,
|
|
187
|
+
releaseDate: $(el).find('div.col-9 > a').text().trim(),
|
|
188
|
+
status: $(el).find('div.col-9 > strong').text().trim() as MediaStatus,
|
|
189
|
+
relationType: $(el).find('h4 > span').text().trim(),
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
animeInfo.episodes = [];
|
|
194
|
+
if (episodePage < 0) {
|
|
195
|
+
const {
|
|
196
|
+
data: { last_page, data },
|
|
197
|
+
} = await axios.get(`${config.baseUrl}/api?m=release&id=${id}&sort=episode_asc&page=1`, {
|
|
198
|
+
headers: Headers(id),
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
animeInfo.episodePages = last_page;
|
|
202
|
+
|
|
203
|
+
animeInfo.episodes.push(
|
|
204
|
+
...data.map(
|
|
205
|
+
(item: any) =>
|
|
206
|
+
({
|
|
207
|
+
id: `${id}/${item.session}`,
|
|
208
|
+
number: item.episode,
|
|
209
|
+
title: item.title,
|
|
210
|
+
image: item.snapshot,
|
|
211
|
+
duration: item.duration,
|
|
212
|
+
isSubbed: item.audio === 'jpn' || item.audio === 'eng',
|
|
213
|
+
isDubbed: item.audio === 'eng',
|
|
214
|
+
releaseDate: item.created_at,
|
|
215
|
+
url: `${config.baseUrl}/play/${id}/${item.session}`,
|
|
216
|
+
}) as IAnimeEpisode
|
|
217
|
+
)
|
|
218
|
+
);
|
|
219
|
+
|
|
220
|
+
for (let i = 1; i < last_page; i++) {
|
|
221
|
+
animeInfo.episodes.push(...(await fetchEpisodes(id, i + 1)));
|
|
222
|
+
}
|
|
223
|
+
} else {
|
|
224
|
+
animeInfo.episodes.push(...(await fetchEpisodes(id, episodePage)));
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return animeInfo;
|
|
228
|
+
} catch (err) {
|
|
229
|
+
throw new Error((err as Error).message);
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
const fetchEpisodeSources = async (
|
|
234
|
+
episodeId: string,
|
|
235
|
+
server: StreamingServers = StreamingServersEnum.Kwik,
|
|
236
|
+
subOrDub: SubOrDub = SubOrDubEnum.SUB
|
|
237
|
+
): Promise<ISource> => {
|
|
238
|
+
if (episodeId.startsWith('http')) {
|
|
239
|
+
const serverUrl = new PolyURL(episodeId);
|
|
240
|
+
switch (server) {
|
|
241
|
+
case StreamingServersEnum.Kwik:
|
|
242
|
+
return {
|
|
243
|
+
headers: { Referer: serverUrl.href },
|
|
244
|
+
...(await Kwik().extract(serverUrl, config.baseUrl)),
|
|
245
|
+
};
|
|
246
|
+
default:
|
|
247
|
+
return {
|
|
248
|
+
headers: { Referer: serverUrl.href },
|
|
249
|
+
...(await Kwik().extract(serverUrl, config.baseUrl)),
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
try {
|
|
254
|
+
if (!ddgCookie) {
|
|
255
|
+
await initDdgCookie();
|
|
256
|
+
}
|
|
257
|
+
const { data } = await axios.get(`${config.baseUrl}/play/${episodeId}`, {
|
|
258
|
+
headers: Headers(episodeId.split('/')[0]!),
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
const $ = load(data);
|
|
262
|
+
|
|
263
|
+
const downloads = $('div#pickDownload > a')
|
|
264
|
+
.map((i, el) => ({
|
|
265
|
+
url: $(el).attr('href')!,
|
|
266
|
+
quality: $(el).text(),
|
|
267
|
+
}))
|
|
268
|
+
.get();
|
|
269
|
+
|
|
270
|
+
const iSource: ISource = {
|
|
271
|
+
headers: {
|
|
272
|
+
Referer: 'https://kwik.si/',
|
|
273
|
+
},
|
|
274
|
+
sources: [],
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
iSource.download = downloads;
|
|
278
|
+
const servers = await fetchEpisodeServers(episodeId, subOrDub);
|
|
279
|
+
const i = servers.findIndex((s) => s.name.toLowerCase().includes(server));
|
|
280
|
+
if (i === -1) {
|
|
281
|
+
throw new Error(`Server ${server} not found`);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const serverUrl: URL = new URL(servers[i]!.url);
|
|
285
|
+
return await fetchEpisodeSources(serverUrl.href, server, subOrDub);
|
|
286
|
+
} catch (err) {
|
|
287
|
+
console.log(err);
|
|
288
|
+
throw new Error((err as Error).message);
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
const fetchEpisodeServers = async (episodeId: string, subOrDub: SubOrDub): Promise<IEpisodeServer[]> => {
|
|
293
|
+
try {
|
|
294
|
+
if (!ddgCookie) {
|
|
295
|
+
await initDdgCookie();
|
|
296
|
+
}
|
|
297
|
+
const { data } = await axios.get(`${config.baseUrl}/play/${episodeId}`, {
|
|
298
|
+
headers: Headers(episodeId.split('/')[0]!),
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
const $ = load(data);
|
|
302
|
+
const servers: IEpisodeServer[] = [];
|
|
303
|
+
|
|
304
|
+
$('div#resolutionMenu > button').each((i, el) => {
|
|
305
|
+
const audio = $(el).attr('data-audio');
|
|
306
|
+
const fansub = $(el).attr('data-fansub');
|
|
307
|
+
const src = $(el).attr('data-src');
|
|
308
|
+
const resolution = $(el).attr('data-resolution');
|
|
309
|
+
|
|
310
|
+
if ((subOrDub === SubOrDubEnum.DUB && audio === 'eng') || (subOrDub === SubOrDubEnum.SUB && audio !== 'eng')) {
|
|
311
|
+
servers.push({
|
|
312
|
+
url: src!,
|
|
313
|
+
name: `kwik-${fansub}-${resolution}`,
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
return servers;
|
|
319
|
+
} catch (err) {
|
|
320
|
+
console.log(err);
|
|
321
|
+
throw new Error((err as Error).message);
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
// Return the functional provider object
|
|
326
|
+
return {
|
|
327
|
+
// Configuration
|
|
328
|
+
name: config.name,
|
|
329
|
+
get baseUrl() {
|
|
330
|
+
return config.baseUrl;
|
|
331
|
+
},
|
|
332
|
+
set baseUrl(value: string) {
|
|
333
|
+
config.baseUrl = value.startsWith('http') ? value : `http://${value}`;
|
|
334
|
+
},
|
|
335
|
+
logo: config.logo,
|
|
336
|
+
classPath: config.classPath,
|
|
337
|
+
|
|
338
|
+
// Core methods, pass only the necessary methods, dont pass helpers or unused methods
|
|
339
|
+
search,
|
|
340
|
+
fetchAnimeInfo,
|
|
341
|
+
fetchEpisodeSources,
|
|
342
|
+
fetchEpisodeServers,
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// Type definition for the provider instance returned by createAnimePahe
|
|
347
|
+
export type AnimePaheProviderInstance = ReturnType<typeof createAnimePahe>;
|
|
348
|
+
|
|
349
|
+
// Default export for backward compatibility
|
|
350
|
+
export default createAnimePahe;
|