mirror of
https://github.com/yusufipk/OpenFrame.git
synced 2026-09-11 17:46:06 +00:00
feat: make asset downloads opt-in via "Include assets" toggle
Project/selected downloads now include only videos by default. Add an "Include assets" checkbox toggle to both download dropdowns (default off) that adds b-rolls and other attached assets to the download when enabled. - buildProjectDownloadManifest gains an includeAssets option (default false). - Download route reads ?assets=1 and passes it through.
This commit is contained in:
+13
-9
@@ -223,6 +223,8 @@ function bigintToSafeNumber(value: bigint): number | null {
|
||||
export type BuildProjectDownloadManifestOptions = {
|
||||
/** Include every version of each video. Defaults to latest version only. */
|
||||
includeAllVersions?: boolean;
|
||||
/** Include b-rolls and other attached assets. Defaults to videos only. */
|
||||
includeAssets?: boolean;
|
||||
};
|
||||
|
||||
export function buildProjectDownloadManifest(
|
||||
@@ -230,7 +232,7 @@ export function buildProjectDownloadManifest(
|
||||
videos: VideoRow[],
|
||||
options: BuildProjectDownloadManifestOptions = {}
|
||||
): ProjectDownloadManifest {
|
||||
const { includeAllVersions = false } = options;
|
||||
const { includeAllVersions = false, includeAssets = false } = options;
|
||||
const files: ProjectDownloadManifestFile[] = [];
|
||||
const usedNames = new Set<string>();
|
||||
|
||||
@@ -257,15 +259,17 @@ export function buildProjectDownloadManifest(
|
||||
});
|
||||
}
|
||||
|
||||
for (const asset of video.assets) {
|
||||
const url = assetDownloadUrl(video.id, asset);
|
||||
if (!url) continue;
|
||||
if (includeAssets) {
|
||||
for (const asset of video.assets) {
|
||||
const url = assetDownloadUrl(video.id, asset);
|
||||
if (!url) continue;
|
||||
|
||||
files.push({
|
||||
fileName: makeUniqueName(buildAssetFileName(videoIndex, videoTitle, asset), usedNames),
|
||||
url,
|
||||
sizeBytes: bigintToSafeNumber(asset.sizeBytes),
|
||||
});
|
||||
files.push({
|
||||
fileName: makeUniqueName(buildAssetFileName(videoIndex, videoTitle, asset), usedNames),
|
||||
url,
|
||||
sizeBytes: bigintToSafeNumber(asset.sizeBytes),
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user