mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-01 12:44:45 -04:00
Replace episodes in history instead of pushing them
This commit is contained in:
parent
4fde5fb65f
commit
be499b3085
@ -26,14 +26,24 @@ import { alpha } from "./themes";
|
|||||||
|
|
||||||
export const A = ({
|
export const A = ({
|
||||||
href,
|
href,
|
||||||
|
replace,
|
||||||
children,
|
children,
|
||||||
...props
|
...props
|
||||||
}: TextProps & { href: string; children: ReactNode }) => {
|
}: TextProps & { href: string; replace?: boolean; children: ReactNode }) => {
|
||||||
const { css, theme } = useYoshiki();
|
const { css, theme } = useYoshiki();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TextLink
|
<TextLink
|
||||||
href={href}
|
href={href}
|
||||||
|
replace={replace as any}
|
||||||
|
experimental={
|
||||||
|
replace
|
||||||
|
? {
|
||||||
|
nativeBehavior: "stack-replace",
|
||||||
|
isNestedNavigator: false,
|
||||||
|
}
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
textProps={css(
|
textProps={css(
|
||||||
{
|
{
|
||||||
fontFamily: theme.font.normal,
|
fontFamily: theme.font.normal,
|
||||||
@ -72,11 +82,16 @@ export const PressableFeedback = forwardRef<View, PressableProps>(function _Feed
|
|||||||
|
|
||||||
export const Link = ({
|
export const Link = ({
|
||||||
href,
|
href,
|
||||||
|
replace,
|
||||||
target,
|
target,
|
||||||
children,
|
children,
|
||||||
...props
|
...props
|
||||||
}: { href: string; target?: string } & PressableProps) => {
|
}: { href: string; target?: string; replace?: boolean } & PressableProps) => {
|
||||||
const linkProps = useLink({ href });
|
const linkProps = useLink({
|
||||||
|
href,
|
||||||
|
replace,
|
||||||
|
experimental: { nativeBehavior: "stack-replace", isNestedNavigator: false },
|
||||||
|
});
|
||||||
// @ts-ignore Missing hrefAttrs type definition.
|
// @ts-ignore Missing hrefAttrs type definition.
|
||||||
linkProps.hrefAttrs = { ...linkProps.hrefAttrs, target };
|
linkProps.hrefAttrs = { ...linkProps.hrefAttrs, target };
|
||||||
return (
|
return (
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { LinearGradient } from "expo-linear-gradient";
|
import { LinearGradient } from "expo-linear-gradient";
|
||||||
import { useState } from "react";
|
|
||||||
import { View, ViewProps } from "react-native";
|
import { View, ViewProps } from "react-native";
|
||||||
import { px, rem, useYoshiki, percent, em } from "yoshiki/native";
|
import { px, rem, useYoshiki, percent, em } from "yoshiki/native";
|
||||||
import { hiddenIfNoJs } from "./utils/nojs";
|
import { hiddenIfNoJs } from "./utils/nojs";
|
||||||
@ -53,8 +52,6 @@ export const Skeleton = ({
|
|||||||
variant?: "text" | "header" | "round" | "custom" | "fill" | "filltext";
|
variant?: "text" | "header" | "round" | "custom" | "fill" | "filltext";
|
||||||
}) => {
|
}) => {
|
||||||
const { css, theme } = useYoshiki();
|
const { css, theme } = useYoshiki();
|
||||||
const [width, setWidth] = useState<number | undefined>(undefined);
|
|
||||||
const perc = (v: number) => (v / 100) * width!;
|
|
||||||
|
|
||||||
if (forcedShow === undefined && children && children !== true) return <>{children}</>;
|
if (forcedShow === undefined && children && children !== true) return <>{children}</>;
|
||||||
|
|
||||||
@ -101,7 +98,6 @@ export const Skeleton = ({
|
|||||||
[...Array(lines)].map((_, i) => (
|
[...Array(lines)].map((_, i) => (
|
||||||
<View
|
<View
|
||||||
key={`skeleton_${i}`}
|
key={`skeleton_${i}`}
|
||||||
onLayout={(e) => setWidth(e.nativeEvent.layout.width)}
|
|
||||||
{...css(
|
{...css(
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
@ -53,6 +53,7 @@ export const LeftButtons = ({
|
|||||||
icon={SkipPrevious}
|
icon={SkipPrevious}
|
||||||
as={Link}
|
as={Link}
|
||||||
href={previousSlug}
|
href={previousSlug}
|
||||||
|
replace
|
||||||
{...tooltip(t("player.previous"), true)}
|
{...tooltip(t("player.previous"), true)}
|
||||||
{...spacing}
|
{...spacing}
|
||||||
/>
|
/>
|
||||||
@ -68,6 +69,7 @@ export const LeftButtons = ({
|
|||||||
icon={SkipNext}
|
icon={SkipNext}
|
||||||
as={Link}
|
as={Link}
|
||||||
href={nextSlug}
|
href={nextSlug}
|
||||||
|
replace
|
||||||
{...tooltip(t("player.next"), true)}
|
{...tooltip(t("player.next"), true)}
|
||||||
{...spacing}
|
{...spacing}
|
||||||
/>
|
/>
|
||||||
|
@ -195,14 +195,20 @@ export const Player: QueryPage<{ slug: string }> = ({ slug }) => {
|
|||||||
>
|
>
|
||||||
<Video
|
<Video
|
||||||
links={data?.link}
|
links={data?.link}
|
||||||
|
subtitles={data?.subtitles}
|
||||||
setError={setPlaybackError}
|
setError={setPlaybackError}
|
||||||
fonts={data?.fonts}
|
fonts={data?.fonts}
|
||||||
onEnd={() => {
|
onEnd={() => {
|
||||||
if (!data) return;
|
if (!data) return;
|
||||||
if (data.isMovie) router.push(`/movie/${data.slug}`);
|
if (data.isMovie)
|
||||||
|
router.replace(`/movie/${data.slug}`, undefined, {
|
||||||
|
experimental: { nativeBehavior: "stack-replace", isNestedNavigator: false },
|
||||||
|
});
|
||||||
else
|
else
|
||||||
router.push(
|
router.replace(
|
||||||
data.nextEpisode ? `/watch/${data.nextEpisode.slug}` : `/show/${data.showSlug}`,
|
data.nextEpisode ? `/watch/${data.nextEpisode.slug}` : `/show/${data.showSlug}`,
|
||||||
|
undefined,
|
||||||
|
{ experimental: { nativeBehavior: "stack-replace", isNestedNavigator: false } },
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
{...css(StyleSheet.absoluteFillObject)}
|
{...css(StyleSheet.absoluteFillObject)}
|
||||||
|
@ -76,11 +76,13 @@ export const subtitleAtom = atom<Track | null>(null);
|
|||||||
|
|
||||||
export const Video = memo(function _Video({
|
export const Video = memo(function _Video({
|
||||||
links,
|
links,
|
||||||
|
subtitles,
|
||||||
setError,
|
setError,
|
||||||
fonts,
|
fonts,
|
||||||
...props
|
...props
|
||||||
}: {
|
}: {
|
||||||
links?: WatchItem["link"];
|
links?: WatchItem["link"];
|
||||||
|
subtitles?: WatchItem["subtitles"];
|
||||||
setError: (error: string | undefined) => void;
|
setError: (error: string | undefined) => void;
|
||||||
fonts?: Font[];
|
fonts?: Font[];
|
||||||
} & Partial<VideoProps>) {
|
} & Partial<VideoProps>) {
|
||||||
@ -149,6 +151,12 @@ export const Video = memo(function _Video({
|
|||||||
setDuration(info.duration);
|
setDuration(info.duration);
|
||||||
}}
|
}}
|
||||||
onPlayPause={setPlay}
|
onPlayPause={setPlay}
|
||||||
|
textTracks={subtitles?.map(x => ({
|
||||||
|
type: "text/x-ssa" as any, //MimeTypes[x.codec],
|
||||||
|
uri: x.link!,
|
||||||
|
title: x.title!,
|
||||||
|
language: x.language!,
|
||||||
|
}))}
|
||||||
selectedTextTrack={
|
selectedTextTrack={
|
||||||
subtitle
|
subtitle
|
||||||
? {
|
? {
|
||||||
|
@ -55,6 +55,9 @@ const Video = forwardRef<NativeVideo, VideoProps>(function _NativeVideo(
|
|||||||
const video = useAtomValue(videoAtom);
|
const video = useAtomValue(videoAtom);
|
||||||
const audio = useAtomValue(audioAtom);
|
const audio = useAtomValue(audioAtom);
|
||||||
|
|
||||||
|
const info = useAtomValue(infoAtom);
|
||||||
|
console.log(info);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function run() {
|
async function run() {
|
||||||
token.current = await getToken();
|
token.current = await getToken();
|
||||||
@ -120,11 +123,8 @@ export const QualitiesMenu = (props: CustomMenu) => {
|
|||||||
onSelect={() => setPlayMode(PlayMode.Direct)}
|
onSelect={() => setPlayMode(PlayMode.Direct)}
|
||||||
/>
|
/>
|
||||||
<Menu.Item
|
<Menu.Item
|
||||||
label={
|
// TODO: Display the currently selected quality (impossible with rn-video right now)
|
||||||
mode === PlayMode.Hls && video !== -1
|
label={t("player.auto")}
|
||||||
? `${t("player.auto")} (${video}p)`
|
|
||||||
: t("player.auto")
|
|
||||||
}
|
|
||||||
selected={video === -1}
|
selected={video === -1}
|
||||||
onSelect={() => {
|
onSelect={() => {
|
||||||
setPlayMode(PlayMode.Hls);
|
setPlayMode(PlayMode.Hls);
|
||||||
|
@ -87,6 +87,23 @@ impl Transcoder {
|
|||||||
master.push_str(format!("URI=\"./audio/{}/index.m3u8\"\n", audio.index).as_str());
|
master.push_str(format!("URI=\"./audio/{}/index.m3u8\"\n", audio.index).as_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for subtitle in info.subtitles {
|
||||||
|
master.push_str("#EXT-X-MEDIA:TYPE=SUBTITLES,");
|
||||||
|
master.push_str("GROUP-ID=\"subtitles\",");
|
||||||
|
if let Some(language) = subtitle.language.clone() {
|
||||||
|
master.push_str(format!("LANGUAGE=\"{}\",", language).as_str());
|
||||||
|
}
|
||||||
|
if let Some(title) = subtitle.title {
|
||||||
|
master.push_str(format!("NAME=\"{}\",", title).as_str());
|
||||||
|
} else if let Some(language) = subtitle.language {
|
||||||
|
master.push_str(format!("NAME=\"{}\",", language).as_str());
|
||||||
|
} else {
|
||||||
|
master.push_str(format!("NAME=\"Subtitle {}\",", subtitle.index).as_str());
|
||||||
|
}
|
||||||
|
master.push_str("URI=\"https://kyoo.sdg.moe/api/subtitle/akudama-drive-s1e1.eng.subtitle\"\n");
|
||||||
|
// master.push_str(format!("URI=\"./subtitles/{}/index.m3u8\"\n", subtitle.index).as_str());
|
||||||
|
}
|
||||||
|
|
||||||
Some(master)
|
Some(master)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user