diff --git a/MovieVerse-Mobile/platforms/android/app/src/main/assets/www/MovieVerse-Frontend/js/movie-details.js b/MovieVerse-Mobile/platforms/android/app/src/main/assets/www/MovieVerse-Frontend/js/movie-details.js index 1769cbc2..f8fa8127 100644 --- a/MovieVerse-Mobile/platforms/android/app/src/main/assets/www/MovieVerse-Frontend/js/movie-details.js +++ b/MovieVerse-Mobile/platforms/android/app/src/main/assets/www/MovieVerse-Frontend/js/movie-details.js @@ -720,7 +720,12 @@ async function fetchMovieRatings(imdbId, tmdbMovieData) { await getMovieCode2(), '58efe859', '60a09d79', - '956e468a' + '956e468a', + 'bd55ada4', + 'cbfc076', + 'dc091ff2', + '6e367eef', + '2a2a3080' ]; const baseURL = `https://${getMovieActor()}/?i=${imdbId}&${getMovieName()}`; diff --git a/MovieVerse-Mobile/platforms/android/app/src/main/assets/www/MovieVerse-Frontend/js/tv-details.js b/MovieVerse-Mobile/platforms/android/app/src/main/assets/www/MovieVerse-Frontend/js/tv-details.js index ebadb344..34a6d37c 100644 --- a/MovieVerse-Mobile/platforms/android/app/src/main/assets/www/MovieVerse-Frontend/js/tv-details.js +++ b/MovieVerse-Mobile/platforms/android/app/src/main/assets/www/MovieVerse-Frontend/js/tv-details.js @@ -570,19 +570,43 @@ async function fetchTvDetails(tvSeriesId) { } async function fetchTVRatings(imdbId) { - const fff = `60a09d79`; - const link = `https://${getMovieActor()}/?i=${imdbId}&${getMovieName()}${fff}`; + const baseURL = `https://${getMovieActor()}/?i=${imdbId}&${getMovieName()}`; + + async function tryFetch(apiKey) { + const url = `${baseURL}${apiKey}`; + try { + const response = await fetch(url); + if (!response.ok) throw new Error('API limit reached or other error'); + const data = await response.json(); + if (!data || data.Error) throw new Error('Data fetch error'); + return data; + } + catch (error) { + console.log(`Fetching error with API Key ${apiKey}: ${error.message}`); + return null; + } + } - try { - const response = await fetch(link); - const data = await response.json(); + const apiKeys = [ + await getMovieCode2(), + '58efe859', + '60a09d79', + '956e468a', + 'bd55ada4', + 'cbfc076', + 'dc091ff2', + '6e367eef', + '2a2a3080' + ]; - return imdbRating = data.imdbRating ? data.imdbRating : 'IMDb data unavailable but you can check it out by clicking here'; - } - catch (error) { - console.log('Error fetching TV series ratings:', error); - return 'N/A'; + for (const key of apiKeys) { + const data = await tryFetch(key); + if (data) { + return data.imdbRating ? data.imdbRating : 'IMDb data unavailable but you can check it out by clicking here'; + } } + + return 'IMDb data unavailable but you can check it out by clicking here'; } function getLanguageName(code) { diff --git a/MovieVerse-Mobile/platforms/ios/www/MovieVerse-Frontend/js/movie-details.js b/MovieVerse-Mobile/platforms/ios/www/MovieVerse-Frontend/js/movie-details.js index 1769cbc2..f8fa8127 100644 --- a/MovieVerse-Mobile/platforms/ios/www/MovieVerse-Frontend/js/movie-details.js +++ b/MovieVerse-Mobile/platforms/ios/www/MovieVerse-Frontend/js/movie-details.js @@ -720,7 +720,12 @@ async function fetchMovieRatings(imdbId, tmdbMovieData) { await getMovieCode2(), '58efe859', '60a09d79', - '956e468a' + '956e468a', + 'bd55ada4', + 'cbfc076', + 'dc091ff2', + '6e367eef', + '2a2a3080' ]; const baseURL = `https://${getMovieActor()}/?i=${imdbId}&${getMovieName()}`; diff --git a/MovieVerse-Mobile/platforms/ios/www/MovieVerse-Frontend/js/tv-details.js b/MovieVerse-Mobile/platforms/ios/www/MovieVerse-Frontend/js/tv-details.js index ebadb344..34a6d37c 100644 --- a/MovieVerse-Mobile/platforms/ios/www/MovieVerse-Frontend/js/tv-details.js +++ b/MovieVerse-Mobile/platforms/ios/www/MovieVerse-Frontend/js/tv-details.js @@ -570,19 +570,43 @@ async function fetchTvDetails(tvSeriesId) { } async function fetchTVRatings(imdbId) { - const fff = `60a09d79`; - const link = `https://${getMovieActor()}/?i=${imdbId}&${getMovieName()}${fff}`; + const baseURL = `https://${getMovieActor()}/?i=${imdbId}&${getMovieName()}`; + + async function tryFetch(apiKey) { + const url = `${baseURL}${apiKey}`; + try { + const response = await fetch(url); + if (!response.ok) throw new Error('API limit reached or other error'); + const data = await response.json(); + if (!data || data.Error) throw new Error('Data fetch error'); + return data; + } + catch (error) { + console.log(`Fetching error with API Key ${apiKey}: ${error.message}`); + return null; + } + } - try { - const response = await fetch(link); - const data = await response.json(); + const apiKeys = [ + await getMovieCode2(), + '58efe859', + '60a09d79', + '956e468a', + 'bd55ada4', + 'cbfc076', + 'dc091ff2', + '6e367eef', + '2a2a3080' + ]; - return imdbRating = data.imdbRating ? data.imdbRating : 'IMDb data unavailable but you can check it out by clicking here'; - } - catch (error) { - console.log('Error fetching TV series ratings:', error); - return 'N/A'; + for (const key of apiKeys) { + const data = await tryFetch(key); + if (data) { + return data.imdbRating ? data.imdbRating : 'IMDb data unavailable but you can check it out by clicking here'; + } } + + return 'IMDb data unavailable but you can check it out by clicking here'; } function getLanguageName(code) {