Skip to content

Commit

Permalink
Merge pull request #225 from waifuvault/add-video-thumbnails
Browse files Browse the repository at this point in the history
enable thumbnails for videos
  • Loading branch information
VictoriqueMoe authored Jan 30, 2025
2 parents e36ed98 + 8dbef9c commit 2c62233
Show file tree
Hide file tree
Showing 6 changed files with 297 additions and 13 deletions.
172 changes: 172 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@
"express": "^4.21.2",
"express-rate-limit": "^7.5.0",
"express-session": "^1.18.1",
"ffmpeg-static": "^5.2.0",
"file-type": "^20.0.0",
"fluent-ffmpeg": "^2.1.3",
"helmet": "^8.0.0",
"http-status-codes": "^2.3.0",
"is-localhost-ip": "^2.0.0",
Expand Down Expand Up @@ -100,6 +102,7 @@
"@types/cors": "^2.8.17",
"@types/express": "^5.0.0",
"@types/express-session": "^1.18.1",
"@types/fluent-ffmpeg": "^2.1.27",
"@types/jsdom": "^21.1.7",
"@types/method-override": "^3.0.0",
"@types/multer": "^1.4.12",
Expand Down
8 changes: 7 additions & 1 deletion src/model/dto/PublicAlbumDto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,16 @@ export class PublicAlbumDto {
}

private static getThumbnail(album: AlbumModel, file: FileUploadModel): string | null {
if (!FileUtils.isImage(file) || file.fileProtectionLevel !== "None") {
if (!PublicAlbumDto.isValidForThumbnail(file)) {
return null;
}
const baseUrl = constant(GlobalEnv.BASE_URL) as string;
return `${baseUrl}/rest/album/operations/${album.publicToken}/thumbnail?imageId=${file.id}`;
}

private static isValidForThumbnail(file: FileUploadModel): boolean {
return (
(FileUtils.isImage(file) || FileUtils.isVideoSupportedByFfmpeg(file)) && file.fileProtectionLevel === "None"
);
}
}
Loading

0 comments on commit 2c62233

Please sign in to comment.