mirror of
https://github.com/p-stream/p-stream.git
synced 2026-03-11 17:55:33 +00:00
translations, bugs, and add back missing buttons
This commit is contained in:
parent
b59b136eea
commit
3507db4050
2 changed files with 49 additions and 26 deletions
|
|
@ -758,6 +758,8 @@
|
||||||
"copyHlsPlaylist": "Copy HLS playlist link",
|
"copyHlsPlaylist": "Copy HLS playlist link",
|
||||||
"downloadSubtitle": "Download current subtitle",
|
"downloadSubtitle": "Download current subtitle",
|
||||||
"downloadVideo": "Download video",
|
"downloadVideo": "Download video",
|
||||||
|
"desktopDisclaimer": "Download this video directly to your app for offline playback.",
|
||||||
|
"offlineButton": "Download for Offline Use",
|
||||||
"openIn": "Open in...",
|
"openIn": "Open in...",
|
||||||
"vlc": "VLC",
|
"vlc": "VLC",
|
||||||
"iina": "IINA",
|
"iina": "IINA",
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,17 @@ export function useDownloadLink() {
|
||||||
const source = usePlayerStore((s) => s.source);
|
const source = usePlayerStore((s) => s.source);
|
||||||
const currentQuality = usePlayerStore((s) => s.currentQuality);
|
const currentQuality = usePlayerStore((s) => s.currentQuality);
|
||||||
const url = useMemo(() => {
|
const url = useMemo(() => {
|
||||||
if (source?.type === "file" && currentQuality)
|
if (source?.type === "file") {
|
||||||
return source.qualities[currentQuality]?.url ?? null;
|
const quality = currentQuality
|
||||||
|
? source.qualities[currentQuality]
|
||||||
|
: undefined;
|
||||||
|
if (quality) return quality.url;
|
||||||
|
// Fallback to the first available quality if currentQuality is not set
|
||||||
|
const firstQuality = Object.values(source.qualities)[0];
|
||||||
|
return firstQuality?.url;
|
||||||
|
}
|
||||||
if (source?.type === "hls") return source.url;
|
if (source?.type === "hls") return source.url;
|
||||||
return null;
|
return undefined;
|
||||||
}, [source, currentQuality]);
|
}, [source, currentQuality]);
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
@ -73,7 +80,7 @@ export function DownloadView({ id }: { id: string }) {
|
||||||
|
|
||||||
const startOfflineDownload = useCallback(async () => {
|
const startOfflineDownload = useCallback(async () => {
|
||||||
if (!downloadUrl) return;
|
if (!downloadUrl) return;
|
||||||
const title = meta?.title ? meta.title : "Video";
|
const title = meta?.title ? meta.title : t("player.menus.downloads.title");
|
||||||
const poster = meta?.poster;
|
const poster = meta?.poster;
|
||||||
let subtitleText: string | undefined;
|
let subtitleText: string | undefined;
|
||||||
|
|
||||||
|
|
@ -112,6 +119,7 @@ export function DownloadView({ id }: { id: string }) {
|
||||||
duration,
|
duration,
|
||||||
router,
|
router,
|
||||||
sourceType,
|
sourceType,
|
||||||
|
t,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const openSubtitleDownload = useCallback(() => {
|
const openSubtitleDownload = useCallback(() => {
|
||||||
|
|
@ -122,8 +130,6 @@ export function DownloadView({ id }: { id: string }) {
|
||||||
window.open(dataUrl);
|
window.open(dataUrl);
|
||||||
}, [selectedCaption]);
|
}, [selectedCaption]);
|
||||||
|
|
||||||
if (!downloadUrl) return null;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Menu.BackLink onClick={() => router.navigate("/")}>
|
<Menu.BackLink onClick={() => router.navigate("/")}>
|
||||||
|
|
@ -136,20 +142,18 @@ export function DownloadView({ id }: { id: string }) {
|
||||||
{isDesktopApp ? (
|
{isDesktopApp ? (
|
||||||
<>
|
<>
|
||||||
<Menu.Paragraph marginClass="mb-6">
|
<Menu.Paragraph marginClass="mb-6">
|
||||||
<Trans i18nKey="player.menus.downloads.desktopDisclaimer">
|
<StyleTrans k="player.menus.downloads.disclaimer" />
|
||||||
Download this video directly to your app for offline
|
</Menu.Paragraph>
|
||||||
playback.
|
|
||||||
</Trans>
|
<Menu.Paragraph marginClass="mb-6">
|
||||||
|
<Trans i18nKey="player.menus.downloads.desktopDisclaimer" />
|
||||||
</Menu.Paragraph>
|
</Menu.Paragraph>
|
||||||
<Button
|
<Button
|
||||||
className="w-full mt-2"
|
className="w-full mt-2"
|
||||||
theme="purple"
|
theme="purple"
|
||||||
onClick={startOfflineDownload}
|
onClick={startOfflineDownload}
|
||||||
>
|
>
|
||||||
{t(
|
{t("player.menus.downloads.offlineButton")}
|
||||||
"player.menus.downloads.offlineButton",
|
|
||||||
"Download for Offline Use",
|
|
||||||
)}
|
|
||||||
</Button>
|
</Button>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
|
|
@ -183,7 +187,7 @@ export function DownloadView({ id }: { id: string }) {
|
||||||
// Allow context menu & left click to copy
|
// Allow context menu & left click to copy
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
copyToClipboard(downloadUrl);
|
copyToClipboard(downloadUrl ?? "");
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{t("player.menus.downloads.copyHlsPlaylist")}
|
{t("player.menus.downloads.copyHlsPlaylist")}
|
||||||
|
|
@ -202,26 +206,43 @@ export function DownloadView({ id }: { id: string }) {
|
||||||
{isDesktopApp ? (
|
{isDesktopApp ? (
|
||||||
<>
|
<>
|
||||||
<Menu.Paragraph marginClass="mb-6">
|
<Menu.Paragraph marginClass="mb-6">
|
||||||
<Trans i18nKey="player.menus.downloads.desktopDisclaimer">
|
<Trans i18nKey="player.menus.downloads.desktopDisclaimer" />
|
||||||
Download this video directly to your app for offline
|
|
||||||
playback.
|
|
||||||
</Trans>
|
|
||||||
</Menu.Paragraph>
|
</Menu.Paragraph>
|
||||||
<Button
|
<Button
|
||||||
className="w-full mt-2"
|
className="w-full mt-2"
|
||||||
theme="purple"
|
theme="purple"
|
||||||
onClick={startOfflineDownload}
|
onClick={startOfflineDownload}
|
||||||
>
|
>
|
||||||
{t(
|
{t("player.menus.downloads.offlineButton")}
|
||||||
"player.menus.downloads.offlineButton",
|
|
||||||
"Download for Offline Use",
|
|
||||||
)}
|
|
||||||
</Button>
|
</Button>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
|
<>
|
||||||
|
<Menu.ChevronLink
|
||||||
|
onClick={() => router.navigate("/download/pc")}
|
||||||
|
>
|
||||||
|
{t("player.menus.downloads.onPc.title")}
|
||||||
|
</Menu.ChevronLink>
|
||||||
|
<Menu.ChevronLink
|
||||||
|
onClick={() => router.navigate("/download/ios")}
|
||||||
|
>
|
||||||
|
{t("player.menus.downloads.onIos.title")}
|
||||||
|
</Menu.ChevronLink>
|
||||||
|
<Menu.ChevronLink
|
||||||
|
onClick={() => router.navigate("/download/android")}
|
||||||
|
>
|
||||||
|
{t("player.menus.downloads.onAndroid.title")}
|
||||||
|
</Menu.ChevronLink>
|
||||||
|
|
||||||
|
<Menu.Divider />
|
||||||
|
|
||||||
|
<Menu.Paragraph marginClass="my-6">
|
||||||
|
<StyleTrans k="player.menus.downloads.disclaimer" />
|
||||||
|
</Menu.Paragraph>
|
||||||
<Button className="w-full" href={downloadUrl} theme="purple">
|
<Button className="w-full" href={downloadUrl} theme="purple">
|
||||||
{t("player.menus.downloads.downloadVideo")}
|
{t("player.menus.downloads.downloadVideo")}
|
||||||
</Button>
|
</Button>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
<Button
|
<Button
|
||||||
className="w-full mt-2"
|
className="w-full mt-2"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue