X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fvideo%2Fvideo-file.ts;h=22cf638046afb6e3fb1ee0bf2e33285cc5484859;hb=d9bf974f5df787bbeaab5b04949ca91a2b3ca2a3;hp=1ad79610414088d34b3221fd6c50ad23002a9777;hpb=d61893f7236abbed30c25b1823e6ecad93a8e8dd;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/video/video-file.ts b/server/models/video/video-file.ts index 1ad796104..22cf63804 100644 --- a/server/models/video/video-file.ts +++ b/server/models/video/video-file.ts @@ -25,6 +25,7 @@ import { logger } from '@server/helpers/logger' import { extractVideo } from '@server/helpers/video' import { getTorrentFilePath } from '@server/lib/video-paths' import { MStreamingPlaylistVideo, MVideo, MVideoWithHost } from '@server/types/models' +import { AttributesOnly } from '@shared/core-utils' import { isVideoFileExtnameValid, isVideoFileInfoHashValid, @@ -149,7 +150,7 @@ export enum ScopeNames { } ] }) -export class VideoFileModel extends Model { +export class VideoFileModel extends Model>> { @CreatedAt createdAt: Date @@ -401,6 +402,10 @@ export class VideoFileModel extends Model { return VideoFileModel.destroy(options) } + hasTorrent () { + return this.infoHash && this.torrentFilename + } + getVideoOrStreamingPlaylist (this: MVideoFileVideo | MVideoFileStreamingPlaylistVideo): MVideo | MStreamingPlaylistVideo { if (this.videoId) return (this as MVideoFileVideo).Video