diff --git a/app/api/anilist/anilistMedias.ts b/app/api/anilist/anilistMedias.ts index f8f264e7..559f8650 100644 --- a/app/api/anilist/anilistMedias.ts +++ b/app/api/anilist/anilistMedias.ts @@ -39,7 +39,7 @@ function filterMediasWithAdultContent( // HANDLES SERVER ERRORS, most of time when server was not running due to be using the Free Tier axiosRetry(Axios, { retries: 3, - retryDelay: (retryAttempt) => retryAttempt * 1200, + retryDelay: (retryAttempt) => retryAttempt * 250, retryCondition: (error) => error.response?.status == 500 || error.response?.status == 404 || diff --git a/app/api/consumet/consumetImdb.ts b/app/api/consumet/consumetImdb.ts index 2471bc89..716b1ca7 100644 --- a/app/api/consumet/consumetImdb.ts +++ b/app/api/consumet/consumetImdb.ts @@ -4,12 +4,16 @@ import Axios from "axios"; import axiosRetry from "axios-retry"; import { cache } from "react"; -const CONSUMET_API_URL = process.env.NEXT_PUBLIC_CONSUMET_API_URL; + +// ATTENTION +// PROBLEMS WITH VERCEL FREE TIER LIMIT +// const CONSUMET_API_URL = process.env.NEXT_PUBLIC_CONSUMET_API_URL; +const CONSUMET_API_URL = "process.env.NEXT_PUBLIC_CONSUMET_API_URL"; // its really made to go wrong this one // HANDLES SERVER ERRORS, most of time when server was not running due to Free Tier usage axiosRetry(Axios, { retries: 1, - retryDelay: (retryAttempt) => retryAttempt * 1000, + retryDelay: (retryAttempt) => retryAttempt * 250, retryCondition: (error) => error.response?.status == 500 || error.response?.status == 503, onRetry: (retryNumber) => @@ -19,7 +23,7 @@ axiosRetry(Axios, { }); // SEARCH BY MEDIA TITLE -export const searchMedia = cache( +export const searchMediaOnIMDB = cache( async ({ mediaTitle }: { mediaTitle: string }) => { try { const { data } = await Axios({ @@ -37,7 +41,7 @@ export const searchMedia = cache( ); // GET INFO FOR THIS MEDIA -export const getMediaInfo = cache( +export const getMediaInfoOnIMDB = cache( async ({ search, mediaId, @@ -56,7 +60,7 @@ export const getMediaInfo = cache( let mediaSearchedType: string | null = null; if (search && seachTitle) { - const searchResults: ImdbSearchItem[] = await searchMedia({ + const searchResults: ImdbSearchItem[] = await searchMediaOnIMDB({ mediaTitle: stringToOnlyAlphabetic(seachTitle), }).then((res) => res.results); diff --git a/app/media/[id]/page.tsx b/app/media/[id]/page.tsx index 42b00efd..eb11107f 100644 --- a/app/media/[id]/page.tsx +++ b/app/media/[id]/page.tsx @@ -11,7 +11,7 @@ import ScoreRating from "@/app/components/DynamicAssets/ScoreRating"; import { headers } from "next/headers"; import { checkDeviceIsMobile } from "@/app/lib/checkMobileOrDesktop"; import { convertFromUnix, getMediaReleaseDate } from "@/app/lib/formatDateUnix"; -import { getMediaInfo } from "@/app/api/consumet/consumetImdb"; +import { getMediaInfoOnIMDB } from "@/app/api/consumet/consumetImdb"; import { ImdbEpisode, ImdbMediaInfo } from "@/app/ts/interfaces/imdb"; import MediaRelatedContainer from "./components/MediaRelatedContainer"; import CommentsSection from "../../components/CommentsSection"; @@ -48,7 +48,7 @@ export default async function MediaPage({ })) as MediaDataFullInfo; // GET MEDIA INFO ON IMDB - const imdbMediaInfo = (await getMediaInfo({ + const imdbMediaInfo = (await getMediaInfoOnIMDB({ search: true, seachTitle: mediaInfo.title.romaji, releaseYear: mediaInfo.startDate.year, diff --git a/app/watch/[id]/page.tsx b/app/watch/[id]/page.tsx index 32894c07..feed0a19 100644 --- a/app/watch/[id]/page.tsx +++ b/app/watch/[id]/page.tsx @@ -24,7 +24,7 @@ import { optimizedFetchOnGoGoAnime, } from "@/app/lib/dataFetch/optimizedFetchAnimeOptions"; import { ImdbEpisode, ImdbMediaInfo } from "@/app/ts/interfaces/imdb"; -import { getMediaInfo } from "@/app/api/consumet/consumetImdb"; +import { getMediaInfoOnIMDB } from "@/app/api/consumet/consumetImdb"; import { SourceType } from "@/app/ts/interfaces/episodesSource"; import { FetchEpisodeError } from "@/app/components/MediaFetchErrorPage"; import { cookies } from "next/headers"; @@ -130,7 +130,7 @@ export default async function WatchEpisode({ const imdbEpisodesList: ImdbEpisode[] = []; const loadImdbMediaAndEpisodeInfo = async () => { - const imdbMediaInfo: ImdbMediaInfo = (await getMediaInfo({ + const imdbMediaInfo: ImdbMediaInfo = (await getMediaInfoOnIMDB({ search: true, seachTitle: mediaInfo.title.english || mediaInfo.title.romaji, releaseYear: mediaInfo.startDate.year,