diff options
| author | kamtschatka <simon.schatka@gmx.at> | 2024-10-28 02:51:00 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-28 01:51:00 +0000 |
| commit | 4a13c36da50f6b3171d817edebefe96ba85dc666 (patch) | |
| tree | 60ff553426493e7ae2460e73c3500a5525ba735c /packages/shared/assetdb.ts | |
| parent | 3b7451f4d0727d597c0af0e602f0c74cf58999af (diff) | |
| download | karakeep-4a13c36da50f6b3171d817edebefe96ba85dc666.tar.zst | |
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 <me@mbassem.com>
Diffstat (limited to 'packages/shared/assetdb.ts')
| -rw-r--r-- | packages/shared/assetdb.ts | 16 |
1 files changed, 16 insertions, 0 deletions
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<string> = new Set<string>([ @@ -31,6 +32,7 @@ export const SUPPORTED_UPLOAD_ASSET_TYPES: Set<string> = new Set<string>([ export const SUPPORTED_ASSET_TYPES: Set<string> = new Set<string>([ ...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, |
