mirror of
https://github.com/p-stream/p-stream.git
synced 2026-04-21 10:32:18 +00:00
Revert "attempt to fix subtitle download"
This reverts commit 30c80053b6.
This commit is contained in:
parent
c12acf8cd9
commit
47a9e2a247
1 changed files with 6 additions and 26 deletions
|
|
@ -8,7 +8,7 @@ import { OptionItem } from "@/components/form/Dropdown";
|
||||||
import { Icon, Icons } from "@/components/Icon";
|
import { Icon, Icons } from "@/components/Icon";
|
||||||
import { OverlayPage } from "@/components/overlays/OverlayPage";
|
import { OverlayPage } from "@/components/overlays/OverlayPage";
|
||||||
import { Menu } from "@/components/player/internals/ContextMenu";
|
import { Menu } from "@/components/player/internals/ContextMenu";
|
||||||
import { convertSubtitlesToSrt } from "@/components/player/utils/captions";
|
import { convertSubtitlesToSrtDataurl } from "@/components/player/utils/captions";
|
||||||
import { Transition } from "@/components/utils/Transition";
|
import { Transition } from "@/components/utils/Transition";
|
||||||
import { useOverlayRouter } from "@/hooks/useOverlayRouter";
|
import { useOverlayRouter } from "@/hooks/useOverlayRouter";
|
||||||
import { usePlayerStore } from "@/stores/player/store";
|
import { usePlayerStore } from "@/stores/player/store";
|
||||||
|
|
@ -125,31 +125,11 @@ export function DownloadView({ id }: { id: string }) {
|
||||||
const sourceType = usePlayerStore((s) => s.source?.type);
|
const sourceType = usePlayerStore((s) => s.source?.type);
|
||||||
const selectedCaption = usePlayerStore((s) => s.caption?.selected);
|
const selectedCaption = usePlayerStore((s) => s.caption?.selected);
|
||||||
const openSubtitleDownload = useCallback(() => {
|
const openSubtitleDownload = useCallback(() => {
|
||||||
if (!selectedCaption?.srtData) return;
|
const dataUrl = selectedCaption
|
||||||
|
? convertSubtitlesToSrtDataurl(selectedCaption?.srtData)
|
||||||
try {
|
: null;
|
||||||
// Convert subtitles to SRT format
|
if (!dataUrl) return;
|
||||||
const srtContent = convertSubtitlesToSrt(selectedCaption.srtData);
|
window.open(dataUrl);
|
||||||
|
|
||||||
// Create a Blob with the SRT content
|
|
||||||
const blob = new Blob([srtContent], { type: "application/x-subrip" });
|
|
||||||
const url = URL.createObjectURL(blob);
|
|
||||||
|
|
||||||
// Create an anchor element for downloading
|
|
||||||
const a = document.createElement("a");
|
|
||||||
a.href = url;
|
|
||||||
a.download = "subtitles.srt";
|
|
||||||
document.body.appendChild(a);
|
|
||||||
a.click();
|
|
||||||
|
|
||||||
// Clean up
|
|
||||||
setTimeout(() => {
|
|
||||||
document.body.removeChild(a);
|
|
||||||
URL.revokeObjectURL(url);
|
|
||||||
}, 100);
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Error downloading subtitles:", error);
|
|
||||||
}
|
|
||||||
}, [selectedCaption]);
|
}, [selectedCaption]);
|
||||||
|
|
||||||
const playerOptions = useMemo(
|
const playerOptions = useMemo(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue