]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/video/video-file.ts
Update server dependencies
[github/Chocobozzz/PeerTube.git] / server / models / video / video-file.ts
index 2203a7abaf547ec3da32cba5f7a95e79aa75e93a..68e2d562a318f9d11ffc8b0e908cf075ff8885dc 100644 (file)
@@ -24,6 +24,8 @@ import { VideoModel } from './video'
 import { VideoRedundancyModel } from '../redundancy/video-redundancy'
 import { VideoStreamingPlaylistModel } from './video-streaming-playlist'
 import { FindOptions, QueryTypes, Transaction } from 'sequelize'
+import { MIMETYPES } from '../../initializers/constants'
+import { MVideoFile } from '@server/typings/models'
 
 @Table({
   tableName: 'videoFile',
@@ -97,7 +99,7 @@ export class VideoFileModel extends Model<VideoFileModel> {
   static doesInfohashExist (infoHash: string) {
     const query = 'SELECT 1 FROM "videoFile" WHERE "infoHash" = $infoHash LIMIT 1'
     const options = {
-      type: QueryTypes.SELECT,
+      type: QueryTypes.SELECT as QueryTypes.SELECT,
       bind: { infoHash },
       raw: true
     }
@@ -161,7 +163,11 @@ export class VideoFileModel extends Model<VideoFileModel> {
       }))
   }
 
-  hasSameUniqueKeysThan (other: VideoFileModel) {
+  isAudio () {
+    return !!MIMETYPES.AUDIO.EXT_MIMETYPE[this.extname]
+  }
+
+  hasSameUniqueKeysThan (other: MVideoFile) {
     return this.fps === other.fps &&
       this.resolution === other.resolution &&
       this.videoId === other.videoId