Skip to content

Commit

Permalink
Update: Enhanced app functionalities (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangsonww committed May 25, 2024
1 parent 1639e5d commit 6e6d0ff
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 6e6d0ff

Please sign in to comment.