diff options
| author | real-zephex <[email protected]> | 2024-05-26 22:29:35 +0530 |
|---|---|---|
| committer | real-zephex <[email protected]> | 2024-05-26 22:29:35 +0530 |
| commit | 3da8e6263d1900571cc8565b19d1b383dfbbf631 (patch) | |
| tree | c9aefb831b91e9f8c531d246be2cd88cd0af669a /src/app/kdrama/components/cacher.js | |
| parent | 🚀 feat(download): add download feature for movies (diff) | |
| download | dramalama-3da8e6263d1900571cc8565b19d1b383dfbbf631.tar.xz dramalama-3da8e6263d1900571cc8565b19d1b383dfbbf631.zip | |
⚡️ perf(kdrama, anime): cache video links, replace next/image
Diffstat (limited to 'src/app/kdrama/components/cacher.js')
| -rw-r--r-- | src/app/kdrama/components/cacher.js | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/app/kdrama/components/cacher.js b/src/app/kdrama/components/cacher.js index fdfa272..476ed95 100644 --- a/src/app/kdrama/components/cacher.js +++ b/src/app/kdrama/components/cacher.js @@ -1,10 +1,14 @@ "use server";
+import { drama_info_url } from "../../../../utils/kdrama_urls";
+import { videoLink } from "./requests";
+
export async function PreFetchKdramaInfo(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 fetch(drama_info_url(element.id), {
+ next: { revalidate: 21600 },
+ });
});
await Promise.all(fetchPromises);
@@ -13,3 +17,16 @@ export async function PreFetchKdramaInfo(data) { console.error("Error occurred while pre-fetching video links:", error);
}
}
+
+export const PreFetchVideoLinks = async (data, mediaID) => {
+ try {
+ const fetchPromise = data.map(async (element) => {
+ await videoLink(element.id, mediaID);
+ });
+
+ await Promise.all(fetchPromise);
+ console.log("Kdrama video links pre fetched successfully");
+ } catch (error) {
+ console.error("Error occured while fetching video links");
+ }
+};
|