+ const videoOutputPath = join(videosDirectory, this.getVideoFilename(newVideoFile))
+
+ const transcodeOptions = {
+ inputPath: videoInputPath,
+ outputPath: videoOutputPath,
+ resolution
+ }
+
+ await transcode(transcodeOptions)
+
+ const stats = await statPromise(videoOutputPath)
+
+ newVideoFile.set('size', stats.size)
+
+ await this.createTorrentAndSetInfoHash(newVideoFile)
+
+ await newVideoFile.save()
+
+ this.VideoFiles.push(newVideoFile)
+}
+
+getOriginalFileHeight = function (this: VideoInstance) {
+ const originalFilePath = this.getVideoFilePath(this.getOriginalFile())
+
+ return getVideoFileHeight(originalFilePath)
+}
+
+getDescriptionPath = function (this: VideoInstance) {
+ return `/api/${API_VERSION}/videos/${this.uuid}/description`
+}
+
+getCategoryLabel = function (this: VideoInstance) {
+ let categoryLabel = VIDEO_CATEGORIES[this.category]
+
+ // Maybe our server is not up to date and there are new categories since our version
+ if (!categoryLabel) categoryLabel = 'Misc'
+
+ return categoryLabel
+}
+
+getLicenceLabel = function (this: VideoInstance) {
+ let licenceLabel = VIDEO_LICENCES[this.licence]
+
+ // Maybe our server is not up to date and there are new licences since our version
+ if (!licenceLabel) licenceLabel = 'Unknown'
+
+ return licenceLabel
+}
+
+getLanguageLabel = function (this: VideoInstance) {
+ // Language is an optional attribute
+ let languageLabel = VIDEO_LANGUAGES[this.language]
+ if (!languageLabel) languageLabel = 'Unknown'
+
+ return languageLabel
+}
+
+removeThumbnail = function (this: VideoInstance) {
+ const thumbnailPath = join(CONFIG.STORAGE.THUMBNAILS_DIR, this.getThumbnailName())
+ return unlinkPromise(thumbnailPath)
+}
+
+removePreview = function (this: VideoInstance) {
+ // Same name than video thumbnail
+ return unlinkPromise(CONFIG.STORAGE.PREVIEWS_DIR + this.getPreviewName())
+}
+
+removeFile = function (this: VideoInstance, videoFile: VideoFileInstance) {
+ const filePath = join(CONFIG.STORAGE.VIDEOS_DIR, this.getVideoFilename(videoFile))
+ return unlinkPromise(filePath)
+}
+
+removeTorrent = function (this: VideoInstance, videoFile: VideoFileInstance) {
+ const torrentPath = join(CONFIG.STORAGE.TORRENTS_DIR, this.getTorrentFileName(videoFile))
+ return unlinkPromise(torrentPath)