ニジカ投稿局 https://tv.nizika.tv
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

video-miniature-permanent-file-cache.ts 898 B

12345678910111213141516171819202122232425262728
  1. import { CONFIG } from '@server/initializers/config.js'
  2. import { THUMBNAILS_SIZE } from '@server/initializers/constants.js'
  3. import { ThumbnailModel } from '@server/models/video/thumbnail.js'
  4. import { MThumbnail } from '@server/types/models/index.js'
  5. import { ThumbnailType } from '@peertube/peertube-models'
  6. import { AbstractPermanentFileCache } from './shared/index.js'
  7. export class VideoMiniaturePermanentFileCache extends AbstractPermanentFileCache<MThumbnail> {
  8. constructor () {
  9. super(CONFIG.STORAGE.THUMBNAILS_DIR)
  10. }
  11. protected loadModel (filename: string) {
  12. return ThumbnailModel.loadByFilename(filename, ThumbnailType.MINIATURE)
  13. }
  14. protected getImageSize (image: MThumbnail): { width: number, height: number } {
  15. if (image.width && image.height) {
  16. return {
  17. height: image.height,
  18. width: image.width
  19. }
  20. }
  21. return THUMBNAILS_SIZE
  22. }
  23. }