1
0
Fork 0
mirror of https://github.com/sussy-code/smov.git synced 2024-12-30 16:17:41 +01:00

fix tmdb 404 request

This commit is contained in:
Jorrin 2024-04-19 19:26:29 +02:00
parent 4712d8fc5d
commit 5fbe5d1ff5

View file

@ -49,7 +49,7 @@ function Button(props: {
function useSeasons(mediaId: string, isLastEpisode: boolean = false) { function useSeasons(mediaId: string, isLastEpisode: boolean = false) {
const state = useAsync(async () => { const state = useAsync(async () => {
if (isLastEpisode) { if (isLastEpisode) {
const data = await getMetaFromId(MWMediaType.SERIES, mediaId ?? ""); const data = await getMetaFromId(MWMediaType.SERIES, mediaId);
if (data?.meta.type !== MWMediaType.SERIES) return null; if (data?.meta.type !== MWMediaType.SERIES) return null;
return data.meta.seasons; return data.meta.seasons;
} }
@ -64,9 +64,10 @@ function useNextSeasonEpisode(
) { ) {
const state = useAsync(async () => { const state = useAsync(async () => {
if (nextSeason) { if (nextSeason) {
if (!mediaId) return;
const data = await getMetaFromId( const data = await getMetaFromId(
MWMediaType.SERIES, MWMediaType.SERIES,
mediaId ?? "", mediaId,
nextSeason?.id, nextSeason?.id,
); );
if (data?.meta.type !== MWMediaType.SERIES) return null; if (data?.meta.type !== MWMediaType.SERIES) return null;
@ -106,7 +107,9 @@ export function NextEpisodeButton(props: {
const enableAutoplay = usePreferencesStore((s) => s.enableAutoplay); const enableAutoplay = usePreferencesStore((s) => s.enableAutoplay);
const isLastEpisode = const isLastEpisode =
meta?.episode?.number === meta?.episodes?.at(-1)?.number; !meta?.episode?.number || !meta?.episodes?.at(-1)?.number
? false
: meta.episode.number === meta.episodes.at(-1)!.number;
const seasons = useSeasons(meta?.tmdbId ?? "", isLastEpisode); const seasons = useSeasons(meta?.tmdbId ?? "", isLastEpisode);