feat: add intro-skipper
This commit is contained in:
10 files changed
+166
-45
No files matched your search
@@ -59,6 +59,7 @@
|
|||||||
- Mediainfo recognition (DolbyVision, DolbyAtoms, Dts, Hdr10+, and more...)
|
- Mediainfo recognition (DolbyVision, DolbyAtoms, Dts, Hdr10+, and more...)
|
||||||
- Sort/Filter library items
|
- Sort/Filter library items
|
||||||
- Queue playback support
|
- Queue playback support
|
||||||
|
- Intro Skip button using [jumoog/Intro-Skipper](https://github.com/jumoog/intro-skipper) plugin
|
||||||
|
|
||||||
## 📷 Screenshots
|
## 📷 Screenshots
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ import type PlayResult from "@//utils/types/playResult";
|
|||||||
import { getRuntimeCompact } from "@/utils/date/time";
|
import { getRuntimeCompact } from "@/utils/date/time";
|
||||||
import getSubtitle from "@/utils/methods/getSubtitles";
|
import getSubtitle from "@/utils/methods/getSubtitles";
|
||||||
import playbackProfile from "@/utils/playback-profiles";
|
import playbackProfile from "@/utils/playback-profiles";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { axiosClient, useApiInContext } from "@/utils/store/api";
|
||||||
|
import type IntroMediaInfo from "@/utils/types/introMediaInfo";
|
||||||
import { getMediaInfoApi } from "@jellyfin/sdk/lib/utils/api/media-info-api";
|
import { getMediaInfoApi } from "@jellyfin/sdk/lib/utils/api/media-info-api";
|
||||||
import type { SxProps } from "@mui/material";
|
import type { SxProps } from "@mui/material";
|
||||||
import type { AxiosResponse } from "axios";
|
import type { AxiosResponse } from "axios";
|
||||||
@@ -95,6 +96,7 @@ const PlayButton = ({
|
|||||||
setPlaybackDataLoading(true);
|
setPlaybackDataLoading(true);
|
||||||
let result: undefined | AxiosResponse<BaseItemDtoQueryResult, any>;
|
let result: undefined | AxiosResponse<BaseItemDtoQueryResult, any>;
|
||||||
let mediaSource: undefined | AxiosResponse<PlaybackInfoResponse, any>;
|
let mediaSource: undefined | AxiosResponse<PlaybackInfoResponse, any>;
|
||||||
|
let introInfo: undefined | AxiosResponse<IntroMediaInfo, any>;
|
||||||
if (playlistItem) {
|
if (playlistItem) {
|
||||||
result = await getPlaylistsApi(api).getPlaylistItems({
|
result = await getPlaylistsApi(api).getPlaylistItems({
|
||||||
userId: userId,
|
userId: userId,
|
||||||
@@ -123,6 +125,20 @@ const PlayButton = ({
|
|||||||
DeviceProfile: playbackProfile,
|
DeviceProfile: playbackProfile,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
try {
|
||||||
|
introInfo = (
|
||||||
|
await axiosClient.get(
|
||||||
|
`${api.basePath}/Episode/${result.data.Items?.[0]?.Id}/IntroTimestamps`,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
Authorization: `MediaBrowser Token=${api.accessToken}`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
)?.data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case BaseItemKind.Series:
|
case BaseItemKind.Series:
|
||||||
result = await getTvShowsApi(api).getEpisodes({
|
result = await getTvShowsApi(api).getEpisodes({
|
||||||
@@ -144,6 +160,20 @@ const PlayButton = ({
|
|||||||
DeviceProfile: playbackProfile,
|
DeviceProfile: playbackProfile,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
try {
|
||||||
|
introInfo = (
|
||||||
|
await axiosClient.get(
|
||||||
|
`${api.basePath}/Episode/${result.data.Items?.[0]?.Id}/IntroTimestamps`,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
Authorization: `MediaBrowser Token=${api.accessToken}`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
)?.data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case BaseItemKind.Playlist:
|
case BaseItemKind.Playlist:
|
||||||
result = await getPlaylistsApi(api).getPlaylistItems({
|
result = await getPlaylistsApi(api).getPlaylistItems({
|
||||||
@@ -204,7 +234,7 @@ const PlayButton = ({
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { item: result?.data, mediaSource: mediaSource?.data };
|
return { item: result?.data, mediaSource: mediaSource?.data, introInfo };
|
||||||
},
|
},
|
||||||
onSuccess: (result: PlayResult | null) => {
|
onSuccess: (result: PlayResult | null) => {
|
||||||
if (trackIndex) {
|
if (trackIndex) {
|
||||||
@@ -255,7 +285,7 @@ const PlayButton = ({
|
|||||||
) {
|
) {
|
||||||
playbackUrl = `${api.basePath}${result.mediaSource.MediaSources[0].TranscodingUrl}`;
|
playbackUrl = `${api.basePath}${result.mediaSource.MediaSources[0].TranscodingUrl}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
playItem(
|
playItem(
|
||||||
itemName,
|
itemName,
|
||||||
episodeTitle,
|
episodeTitle,
|
||||||
@@ -272,6 +302,7 @@ const PlayButton = ({
|
|||||||
result?.mediaSource.MediaSources?.[0]?.Id,
|
result?.mediaSource.MediaSources?.[0]?.Id,
|
||||||
result?.mediaSource.PlaySessionId,
|
result?.mediaSource.PlaySessionId,
|
||||||
subtitle,
|
subtitle,
|
||||||
|
result?.introInfo,
|
||||||
);
|
);
|
||||||
navigate({ to: "/player" });
|
navigate({ to: "/player" });
|
||||||
}
|
}
|
||||||
@@ -374,7 +405,7 @@ const PlayButton = ({
|
|||||||
color="white"
|
color="white"
|
||||||
/>
|
/>
|
||||||
</Button>
|
</Button>
|
||||||
{itemUserData.PlaybackPositionTicks && (
|
{itemUserData.PlaybackPositionTicks > 0 && (
|
||||||
<Typography
|
<Typography
|
||||||
sx={{
|
sx={{
|
||||||
opacity: 0.8,
|
opacity: 0.8,
|
||||||
@@ -396,18 +427,3 @@ const PlayButton = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default PlayButton;
|
export default PlayButton;
|
||||||
|
|
||||||
PlayButton.propTypes = {
|
|
||||||
itemId: PropTypes.string,
|
|
||||||
itemUserData: PropTypes.object,
|
|
||||||
userId: PropTypes.string,
|
|
||||||
itemType: PropTypes.string,
|
|
||||||
currentAudioTrack: PropTypes.number,
|
|
||||||
currentSubTrack: PropTypes.number,
|
|
||||||
currentVideoTrack: PropTypes.number,
|
|
||||||
className: PropTypes.string,
|
|
||||||
sx: PropTypes.any,
|
|
||||||
iconProps: PropTypes.any,
|
|
||||||
buttonProps: PropTypes.any,
|
|
||||||
iconOnly: PropTypes.bool,
|
|
||||||
};
|
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
import { getSetting, setSetting } from "@/utils/storage/settings";
|
||||||
|
import { FormControlLabel, Switch, Typography } from "@mui/material";
|
||||||
|
import React, { useState } from "react";
|
||||||
|
|
||||||
|
const SettingOption = ({
|
||||||
|
setting,
|
||||||
|
}: { setting: { key: string; name: string; description: string } }) => {
|
||||||
|
const [settingVal, setSettingVal] = useState(
|
||||||
|
async () => (await getSetting(setting.key)) ?? false,
|
||||||
|
);
|
||||||
|
return (
|
||||||
|
<FormControlLabel
|
||||||
|
control={
|
||||||
|
<Switch
|
||||||
|
color="primary"
|
||||||
|
checked={settingVal}
|
||||||
|
onChange={(e) => {
|
||||||
|
setSetting(setting.key, e.target.checked);
|
||||||
|
setSettingVal(e.target.checked);
|
||||||
|
}}
|
||||||
|
name={setting.name}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label={
|
||||||
|
<div className="settings-option-info">
|
||||||
|
<Typography variant="subtitle1" fontWeight={400}>
|
||||||
|
{setting.name}
|
||||||
|
</Typography>
|
||||||
|
<Typography
|
||||||
|
variant="caption"
|
||||||
|
className="settings-option-info-caption"
|
||||||
|
>
|
||||||
|
{setting.description}
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
labelPlacement="start"
|
||||||
|
className="settings-option"
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SettingOption;
|
||||||
@@ -41,6 +41,7 @@ import {
|
|||||||
setDefaultServer,
|
setDefaultServer,
|
||||||
setServer,
|
setServer,
|
||||||
} from "@/utils/storage/servers";
|
} from "@/utils/storage/servers";
|
||||||
|
import { allSettings, getSetting, setSetting } from "@/utils/storage/settings";
|
||||||
import { delUser } from "@/utils/storage/user";
|
import { delUser } from "@/utils/storage/user";
|
||||||
import type { RecommendedServerInfo } from "@jellyfin/sdk";
|
import type { RecommendedServerInfo } from "@jellyfin/sdk";
|
||||||
import { LoadingButton } from "@mui/lab";
|
import { LoadingButton } from "@mui/lab";
|
||||||
@@ -49,6 +50,7 @@ import { useNavigate, useRouteContext } from "@tanstack/react-router";
|
|||||||
import { relaunch } from "@tauri-apps/plugin-process";
|
import { relaunch } from "@tauri-apps/plugin-process";
|
||||||
import { type Update, check } from "@tauri-apps/plugin-updater";
|
import { type Update, check } from "@tauri-apps/plugin-updater";
|
||||||
import { useSnackbar } from "notistack";
|
import { useSnackbar } from "notistack";
|
||||||
|
import SettingOption from "../settingOption";
|
||||||
|
|
||||||
const motionConfig = {
|
const motionConfig = {
|
||||||
initial: {
|
initial: {
|
||||||
@@ -261,27 +263,8 @@ const Settings = () => {
|
|||||||
{/* General */}
|
{/* General */}
|
||||||
{tabValue === 1 && (
|
{tabValue === 1 && (
|
||||||
<div className="settings-container">
|
<div className="settings-container">
|
||||||
{Array.from(new Array(10)).map((i) => (
|
{allSettings.general.map((setting) => (
|
||||||
<FormControlLabel
|
<SettingOption key={setting.key} setting={setting} />
|
||||||
key={i}
|
|
||||||
value="start"
|
|
||||||
control={<Switch color="primary" />}
|
|
||||||
label={
|
|
||||||
<div className="settings-option-info">
|
|
||||||
<Typography variant="subtitle1">
|
|
||||||
Some dummy setting
|
|
||||||
</Typography>
|
|
||||||
<Typography
|
|
||||||
variant="caption"
|
|
||||||
className="settings-option-info-caption"
|
|
||||||
>
|
|
||||||
this a test
|
|
||||||
</Typography>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
labelPlacement="start"
|
|
||||||
className="settings-option"
|
|
||||||
/>
|
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { WebviewWindow as appWindow } from "@tauri-apps/api/webviewWindow";
|
import { WebviewWindow as appWindow } from "@tauri-apps/api/webviewWindow";
|
||||||
import React, { type ChangeEventHandler } from "react";
|
import React, { MouseEventHandler, type ChangeEventHandler } from "react";
|
||||||
import { useLayoutEffect, useMemo } from "react";
|
import { useLayoutEffect, useMemo } from "react";
|
||||||
|
|
||||||
import CircularProgress from "@mui/material/CircularProgress";
|
import CircularProgress from "@mui/material/CircularProgress";
|
||||||
@@ -27,7 +27,7 @@ import { AnimatePresence, motion } from "framer-motion";
|
|||||||
|
|
||||||
import { setBackdrop } from "@/utils/store/backdrop";
|
import { setBackdrop } from "@/utils/store/backdrop";
|
||||||
|
|
||||||
import { TextField } from "@mui/material";
|
import { Button, TextField } from "@mui/material";
|
||||||
import JASSUB from "jassub";
|
import JASSUB from "jassub";
|
||||||
import workerUrl from "jassub/dist/jassub-worker.js?url";
|
import workerUrl from "jassub/dist/jassub-worker.js?url";
|
||||||
import wasmUrl from "jassub/dist/jassub-worker.wasm?url";
|
import wasmUrl from "jassub/dist/jassub-worker.wasm?url";
|
||||||
@@ -80,6 +80,7 @@ function VideoPlayer() {
|
|||||||
episodeTitle,
|
episodeTitle,
|
||||||
mediaSource,
|
mediaSource,
|
||||||
playsessionId,
|
playsessionId,
|
||||||
|
introInfo,
|
||||||
] = usePlaybackStore((state) => [
|
] = usePlaybackStore((state) => [
|
||||||
state.playbackStream,
|
state.playbackStream,
|
||||||
state.item,
|
state.item,
|
||||||
@@ -89,6 +90,7 @@ function VideoPlayer() {
|
|||||||
state.episodeTitle,
|
state.episodeTitle,
|
||||||
state.mediaSource,
|
state.mediaSource,
|
||||||
state.playsessionId,
|
state.playsessionId,
|
||||||
|
state.intro,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
@@ -277,6 +279,19 @@ function VideoPlayer() {
|
|||||||
}
|
}
|
||||||
}, [mediaSource.subtitle.track, player.current?.getInternalPlayer()]);
|
}, [mediaSource.subtitle.track, player.current?.getInternalPlayer()]);
|
||||||
|
|
||||||
|
const showSkipIntroButton = useMemo(() => {
|
||||||
|
if (
|
||||||
|
ticksToSec(progress) >= introInfo?.ShowSkipPromptAt &&
|
||||||
|
ticksToSec(progress) < introInfo?.HideSkipPromptAt
|
||||||
|
)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}, [progress]);
|
||||||
|
|
||||||
|
const handleSkipIntro = useCallback(() => {
|
||||||
|
player.current?.seekTo(introInfo?.IntroEnd);
|
||||||
|
}, [item?.Id]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="video-player">
|
<div className="video-player">
|
||||||
<AnimatePresence>
|
<AnimatePresence>
|
||||||
@@ -303,6 +318,22 @@ function VideoPlayer() {
|
|||||||
</motion.div>
|
</motion.div>
|
||||||
)}
|
)}
|
||||||
</AnimatePresence>
|
</AnimatePresence>
|
||||||
|
{showSkipIntroButton && (
|
||||||
|
<Button
|
||||||
|
variant="outlined"
|
||||||
|
size="large"
|
||||||
|
color="white"
|
||||||
|
style={{
|
||||||
|
position: "absolute",
|
||||||
|
bottom: "18vh",
|
||||||
|
right: "2em",
|
||||||
|
zIndex: 10000,
|
||||||
|
}}
|
||||||
|
onClick={handleSkipIntro}
|
||||||
|
>
|
||||||
|
Skip Intro
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
<motion.div
|
<motion.div
|
||||||
className={
|
className={
|
||||||
hoveringOsd || !playing || isSeeking
|
hoveringOsd || !playing || isSeeking
|
||||||
|
|||||||
@@ -1020,7 +1020,7 @@ function SeriesTitlePage() {
|
|||||||
<PlayButton
|
<PlayButton
|
||||||
item={episode}
|
item={episode}
|
||||||
itemId={episode.Id}
|
itemId={episode.Id}
|
||||||
itemType="Episode"
|
itemType={BaseItemKind.Episode}
|
||||||
itemUserData={episode.UserData}
|
itemUserData={episode.UserData}
|
||||||
userId={user.data.Id}
|
userId={user.data.Id}
|
||||||
currentAudioTrack={0}
|
currentAudioTrack={0}
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import { Store } from "@tauri-apps/plugin-store";
|
||||||
|
|
||||||
|
const SettingsStore = new Store(".settings.dat");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* settingKey should be of type:
|
||||||
|
* 'settingDomain.settingKeyName'
|
||||||
|
*/
|
||||||
|
|
||||||
|
export const setSetting = async (settingKey: string, value: boolean) => {
|
||||||
|
await SettingsStore.set(settingKey, value);
|
||||||
|
await SettingsStore.save();
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getSetting = async (settingKey: string) => {
|
||||||
|
const value = await SettingsStore.get(settingKey);
|
||||||
|
console.log(`${settingKey} - ${value}`);
|
||||||
|
if (value) return value;
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const allSettings = {
|
||||||
|
general: [
|
||||||
|
{
|
||||||
|
key: "general.enable_skip_intro_outro",
|
||||||
|
name: "Enable Intro-Skipper plugin",
|
||||||
|
description:
|
||||||
|
"Shows a skip button for Intros and End Credit scenes in an episode. Note: this requires jumoog/intro-skipper plugin to be installed on server",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
import type {
|
import type {
|
||||||
BaseItemDto,
|
BaseItemDto,
|
||||||
BaseItemKind,
|
|
||||||
MediaProtocol,
|
|
||||||
MediaStream,
|
MediaStream,
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { getMediaInfoApi } from "@jellyfin/sdk/lib/utils/api/media-info-api";
|
import { getMediaInfoApi } from "@jellyfin/sdk/lib/utils/api/media-info-api";
|
||||||
import { create } from "zustand";
|
import { create } from "zustand";
|
||||||
import playbackProfile from "../playback-profiles";
|
import playbackProfile from "../playback-profiles";
|
||||||
|
import type IntroMediaInfo from "../types/introMediaInfo";
|
||||||
import type subtitlePlaybackInfo from "../types/subtitlePlaybackInfo";
|
import type subtitlePlaybackInfo from "../types/subtitlePlaybackInfo";
|
||||||
import { useApiInContext } from "./api";
|
import { useApiInContext } from "./api";
|
||||||
import { playAudio } from "./audioPlayback";
|
import { playAudio } from "./audioPlayback";
|
||||||
@@ -28,6 +27,7 @@ type PlaybackStore = {
|
|||||||
itemDuration: number;
|
itemDuration: number;
|
||||||
item: BaseItemDto | null;
|
item: BaseItemDto | null;
|
||||||
playsessionId: string | undefined | null;
|
playsessionId: string | undefined | null;
|
||||||
|
intro: IntroMediaInfo | undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const usePlaybackStore = create<PlaybackStore>(() => ({
|
export const usePlaybackStore = create<PlaybackStore>(() => ({
|
||||||
@@ -53,6 +53,7 @@ export const usePlaybackStore = create<PlaybackStore>(() => ({
|
|||||||
itemDuration: 0,
|
itemDuration: 0,
|
||||||
item: null,
|
item: null,
|
||||||
playsessionId: "",
|
playsessionId: "",
|
||||||
|
intro: undefined,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const playItem = (
|
export const playItem = (
|
||||||
@@ -71,6 +72,7 @@ export const playItem = (
|
|||||||
mediaSourceId: string | undefined | null,
|
mediaSourceId: string | undefined | null,
|
||||||
playsessionId: string | undefined | null,
|
playsessionId: string | undefined | null,
|
||||||
subtitle: subtitlePlaybackInfo,
|
subtitle: subtitlePlaybackInfo,
|
||||||
|
intro: IntroMediaInfo | undefined,
|
||||||
) => {
|
) => {
|
||||||
console.log({
|
console.log({
|
||||||
itemName,
|
itemName,
|
||||||
@@ -88,6 +90,7 @@ export const playItem = (
|
|||||||
itemDuration,
|
itemDuration,
|
||||||
item,
|
item,
|
||||||
playsessionId,
|
playsessionId,
|
||||||
|
intro,
|
||||||
});
|
});
|
||||||
usePlaybackStore.setState({
|
usePlaybackStore.setState({
|
||||||
itemName,
|
itemName,
|
||||||
@@ -105,6 +108,7 @@ export const playItem = (
|
|||||||
itemDuration,
|
itemDuration,
|
||||||
item,
|
item,
|
||||||
playsessionId,
|
playsessionId,
|
||||||
|
intro,
|
||||||
});
|
});
|
||||||
setQueue(queue, queueItemIndex);
|
setQueue(queue, queueItemIndex);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
type IntroMediaInfo = {
|
||||||
|
EpisodeId: string;
|
||||||
|
Valid: true;
|
||||||
|
IntroStart: number;
|
||||||
|
IntroEnd: number;
|
||||||
|
ShowSkipPromptAt: number;
|
||||||
|
HideSkipPromptAt: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default IntroMediaInfo
|
||||||
@@ -2,10 +2,12 @@ import type {
|
|||||||
BaseItemDtoQueryResult,
|
BaseItemDtoQueryResult,
|
||||||
PlaybackInfoResponse,
|
PlaybackInfoResponse,
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import type IntroMediaInfo from "./introMediaInfo";
|
||||||
|
|
||||||
interface PlayResult {
|
interface PlayResult {
|
||||||
item: BaseItemDtoQueryResult;
|
item: BaseItemDtoQueryResult;
|
||||||
mediaSource: PlaybackInfoResponse;
|
mediaSource: PlaybackInfoResponse;
|
||||||
|
introInfo: IntroMediaInfo | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default PlayResult;
|
export default PlayResult;
|
||||||
Reference in new issue
Block a user