Skip to content

Commit 1639e5d

Browse files
committed
Update: Enhanced app functionalities (#196)
1 parent 49c166b commit 1639e5d

File tree

2 files changed

+40
-11
lines changed

2 files changed

+40
-11
lines changed

MovieVerse-Mobile/www/MovieVerse-Frontend/js/movie-details.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,12 @@ async function fetchMovieRatings(imdbId, tmdbMovieData) {
720720
await getMovieCode2(),
721721
'58efe859',
722722
'60a09d79',
723-
'956e468a'
723+
'956e468a',
724+
'bd55ada4',
725+
'cbfc076',
726+
'dc091ff2',
727+
'6e367eef',
728+
'2a2a3080'
724729
];
725730

726731
const baseURL = `https://${getMovieActor()}/?i=${imdbId}&${getMovieName()}`;

MovieVerse-Mobile/www/MovieVerse-Frontend/js/tv-details.js

+34-10
Original file line numberDiff line numberDiff line change
@@ -570,19 +570,43 @@ async function fetchTvDetails(tvSeriesId) {
570570
}
571571

572572
async function fetchTVRatings(imdbId) {
573-
const fff = `60a09d79`;
574-
const link = `https://${getMovieActor()}/?i=${imdbId}&${getMovieName()}${fff}`;
573+
const baseURL = `https://${getMovieActor()}/?i=${imdbId}&${getMovieName()}`;
574+
575+
async function tryFetch(apiKey) {
576+
const url = `${baseURL}${apiKey}`;
577+
try {
578+
const response = await fetch(url);
579+
if (!response.ok) throw new Error('API limit reached or other error');
580+
const data = await response.json();
581+
if (!data || data.Error) throw new Error('Data fetch error');
582+
return data;
583+
}
584+
catch (error) {
585+
console.log(`Fetching error with API Key ${apiKey}: ${error.message}`);
586+
return null;
587+
}
588+
}
575589

576-
try {
577-
const response = await fetch(link);
578-
const data = await response.json();
590+
const apiKeys = [
591+
await getMovieCode2(),
592+
'58efe859',
593+
'60a09d79',
594+
'956e468a',
595+
'bd55ada4',
596+
'cbfc076',
597+
'dc091ff2',
598+
'6e367eef',
599+
'2a2a3080'
600+
];
579601

580-
return imdbRating = data.imdbRating ? data.imdbRating : 'IMDb data unavailable but you can check it out by clicking here';
581-
}
582-
catch (error) {
583-
console.log('Error fetching TV series ratings:', error);
584-
return 'N/A';
602+
for (const key of apiKeys) {
603+
const data = await tryFetch(key);
604+
if (data) {
605+
return data.imdbRating ? data.imdbRating : 'IMDb data unavailable but you can check it out by clicking here';
606+
}
585607
}
608+
609+
return 'IMDb data unavailable but you can check it out by clicking here';
586610
}
587611

588612
function getLanguageName(code) {

0 commit comments

Comments
 (0)