1
0
Fork 0
mirror of https://github.com/sussy-code/smov.git synced 2024-12-29 16:07:40 +01:00

Fix inconsistent TMDB season naming

This commit is contained in:
James Hawkins 2022-01-02 09:49:21 +00:00
parent 8e7b2d38ea
commit b2c4b54893

View file

@ -56,7 +56,17 @@ async function findContent(searchTerm, type) {
}
async function getEpisodes(slug) {
const tmdbRes = await fetch(`${process.env.REACT_APP_CORS_PROXY_URL}https://www.themoviedb.org/tv/${slug}/seasons`).then(d => d.text());
let tmdbRes;
try {
tmdbRes = await fetch(`${process.env.REACT_APP_CORS_PROXY_URL}https://www.themoviedb.org/tv/${slug}/seasons`).then(d => d.text());
} catch (err) {
tmdbRes = await fetch(`${process.env.REACT_APP_CORS_PROXY_URL}https://www.themoviedb.org/tv/${slug.split('-')[0]}/seasons`).then(d => d.text());
if (tmdbRes)
slug = slug.split('-')[0];
}
const sNodes = Array.from(new DOMParser().parseFromString(tmdbRes, 'text/html').querySelectorAll('div.column_wrapper > div.flex > div'));
let seasons = [];