mirror of
https://github.com/movie-web/movie-web.git
synced 2025-09-13 18:13:24 +00:00
Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
f3dd80f42b | ||
|
cfc74dfa78 | ||
|
1a3144a872 | ||
|
ae81832037 | ||
|
3da8955607 | ||
|
9bd5f30f40 | ||
|
0a15bb2023 | ||
|
cfa3cfd072 | ||
|
5fbe5d1ff5 | ||
|
4712d8fc5d | ||
|
a9d80ddf24 |
@@ -278,7 +278,8 @@
|
|||||||
"loadingError": "Error loading season",
|
"loadingError": "Error loading season",
|
||||||
"loadingList": "Loading...",
|
"loadingList": "Loading...",
|
||||||
"loadingTitle": "Loading...",
|
"loadingTitle": "Loading...",
|
||||||
"unairedEpisodes": "One or more episodes in this season have been disabled because they haven't been aired yet."
|
"unairedEpisodes": "One or more episodes in this season have been disabled because they haven't been aired yet.",
|
||||||
|
"seasons": "Seasons"
|
||||||
},
|
},
|
||||||
"playback": {
|
"playback": {
|
||||||
"speedLabel": "Playback speed",
|
"speedLabel": "Playback speed",
|
||||||
|
@@ -153,6 +153,12 @@ const tmdbHeaders = {
|
|||||||
Authorization: `Bearer ${apiKey}`,
|
Authorization: `Bearer ${apiKey}`,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function abortOnTimeout(timeout: number): AbortSignal {
|
||||||
|
const controller = new AbortController();
|
||||||
|
setTimeout(() => controller.abort(), timeout);
|
||||||
|
return controller.signal;
|
||||||
|
}
|
||||||
|
|
||||||
async function get<T>(url: string, params?: object): Promise<T> {
|
async function get<T>(url: string, params?: object): Promise<T> {
|
||||||
if (!apiKey) throw new Error("TMDB API key not set");
|
if (!apiKey) throw new Error("TMDB API key not set");
|
||||||
try {
|
try {
|
||||||
@@ -162,7 +168,7 @@ async function get<T>(url: string, params?: object): Promise<T> {
|
|||||||
params: {
|
params: {
|
||||||
...params,
|
...params,
|
||||||
},
|
},
|
||||||
signal: AbortSignal.timeout(5000),
|
signal: abortOnTimeout(5000),
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return mwFetch<T>(encodeURI(url), {
|
return mwFetch<T>(encodeURI(url), {
|
||||||
@@ -171,7 +177,7 @@ async function get<T>(url: string, params?: object): Promise<T> {
|
|||||||
params: {
|
params: {
|
||||||
...params,
|
...params,
|
||||||
},
|
},
|
||||||
signal: AbortSignal.timeout(30000),
|
signal: abortOnTimeout(30000),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -25,7 +25,7 @@ export function EditButton(props: EditButtonProps) {
|
|||||||
>
|
>
|
||||||
<span ref={parent}>
|
<span ref={parent}>
|
||||||
{props.editing ? (
|
{props.editing ? (
|
||||||
<span className="mx-4 whitespace-nowrap">
|
<span className="mx-2 sm:mx-4 whitespace-nowrap">
|
||||||
{t("home.mediaList.stopEditing")}
|
{t("home.mediaList.stopEditing")}
|
||||||
</span>
|
</span>
|
||||||
) : (
|
) : (
|
||||||
|
@@ -212,9 +212,16 @@ function EpisodesView({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Menu.CardWithScrollable>
|
<Menu.CardWithScrollable>
|
||||||
<Menu.BackLink onClick={goBack}>
|
<Menu.BackLink
|
||||||
|
onClick={goBack}
|
||||||
|
rightSide={
|
||||||
|
<span>
|
||||||
{loadingState?.value?.season.title ||
|
{loadingState?.value?.season.title ||
|
||||||
t("player.menus.episodes.loadingTitle")}
|
t("player.menus.episodes.loadingTitle")}
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{t("player.menus.episodes.seasons")}
|
||||||
</Menu.BackLink>
|
</Menu.BackLink>
|
||||||
{content}
|
{content}
|
||||||
</Menu.CardWithScrollable>
|
</Menu.CardWithScrollable>
|
||||||
|
@@ -46,10 +46,14 @@ function Button(props: {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function useSeasons(mediaId: string, isLastEpisode: boolean = false) {
|
function useSeasons(
|
||||||
|
mediaId: string | undefined,
|
||||||
|
isLastEpisode: boolean = false,
|
||||||
|
) {
|
||||||
const state = useAsync(async () => {
|
const state = useAsync(async () => {
|
||||||
if (isLastEpisode) {
|
if (isLastEpisode) {
|
||||||
const data = await getMetaFromId(MWMediaType.SERIES, mediaId ?? "");
|
if (!mediaId) return null;
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
@@ -60,13 +64,14 @@ function useSeasons(mediaId: string, isLastEpisode: boolean = false) {
|
|||||||
|
|
||||||
function useNextSeasonEpisode(
|
function useNextSeasonEpisode(
|
||||||
nextSeason: MWSeasonMeta | undefined,
|
nextSeason: MWSeasonMeta | undefined,
|
||||||
mediaId: string,
|
mediaId: string | undefined,
|
||||||
) {
|
) {
|
||||||
const state = useAsync(async () => {
|
const state = useAsync(async () => {
|
||||||
if (nextSeason) {
|
if (nextSeason) {
|
||||||
|
if (!mediaId) return null;
|
||||||
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,18 +111,17 @@ 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);
|
||||||
|
|
||||||
const nextSeason = seasons.value?.find(
|
const nextSeason = seasons.value?.find(
|
||||||
(season) => season.number === (meta?.season?.number ?? 0) + 1,
|
(season) => season.number === (meta?.season?.number ?? 0) + 1,
|
||||||
);
|
);
|
||||||
|
|
||||||
const nextSeasonEpisode = useNextSeasonEpisode(
|
const nextSeasonEpisode = useNextSeasonEpisode(nextSeason, meta?.tmdbId);
|
||||||
nextSeason,
|
|
||||||
meta?.tmdbId ?? "",
|
|
||||||
);
|
|
||||||
|
|
||||||
let show = false;
|
let show = false;
|
||||||
const hasAutoplayed = useRef(false);
|
const hasAutoplayed = useRef(false);
|
||||||
|
Reference in New Issue
Block a user