mirror of
https://github.com/movie-web/movie-web.git
synced 2024-11-14 10:45:10 +01:00
Merge pull request #596 from robertsspaceindustries/dev
Playlist download support
This commit is contained in:
commit
ed67c30e1d
@ -188,8 +188,9 @@
|
|||||||
"downloads": {
|
"downloads": {
|
||||||
"title": "Download",
|
"title": "Download",
|
||||||
"disclaimer": "Downloads are taken directly from the provider. movie-web does not have control over how the downloads are provided.",
|
"disclaimer": "Downloads are taken directly from the provider. movie-web does not have control over how the downloads are provided.",
|
||||||
"hlsExplanation": "This media is a HLS stream which cannot be downloaded on movie-web.",
|
"hlsDisclaimer": "Downloads are taken directly from the provider. movie-web does not have control over how the downloads are provided. Please note that you are downloading an HLS playlist, this is intended for users familiar with advanced multimedia streaming.",
|
||||||
"downloadVideo": "Download video",
|
"downloadVideo": "Download video",
|
||||||
|
"downloadPlaylist": "Download playlist",
|
||||||
"downloadCaption": "Download current caption",
|
"downloadCaption": "Download current caption",
|
||||||
"onPc": {
|
"onPc": {
|
||||||
"1": "On PC, click the download button then, on the new page, right click the video and select <bold>Save video as</bold>",
|
"1": "On PC, click the download button then, on the new page, right click the video and select <bold>Save video as</bold>",
|
||||||
|
@ -15,6 +15,7 @@ function useDownloadLink() {
|
|||||||
const url = useMemo(() => {
|
const url = useMemo(() => {
|
||||||
if (source?.type === "file" && currentQuality)
|
if (source?.type === "file" && currentQuality)
|
||||||
return source.qualities[currentQuality]?.url ?? null;
|
return source.qualities[currentQuality]?.url ?? null;
|
||||||
|
if (source?.type === "hls") return source.url;
|
||||||
return null;
|
return null;
|
||||||
}, [source, currentQuality]);
|
}, [source, currentQuality]);
|
||||||
return url;
|
return url;
|
||||||
@ -42,6 +43,7 @@ export function DownloadView({ id }: { id: string }) {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const downloadUrl = useDownloadLink();
|
const downloadUrl = useDownloadLink();
|
||||||
|
|
||||||
|
const sourceType = usePlayerStore((s) => s.source?.type);
|
||||||
const selectedCaption = usePlayerStore((s) => s.caption?.selected);
|
const selectedCaption = usePlayerStore((s) => s.caption?.selected);
|
||||||
const subtitleUrl = useMemo(
|
const subtitleUrl = useMemo(
|
||||||
() =>
|
() =>
|
||||||
@ -60,36 +62,61 @@ export function DownloadView({ id }: { id: string }) {
|
|||||||
</Menu.BackLink>
|
</Menu.BackLink>
|
||||||
<Menu.Section>
|
<Menu.Section>
|
||||||
<div>
|
<div>
|
||||||
<Menu.ChevronLink onClick={() => router.navigate("/download/pc")}>
|
{sourceType === "hls" ? (
|
||||||
{t("player.menus.downloads.onPc.title")}
|
<>
|
||||||
</Menu.ChevronLink>
|
<Menu.Paragraph marginClass="mb-6">
|
||||||
<Menu.ChevronLink onClick={() => router.navigate("/download/ios")}>
|
<StyleTrans k="player.menus.downloads.hlsDisclaimer" />
|
||||||
{t("player.menus.downloads.onIos.title")}
|
</Menu.Paragraph>
|
||||||
</Menu.ChevronLink>
|
|
||||||
<Menu.ChevronLink
|
|
||||||
onClick={() => router.navigate("/download/android")}
|
|
||||||
>
|
|
||||||
{t("player.menus.downloads.onAndroid.title")}
|
|
||||||
</Menu.ChevronLink>
|
|
||||||
|
|
||||||
<Menu.Divider />
|
<Button className="w-full" href={downloadUrl} theme="purple">
|
||||||
|
{t("player.menus.downloads.downloadPlaylist")}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
className="w-full mt-2"
|
||||||
|
href={subtitleUrl ?? undefined}
|
||||||
|
disabled={!subtitleUrl}
|
||||||
|
theme="secondary"
|
||||||
|
download="subtitles.srt"
|
||||||
|
>
|
||||||
|
{t("player.menus.downloads.downloadCaption")}
|
||||||
|
</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.Paragraph marginClass="my-6">
|
<Menu.Divider />
|
||||||
<StyleTrans k="player.menus.downloads.disclaimer" />
|
|
||||||
</Menu.Paragraph>
|
|
||||||
|
|
||||||
<Button className="w-full" href={downloadUrl} theme="purple">
|
<Menu.Paragraph marginClass="my-6">
|
||||||
{t("player.menus.downloads.downloadVideo")}
|
<StyleTrans k="player.menus.downloads.disclaimer" />
|
||||||
</Button>
|
</Menu.Paragraph>
|
||||||
<Button
|
|
||||||
className="w-full mt-2"
|
<Button className="w-full" href={downloadUrl} theme="purple">
|
||||||
href={subtitleUrl ?? undefined}
|
{t("player.menus.downloads.downloadVideo")}
|
||||||
disabled={!subtitleUrl}
|
</Button>
|
||||||
theme="secondary"
|
<Button
|
||||||
download="subtitles.srt"
|
className="w-full mt-2"
|
||||||
>
|
href={subtitleUrl ?? undefined}
|
||||||
{t("player.menus.downloads.downloadCaption")}
|
disabled={!subtitleUrl}
|
||||||
</Button>
|
theme="secondary"
|
||||||
|
download="subtitles.srt"
|
||||||
|
>
|
||||||
|
{t("player.menus.downloads.downloadCaption")}
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</Menu.Section>
|
</Menu.Section>
|
||||||
</>
|
</>
|
||||||
|
@ -37,6 +37,8 @@ export function SettingsMenu({ id }: { id: string }) {
|
|||||||
|
|
||||||
const source = usePlayerStore((s) => s.source);
|
const source = usePlayerStore((s) => s.source);
|
||||||
|
|
||||||
|
const downloadable = source?.type === "file" || source?.type === "hls";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Menu.Card>
|
<Menu.Card>
|
||||||
<Menu.SectionTitle>
|
<Menu.SectionTitle>
|
||||||
@ -58,12 +60,10 @@ export function SettingsMenu({ id }: { id: string }) {
|
|||||||
<Menu.Link
|
<Menu.Link
|
||||||
clickable
|
clickable
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
router.navigate(
|
router.navigate(downloadable ? "/download" : "/download/unable")
|
||||||
source?.type === "file" ? "/download" : "/download/unable",
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
rightSide={<Icon className="text-xl" icon={Icons.DOWNLOAD} />}
|
rightSide={<Icon className="text-xl" icon={Icons.DOWNLOAD} />}
|
||||||
className={source?.type === "file" ? "opacity-100" : "opacity-50"}
|
className={downloadable ? "opacity-100" : "opacity-50"}
|
||||||
>
|
>
|
||||||
{t("player.menus.settings.downloadItem")}
|
{t("player.menus.settings.downloadItem")}
|
||||||
</Menu.Link>
|
</Menu.Link>
|
||||||
|
Loading…
Reference in New Issue
Block a user