Browse Source

Merge branch 'cdn-replacements' of https://github.com/JamesHawkinss/movie-web into cdn-replacements

pull/597/head
mrjvs 2 years ago
parent
commit
b6294b6d15
  1. 3
      src/assets/locales/en.json
  2. 2
      src/components/player/README.md
  3. 29
      src/components/player/atoms/settings/Downloads.tsx
  4. 8
      src/components/player/atoms/settings/SettingsMenu.tsx

3
src/assets/locales/en.json

@ -188,8 +188,9 @@ @@ -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 <bold>Save video as</bold>",

2
src/components/player/README.md

@ -12,7 +12,7 @@ These parts are internally used, they aren't exported. Do not use them outside o @@ -12,7 +12,7 @@ These parts are internally used, they aren't exported. Do not use them outside o
### `/display`
The display interface, abstraction on how to actually play the content (e.g Video element, chrome casting, etc)
- It must be completely seperate from any react code
- It must be completely separate from any react code
- It must not interact with state, pass async data back with events
### `/internals`

29
src/components/player/atoms/settings/Downloads.tsx

@ -15,6 +15,7 @@ function useDownloadLink() { @@ -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 }) { @@ -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,10 +62,33 @@ export function DownloadView({ id }: { id: string }) { @@ -60,10 +62,33 @@ export function DownloadView({ id }: { id: string }) {
</Menu.BackLink>
<Menu.Section>
<div>
{sourceType === "hls" ? (
<>
<Menu.Paragraph marginClass="mb-6">
<StyleTrans k="player.menus.downloads.hlsDisclaimer" />
</Menu.Paragraph>
<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")}>
<Menu.ChevronLink
onClick={() => router.navigate("/download/ios")}
>
{t("player.menus.downloads.onIos.title")}
</Menu.ChevronLink>
<Menu.ChevronLink
@ -90,6 +115,8 @@ export function DownloadView({ id }: { id: string }) { @@ -90,6 +115,8 @@ export function DownloadView({ id }: { id: string }) {
>
{t("player.menus.downloads.downloadCaption")}
</Button>
</>
)}
</div>
</Menu.Section>
</>

8
src/components/player/atoms/settings/SettingsMenu.tsx

@ -37,6 +37,8 @@ export function SettingsMenu({ id }: { id: string }) { @@ -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 (
<Menu.Card>
<Menu.SectionTitle>
@ -58,12 +60,10 @@ export function SettingsMenu({ id }: { id: string }) { @@ -58,12 +60,10 @@ export function SettingsMenu({ id }: { id: string }) {
<Menu.Link
clickable
onClick={() =>
router.navigate(
source?.type === "file" ? "/download" : "/download/unable",
)
router.navigate(downloadable ? "/download" : "/download/unable")
}
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")}
</Menu.Link>

Loading…
Cancel
Save