]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/job-queue/handlers/video-transcoding.ts
Suffix external auth username on conflict
[github/Chocobozzz/PeerTube.git] / server / lib / job-queue / handlers / video-transcoding.ts
index 95ee6b384d9902f50a4ca39738e78c3a6b2dfe1f..d3fb7778b76487e214e216fa2445644260ebfd50 100644 (file)
@@ -26,6 +26,7 @@ import {
   optimizeOriginalVideofile,
   transcodeNewWebTorrentResolution
 } from '../../transcoding/transcoding'
+import { Hooks } from '@server/lib/plugins/hooks'
 
 type HandlerFunction = (job: Job, payload: VideoTranscodingPayload, video: MVideoFullLight, user: MUser) => Promise<void>
 
@@ -42,7 +43,7 @@ async function processVideoTranscoding (job: Job) {
   const payload = job.data as VideoTranscodingPayload
   logger.info('Processing transcoding job %d.', job.id, lTags(payload.videoUUID))
 
-  const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(payload.videoUUID)
+  const video = await VideoModel.loadFull(payload.videoUUID)
   // No video, maybe deleted?
   if (!video) {
     logger.info('Do not process job %d, video does not exist.', job.id, lTags(payload.videoUUID))
@@ -149,7 +150,7 @@ async function onHlsPlaylistGeneration (video: MVideoFullLight, user: MUser, pay
   if (payload.isMaxQuality && payload.autoDeleteWebTorrentIfNeeded && CONFIG.TRANSCODING.WEBTORRENT.ENABLED === false) {
     // Remove webtorrent files if not enabled
     for (const file of video.VideoFiles) {
-      await video.removeWebTorrentFileAndTorrent(file)
+      await video.removeWebTorrentFile(file)
       await file.destroy()
     }
 
@@ -180,7 +181,7 @@ async function onVideoFirstWebTorrentTranscoding (
   const { resolution, isPortraitMode, audioStream } = await videoArg.probeMaxQualityFile()
 
   // Maybe the video changed in database, refresh it
-  const videoDatabase = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoArg.uuid)
+  const videoDatabase = await VideoModel.loadFull(videoArg.uuid)
   // Video does not exist anymore
   if (!videoDatabase) return undefined
 
@@ -269,7 +270,12 @@ async function createLowerResolutionsJobs (options: {
   const { video, user, videoFileResolution, isPortraitMode, isNewVideo, hasAudio, type } = options
 
   // Create transcoding jobs if there are enabled resolutions
-  const resolutionsEnabled = computeLowerResolutionsToTranscode(videoFileResolution, 'vod')
+  const resolutionsEnabled = await Hooks.wrapObject(
+    computeLowerResolutionsToTranscode(videoFileResolution, 'vod'),
+    'filter:transcoding.auto.lower-resolutions-to-transcode.result',
+    options
+  )
+
   const resolutionCreated: string[] = []
 
   for (const resolution of resolutionsEnabled) {