X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fvideo%2Fvideo-file.ts;h=6f03fae3a501bf986a7dbb774bb7e2d7800060bf;hb=cbe2f36d93c779ca08424336be7e3988e57be01d;hp=5e8d29d0a9b5a3e7039aba94d499f8bc087830b1;hpb=41fb13c330de629df2d23379209e79c7af0f2e9a;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/video/video-file.ts b/server/models/video/video-file.ts index 5e8d29d0a..6f03fae3a 100644 --- a/server/models/video/video-file.ts +++ b/server/models/video/video-file.ts @@ -25,9 +25,9 @@ import { logger } from '@server/helpers/logger' import { extractVideo } from '@server/helpers/video' import { getHLSPublicFileUrl, getWebTorrentPublicFileUrl } from '@server/lib/object-storage' import { getFSTorrentFilePath } from '@server/lib/paths' -import { MStreamingPlaylistVideo, MVideo, MVideoWithHost } from '@server/types/models' -import { AttributesOnly } from '@shared/core-utils' -import { VideoStorage } from '@shared/models' +import { isStreamingPlaylist, MStreamingPlaylistVideo, MVideo, MVideoWithHost } from '@server/types/models' +import { VideoResolution, VideoStorage } from '@shared/models' +import { AttributesOnly } from '@shared/typescript-utils' import { isVideoFileExtnameValid, isVideoFileInfoHashValid, @@ -39,7 +39,6 @@ import { LAZY_STATIC_PATHS, MEMOIZE_LENGTH, MEMOIZE_TTL, - MIMETYPES, STATIC_DOWNLOAD_PATHS, STATIC_PATHS, WEBSERVER @@ -194,6 +193,7 @@ export class VideoFileModel extends Model @Column metadataUrl: string + // Could be null for remote files @AllowNull(true) @Column fileUrl: string @@ -203,6 +203,7 @@ export class VideoFileModel extends Model @Column filename: string + // Could be null for remote files @AllowNull(true) @Column torrentUrl: string @@ -446,7 +447,7 @@ export class VideoFileModel extends Model } isAudio () { - return !!MIMETYPES.AUDIO.EXT_MIMETYPE[this.extname] + return this.resolution === VideoResolution.H_NOVIDEO } isLive () { @@ -534,4 +535,10 @@ export class VideoFileModel extends Model (this.videoStreamingPlaylistId !== null && this.videoStreamingPlaylistId === other.videoStreamingPlaylistId) ) } + + withVideoOrPlaylist (videoOrPlaylist: MVideo | MStreamingPlaylistVideo) { + if (isStreamingPlaylist(videoOrPlaylist)) return Object.assign(this, { VideoStreamingPlaylist: videoOrPlaylist }) + + return Object.assign(this, { Video: videoOrPlaylist }) + } }