File tree 2 files changed +40
-11
lines changed
MovieVerse-Mobile/www/MovieVerse-Frontend/js
2 files changed +40
-11
lines changed Original file line number Diff line number Diff line change @@ -720,7 +720,12 @@ async function fetchMovieRatings(imdbId, tmdbMovieData) {
720
720
await getMovieCode2 ( ) ,
721
721
'58efe859' ,
722
722
'60a09d79' ,
723
- '956e468a'
723
+ '956e468a' ,
724
+ 'bd55ada4' ,
725
+ 'cbfc076' ,
726
+ 'dc091ff2' ,
727
+ '6e367eef' ,
728
+ '2a2a3080'
724
729
] ;
725
730
726
731
const baseURL = `https://${ getMovieActor ( ) } /?i=${ imdbId } &${ getMovieName ( ) } ` ;
Original file line number Diff line number Diff line change @@ -570,19 +570,43 @@ async function fetchTvDetails(tvSeriesId) {
570
570
}
571
571
572
572
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
+ }
575
589
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
+ ] ;
579
601
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
+ }
585
607
}
608
+
609
+ return 'IMDb data unavailable but you can check it out by clicking here' ;
586
610
}
587
611
588
612
function getLanguageName ( code ) {
You can’t perform that action at this time.
0 commit comments