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:
yusufipk
2026-07-10 21:03:34 +07:00
parent 57c5a127d1
commit 8d7d064647
3 changed files with 65 additions and 15 deletions
+13 -9
View File
@@ -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),
});
}
}
});