From ac0e5e692717fef0d7e21dd07f5715da88b3c5eb Mon Sep 17 00:00:00 2001 From: Astrid Date: Wed, 27 Dec 2023 22:39:38 +0100 Subject: [PATCH 1/3] Add support for playlist download --- src/components/player/atoms/settings/SettingsMenu.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/player/atoms/settings/SettingsMenu.tsx b/src/components/player/atoms/settings/SettingsMenu.tsx index 6e1f4d2f..14b3827f 100644 --- a/src/components/player/atoms/settings/SettingsMenu.tsx +++ b/src/components/player/atoms/settings/SettingsMenu.tsx @@ -37,6 +37,8 @@ export function SettingsMenu({ id }: { id: string }) { const source = usePlayerStore((s) => s.source); + const downloadable = source?.type === "file" || source?.type === "hls"; + return ( @@ -58,12 +60,10 @@ export function SettingsMenu({ id }: { id: string }) { - router.navigate( - source?.type === "file" ? "/download" : "/download/unable", - ) + router.navigate(downloadable ? "/download" : "/download/unable") } rightSide={} - className={source?.type === "file" ? "opacity-100" : "opacity-50"} + className={downloadable ? "opacity-100" : "opacity-50"} > {t("player.menus.settings.downloadItem")} From 7f0701ee61ca308a263eaea0c6981f25c716cc06 Mon Sep 17 00:00:00 2001 From: Astrid Date: Wed, 27 Dec 2023 22:39:56 +0100 Subject: [PATCH 2/3] Updated English locale for playlist downloads --- src/assets/locales/en.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/assets/locales/en.json b/src/assets/locales/en.json index 042cbe91..f0ef16ea 100644 --- a/src/assets/locales/en.json +++ b/src/assets/locales/en.json @@ -188,8 +188,9 @@ "downloads": { "title": "Download", "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", + "downloadPlaylist": "Download playlist", "downloadCaption": "Download current caption", "onPc": { "1": "On PC, click the download button then, on the new page, right click the video and select Save video as", From 57edcbeb79924fc7a072d8379fbabd1cfb8b0363 Mon Sep 17 00:00:00 2001 From: Astrid Date: Wed, 27 Dec 2023 22:40:04 +0100 Subject: [PATCH 3/3] Playlist downloads --- .../player/atoms/settings/Downloads.tsx | 81 ++++++++++++------- 1 file changed, 54 insertions(+), 27 deletions(-) diff --git a/src/components/player/atoms/settings/Downloads.tsx b/src/components/player/atoms/settings/Downloads.tsx index 73bcf24a..4a7dcef2 100644 --- a/src/components/player/atoms/settings/Downloads.tsx +++ b/src/components/player/atoms/settings/Downloads.tsx @@ -15,6 +15,7 @@ function useDownloadLink() { const url = useMemo(() => { if (source?.type === "file" && currentQuality) return source.qualities[currentQuality]?.url ?? null; + if (source?.type === "hls") return source.url; return null; }, [source, currentQuality]); return url; @@ -42,6 +43,7 @@ export function DownloadView({ id }: { id: string }) { const { t } = useTranslation(); const downloadUrl = useDownloadLink(); + const sourceType = usePlayerStore((s) => s.source?.type); const selectedCaption = usePlayerStore((s) => s.caption?.selected); const subtitleUrl = useMemo( () => @@ -60,36 +62,61 @@ export function DownloadView({ id }: { id: string }) {
- router.navigate("/download/pc")}> - {t("player.menus.downloads.onPc.title")} - - router.navigate("/download/ios")}> - {t("player.menus.downloads.onIos.title")} - - router.navigate("/download/android")} - > - {t("player.menus.downloads.onAndroid.title")} - + {sourceType === "hls" ? ( + <> + + + - + + + + ) : ( + <> + router.navigate("/download/pc")}> + {t("player.menus.downloads.onPc.title")} + + router.navigate("/download/ios")} + > + {t("player.menus.downloads.onIos.title")} + + router.navigate("/download/android")} + > + {t("player.menus.downloads.onAndroid.title")} + - - - + - - + + + + + + + + )}