blob: 860cdca8845f866961d1d4455ea1ad9ae43a6e53 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
// This function pre-fetches all the video links for a drama in the background
"use server";
export async function PreFetchVideoLinks(data, dramaId) {
try {
const fetchPromises = data.map(async (element) => {
const link = `https://consumet-jade.vercel.app/movies/dramacool/watch?episodeId=${element.id}&mediaId=${dramaId}`;
await fetch(link, { cache: "force-cache" });
});
await Promise.all(fetchPromises);
console.log("Video links pre-fetched successfully!");
} catch (error) {
console.error("Error occurred while pre-fetching video links:", error);
}
}
export async function PreFetchAnimeInfo(data) {
try {
const fetchPromises = data.results.map(async (element) => {
const link = `https://consumet-jade.vercel.app/movies/dramacool/info?id=${element.id}`;
await fetch(link, { next: { revalidate: 21600 } });
});
await Promise.all(fetchPromises);
console.log("Drama info fetched successfully.");
} catch (error) {
console.error("Error occurred while pre-fetching video links:", error);
}
}
|