mirror of
https://github.com/movie-web/native-app.git
synced 2025-09-13 18:13:25 +00:00
feat: hls downloads
This commit is contained in:
@@ -12,10 +12,15 @@ export const DownloadButton = () => {
|
||||
const theme = useTheme();
|
||||
const stream = usePlayerStore((state) => state.interface.currentStream);
|
||||
const { startDownload } = useDownloadManager();
|
||||
if (stream?.type !== "file") return null;
|
||||
let url: string | undefined | null = null;
|
||||
|
||||
if (stream?.type === "file") {
|
||||
const highestQuality = findHighestQuality(stream);
|
||||
url = highestQuality ? stream.qualities[highestQuality]?.url : null;
|
||||
} else if (stream?.type === "hls") {
|
||||
url = stream.playlist;
|
||||
}
|
||||
|
||||
const highestQuality = findHighestQuality(stream);
|
||||
const url = highestQuality ? stream.qualities[highestQuality]?.url : null;
|
||||
if (!url) return null;
|
||||
|
||||
return (
|
||||
@@ -30,7 +35,9 @@ export const DownloadButton = () => {
|
||||
color={theme.buttonSecondaryText.val}
|
||||
/>
|
||||
}
|
||||
onPress={() => startDownload(url, "mp4")}
|
||||
onPress={() =>
|
||||
url && startDownload(url, stream?.type === "hls" ? "hls" : "mp4")
|
||||
}
|
||||
>
|
||||
Download
|
||||
</MWButton>
|
||||
|
@@ -2,7 +2,8 @@ import { useState } from "react";
|
||||
import { MaterialCommunityIcons, MaterialIcons } from "@expo/vector-icons";
|
||||
import { useTheme } from "tamagui";
|
||||
|
||||
import { constructFullUrl } from "~/lib/url";
|
||||
import { constructFullUrl } from "@movie-web/provider-utils";
|
||||
|
||||
import { usePlayerStore } from "~/stores/player/store";
|
||||
import { MWButton } from "../ui/Button";
|
||||
import { Controls } from "./Controls";
|
||||
|
@@ -10,6 +10,7 @@ import type {
|
||||
ScrapeMedia,
|
||||
} from "@movie-web/provider-utils";
|
||||
import {
|
||||
constructFullUrl,
|
||||
extractTracksFromHLS,
|
||||
findHighestQuality,
|
||||
} from "@movie-web/provider-utils";
|
||||
@@ -21,7 +22,6 @@ import { useDownloadManager } from "~/hooks/DownloadManagerContext";
|
||||
import { useMeta } from "~/hooks/player/useMeta";
|
||||
import { useScrape } from "~/hooks/player/useSourceScrape";
|
||||
import { convertMetaToScrapeMedia } from "~/lib/meta";
|
||||
import { constructFullUrl } from "~/lib/url";
|
||||
import { PlayerStatus } from "~/stores/player/slices/interface";
|
||||
import { usePlayerStore } from "~/stores/player/store";
|
||||
import { ScrapeCard, ScrapeItem } from "./ScrapeCard";
|
||||
@@ -76,6 +76,10 @@ export const ScraperProcess = ({
|
||||
: null;
|
||||
if (!url) return;
|
||||
startDownload(url, "mp4").catch(console.error);
|
||||
} else if (streamResult.stream.type === "hls") {
|
||||
startDownload(streamResult.stream.playlist, "hls").catch(
|
||||
console.error,
|
||||
);
|
||||
}
|
||||
return router.back();
|
||||
}
|
||||
|
Reference in New Issue
Block a user