From 5feda3edd7b965bc9467f2813c74ed705186b9f6 Mon Sep 17 00:00:00 2001 From: Pas <74743263+Pasithea0@users.noreply.github.com> Date: Thu, 16 Jan 2025 18:17:54 -0700 Subject: [PATCH] add hls downloader --- .../player/atoms/settings/Downloads.tsx | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/components/player/atoms/settings/Downloads.tsx b/src/components/player/atoms/settings/Downloads.tsx index 1c018b3e..0a742588 100644 --- a/src/components/player/atoms/settings/Downloads.tsx +++ b/src/components/player/atoms/settings/Downloads.tsx @@ -44,6 +44,22 @@ export function DownloadView({ id }: { id: string }) { const router = useOverlayRouter(id); const { t } = useTranslation(); const downloadUrl = useDownloadLink(); + + // Custom function to process the download URL + const processDownloadUrl = useCallback(() => { + if (!downloadUrl) return ""; + + // Check if the URL contains the m3u8-proxy and the ?url= parameter + const match = downloadUrl.match(/m3u8-proxy\?url=(.*)$/); + if (match && match[1]) { + // Decode the URL component + return decodeURIComponent(match[1]); + } + + return downloadUrl; // Return original if no specific pattern is found + }, [downloadUrl]); + + const hlsDownload = `https://hls-downloader.pstream.org/?url=${encodeURIComponent(processDownloadUrl())}`; const [, copyToClipboard] = useCopyToClipboard(); const sourceType = usePlayerStore((s) => s.source?.type); @@ -66,14 +82,16 @@ export function DownloadView({ id }: { id: string }) {