From 4a13c36da50f6b3171d817edebefe96ba85dc666 Mon Sep 17 00:00:00 2001 From: kamtschatka Date: Mon, 28 Oct 2024 02:51:00 +0100 Subject: feature: Archive videos using yt-dlp. Fixes #215 (#525) * Allow downloading more content from a webpage and index it #215 Added a worker that allows downloading videos depending on the environment variables refactored the code a bit added new video asset updated documentation * Some tweaks * Drop the dependency on the yt-dlp wrapper * Update openapi specs * Dont log an error when the url is not supported * Better handle supported websites that dont download anything --------- Co-authored-by: Mohamed Bassem --- packages/shared/assetdb.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'packages/shared/assetdb.ts') diff --git a/packages/shared/assetdb.ts b/packages/shared/assetdb.ts index 64413e9f..fb7d2461 100644 --- a/packages/shared/assetdb.ts +++ b/packages/shared/assetdb.ts @@ -13,6 +13,7 @@ export const enum ASSET_TYPES { IMAGE_WEBP = "image/webp", APPLICATION_PDF = "application/pdf", TEXT_HTML = "text/html", + VIDEO_MP4 = "video/mp4", } export const IMAGE_ASSET_TYPES: Set = new Set([ @@ -31,6 +32,7 @@ export const SUPPORTED_UPLOAD_ASSET_TYPES: Set = new Set([ export const SUPPORTED_ASSET_TYPES: Set = new Set([ ...SUPPORTED_UPLOAD_ASSET_TYPES, ASSET_TYPES.TEXT_HTML, + ASSET_TYPES.VIDEO_MP4, ]); function getAssetDir(userId: string, assetId: string) { @@ -152,6 +154,20 @@ export async function getAssetSize({ return stat.size; } +/** + * Deletes the passed in asset if it exists and ignores any errors + * @param userId the id of the user the asset belongs to + * @param assetId the id of the asset to delete + */ +export async function silentDeleteAsset( + userId: string, + assetId: string | undefined, +) { + if (assetId) { + await deleteAsset({ userId, assetId }).catch(() => ({})); + } +} + export async function deleteAsset({ userId, assetId, -- cgit v1.2.3-70-g09d2