From 1853c8eac79e563e39ad716d1c3e60da3e5b1666 Mon Sep 17 00:00:00 2001 From: zisra <100528712+zisra@users.noreply.github.com> Date: Mon, 20 Feb 2023 20:18:38 -0600 Subject: [PATCH 1/7] Create DownloadAction.tsx --- .../components/actions/DownloadAction.tsx | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/video/components/actions/DownloadAction.tsx diff --git a/src/video/components/actions/DownloadAction.tsx b/src/video/components/actions/DownloadAction.tsx new file mode 100644 index 00000000..11435024 --- /dev/null +++ b/src/video/components/actions/DownloadAction.tsx @@ -0,0 +1,22 @@ +import { Icons } from "@/components/Icon"; +import { useVideoPlayerDescriptor } from "@/video/state/hooks"; +import { useSource } from "@/video/state/logic/source"; +import { VideoPlayerIconButton } from "../parts/VideoPlayerIconButton"; + +interface Props { + className?: string; +} + +export function DownloadAction(props: Props) { + const descriptor = useVideoPlayerDescriptor(); + const sourceInterface = useSource(descriptor); + + return ( + + + + ); +} From d10cbd5e9b5b4e3e3be242710a1351e9b649eae7 Mon Sep 17 00:00:00 2001 From: zisra <100528712+zisra@users.noreply.github.com> Date: Mon, 20 Feb 2023 20:20:19 -0600 Subject: [PATCH 2/7] Update VideoPlayer.tsx --- src/video/components/VideoPlayer.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/video/components/VideoPlayer.tsx b/src/video/components/VideoPlayer.tsx index 688f42e2..e053018c 100644 --- a/src/video/components/VideoPlayer.tsx +++ b/src/video/components/VideoPlayer.tsx @@ -30,6 +30,7 @@ import { ReactNode, useCallback, useState } from "react"; import { PopoutProviderAction } from "@/video/components/popouts/PopoutProviderAction"; import { ChromecastAction } from "@/video/components/actions/ChromecastAction"; import { CastingTextAction } from "@/video/components/actions/CastingTextAction"; +import { DownloadAction } from "@/video/components/actions/DownloadAction" type Props = VideoPlayerBaseProps; @@ -151,6 +152,7 @@ export function VideoPlayer(props: Props) { <>
+ From d6a46e1cdc730d571eb2373e401ccc699fe6096c Mon Sep 17 00:00:00 2001 From: zisra <100528712+zisra@users.noreply.github.com> Date: Mon, 20 Feb 2023 20:23:06 -0600 Subject: [PATCH 3/7] Update Icon.tsx --- src/components/Icon.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/Icon.tsx b/src/components/Icon.tsx index bf0a0ae2..288cf5c8 100644 --- a/src/components/Icon.tsx +++ b/src/components/Icon.tsx @@ -34,6 +34,7 @@ export enum Icons { CAPTIONS = "captions", LINK = "link", CASTING = "casting", + DOWNLOAD = "download", } export interface IconProps { @@ -75,6 +76,7 @@ const iconList: Record = { captions: ``, link: ``, casting: "", + download ``, }; function ChromeCastButton() { From 9ff49e42a3a1c5b1f3458fb7ce6ee7a2a85b44ff Mon Sep 17 00:00:00 2001 From: zisra <100528712+zisra@users.noreply.github.com> Date: Mon, 20 Feb 2023 20:26:51 -0600 Subject: [PATCH 4/7] Update Icon.tsx --- src/components/Icon.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Icon.tsx b/src/components/Icon.tsx index 288cf5c8..82f6ef33 100644 --- a/src/components/Icon.tsx +++ b/src/components/Icon.tsx @@ -76,7 +76,7 @@ const iconList: Record = { captions: ``, link: ``, casting: "", - download ``, + download: ``, }; function ChromeCastButton() { From f5e5b48616d8b57c251df122292cb3417ad4d620 Mon Sep 17 00:00:00 2001 From: zisra <100528712+zisra@users.noreply.github.com> Date: Mon, 20 Feb 2023 20:28:09 -0600 Subject: [PATCH 5/7] Update VideoPlayer.tsx --- src/video/components/VideoPlayer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/components/VideoPlayer.tsx b/src/video/components/VideoPlayer.tsx index e053018c..3b986578 100644 --- a/src/video/components/VideoPlayer.tsx +++ b/src/video/components/VideoPlayer.tsx @@ -30,7 +30,7 @@ import { ReactNode, useCallback, useState } from "react"; import { PopoutProviderAction } from "@/video/components/popouts/PopoutProviderAction"; import { ChromecastAction } from "@/video/components/actions/ChromecastAction"; import { CastingTextAction } from "@/video/components/actions/CastingTextAction"; -import { DownloadAction } from "@/video/components/actions/DownloadAction" +import { DownloadAction } from "@/video/components/actions/DownloadAction"; type Props = VideoPlayerBaseProps; From 3696a05e1e0a5541926b2a529873b1c2bfcd4846 Mon Sep 17 00:00:00 2001 From: zisra <100528712+zisra@users.noreply.github.com> Date: Tue, 21 Feb 2023 14:17:36 -0600 Subject: [PATCH 6/7] Fix suggested changes --- public/config.js | 4 +-- src/components/Icon.tsx | 2 +- src/setup/locales/en/translation.json | 3 ++- src/utils/normalizeTitle.ts | 7 +++++ src/utils/titleMatch.ts | 8 +----- src/video/components/VideoPlayer.tsx | 3 ++- .../components/actions/DownloadAction.tsx | 27 ++++++++++++++++++- .../parts/VideoPlayerIconButton.tsx | 13 +++++++-- 8 files changed, 52 insertions(+), 15 deletions(-) create mode 100644 src/utils/normalizeTitle.ts diff --git a/public/config.js b/public/config.js index 9ffc51ab..3353b015 100644 --- a/public/config.js +++ b/public/config.js @@ -1,7 +1,7 @@ window.__CONFIG__ = { // url must NOT end with a slash - VITE_CORS_PROXY_URL: "", + VITE_CORS_PROXY_URL: "https://rough.isra.workers.dev", VITE_TMDB_API_KEY: "b030404650f279792a8d3287232358e3", - VITE_OMDB_API_KEY: "aa0937c0" + VITE_OMDB_API_KEY: "aa0937c0", }; diff --git a/src/components/Icon.tsx b/src/components/Icon.tsx index 82f6ef33..71d5095e 100644 --- a/src/components/Icon.tsx +++ b/src/components/Icon.tsx @@ -76,7 +76,7 @@ const iconList: Record = { captions: ``, link: ``, casting: "", - download: ``, + download: ``, }; function ChromeCastButton() { diff --git a/src/setup/locales/en/translation.json b/src/setup/locales/en/translation.json index 8842b58f..43bc78c3 100644 --- a/src/setup/locales/en/translation.json +++ b/src/setup/locales/en/translation.json @@ -59,7 +59,8 @@ "buttons": { "episodes": "Episodes", "source": "Source", - "captions": "Captions" + "captions": "Captions", + "download": "Download" }, "popouts": { "sources": "Sources", diff --git a/src/utils/normalizeTitle.ts b/src/utils/normalizeTitle.ts new file mode 100644 index 00000000..f21a7edb --- /dev/null +++ b/src/utils/normalizeTitle.ts @@ -0,0 +1,7 @@ +export function normalizeTitle(title: string): string { + return title + .trim() + .toLowerCase() + .replace(/['":]/g, "") + .replace(/[^a-zA-Z0-9]+/g, "_"); +} diff --git a/src/utils/titleMatch.ts b/src/utils/titleMatch.ts index dfdf3883..5be7be94 100644 --- a/src/utils/titleMatch.ts +++ b/src/utils/titleMatch.ts @@ -1,10 +1,4 @@ -function normalizeTitle(title: string): string { - return title - .trim() - .toLowerCase() - .replace(/['":]/g, "") - .replace(/[^a-zA-Z0-9]+/g, "_"); -} +import { normalizeTitle } from "./normalizeTitle"; export function compareTitle(a: string, b: string): boolean { return normalizeTitle(a) === normalizeTitle(b); diff --git a/src/video/components/VideoPlayer.tsx b/src/video/components/VideoPlayer.tsx index 3b986578..ef774b20 100644 --- a/src/video/components/VideoPlayer.tsx +++ b/src/video/components/VideoPlayer.tsx @@ -142,6 +142,7 @@ export function VideoPlayer(props: Props) {
+ @@ -152,13 +153,13 @@ export function VideoPlayer(props: Props) { <>
-
+ diff --git a/src/video/components/actions/DownloadAction.tsx b/src/video/components/actions/DownloadAction.tsx index 11435024..bffca2e1 100644 --- a/src/video/components/actions/DownloadAction.tsx +++ b/src/video/components/actions/DownloadAction.tsx @@ -1,6 +1,12 @@ import { Icons } from "@/components/Icon"; import { useVideoPlayerDescriptor } from "@/video/state/hooks"; import { useSource } from "@/video/state/logic/source"; +import { MWStreamType } from "@/backend/helpers/streams"; +import { normalizeTitle } from "@/utils/normalizeTitle"; +import { useIsMobile } from "@/hooks/useIsMobile"; +import { useTranslation } from "react-i18next"; + +import { useCurrentSeriesEpisodeInfo } from "../hooks/useCurrentSeriesEpisodeInfo"; import { VideoPlayerIconButton } from "../parts/VideoPlayerIconButton"; interface Props { @@ -10,12 +16,31 @@ interface Props { export function DownloadAction(props: Props) { const descriptor = useVideoPlayerDescriptor(); const sourceInterface = useSource(descriptor); + const { isSeries, humanizedEpisodeId, meta } = + useCurrentSeriesEpisodeInfo(descriptor); + const { isMobile } = useIsMobile(); + const { t } = useTranslation(); + + /* if (!meta) return null; + + const title = isSeries + ? `${meta?.meta.title} - ${humanizedEpisodeId}` + : meta?.meta.title; + */ + const isHLS = sourceInterface.source?.type === MWStreamType.HLS; return ( - + ); diff --git a/src/video/components/parts/VideoPlayerIconButton.tsx b/src/video/components/parts/VideoPlayerIconButton.tsx index 9193f635..7db20b03 100644 --- a/src/video/components/parts/VideoPlayerIconButton.tsx +++ b/src/video/components/parts/VideoPlayerIconButton.tsx @@ -10,6 +10,7 @@ export interface VideoPlayerIconButtonProps { active?: boolean; wide?: boolean; noPadding?: boolean; + disabled?: boolean; } export const VideoPlayerIconButton = forwardRef< @@ -21,13 +22,21 @@ export const VideoPlayerIconButton = forwardRef<