diff options
Diffstat (limited to 'server/lib/job-queue/handlers/video-import.ts')
-rw-r--r-- | server/lib/job-queue/handlers/video-import.ts | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/server/lib/job-queue/handlers/video-import.ts b/server/lib/job-queue/handlers/video-import.ts index 93a3e9d90..1fca17584 100644 --- a/server/lib/job-queue/handlers/video-import.ts +++ b/server/lib/job-queue/handlers/video-import.ts | |||
@@ -4,14 +4,14 @@ import { downloadYoutubeDLVideo } from '../../../helpers/youtube-dl' | |||
4 | import { VideoImportModel } from '../../../models/video/video-import' | 4 | import { VideoImportModel } from '../../../models/video/video-import' |
5 | import { VideoImportState } from '../../../../shared/models/videos' | 5 | import { VideoImportState } from '../../../../shared/models/videos' |
6 | import { getDurationFromVideoFile, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' | 6 | import { getDurationFromVideoFile, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' |
7 | import { extname, join } from 'path' | 7 | import { extname } from 'path' |
8 | import { VideoFileModel } from '../../../models/video/video-file' | 8 | import { VideoFileModel } from '../../../models/video/video-file' |
9 | import { VIDEO_IMPORT_TIMEOUT } from '../../../initializers/constants' | 9 | import { VIDEO_IMPORT_TIMEOUT } from '../../../initializers/constants' |
10 | import { VideoState } from '../../../../shared' | 10 | import { VideoState } from '../../../../shared' |
11 | import { JobQueue } from '../index' | 11 | import { JobQueue } from '../index' |
12 | import { federateVideoIfNeeded } from '../../activitypub' | 12 | import { federateVideoIfNeeded } from '../../activitypub' |
13 | import { VideoModel } from '../../../models/video/video' | 13 | import { VideoModel } from '../../../models/video/video' |
14 | import { downloadWebTorrentVideo } from '../../../helpers/webtorrent' | 14 | import { createTorrentAndSetInfoHash, downloadWebTorrentVideo } from '../../../helpers/webtorrent' |
15 | import { getSecureTorrentName } from '../../../helpers/utils' | 15 | import { getSecureTorrentName } from '../../../helpers/utils' |
16 | import { move, remove, stat } from 'fs-extra' | 16 | import { move, remove, stat } from 'fs-extra' |
17 | import { Notifier } from '../../notifier' | 17 | import { Notifier } from '../../notifier' |
@@ -21,7 +21,7 @@ import { createVideoMiniatureFromUrl, generateVideoMiniature } from '../../thumb | |||
21 | import { ThumbnailType } from '../../../../shared/models/videos/thumbnail.type' | 21 | import { ThumbnailType } from '../../../../shared/models/videos/thumbnail.type' |
22 | import { MThumbnail } from '../../../typings/models/video/thumbnail' | 22 | import { MThumbnail } from '../../../typings/models/video/thumbnail' |
23 | import { MVideoImportDefault, MVideoImportDefaultFiles, MVideoImportVideo } from '@server/typings/models/video/video-import' | 23 | import { MVideoImportDefault, MVideoImportDefaultFiles, MVideoImportVideo } from '@server/typings/models/video/video-import' |
24 | import { MVideoBlacklistVideo, MVideoBlacklist } from '@server/typings/models' | 24 | import { getVideoFilePath } from '@server/lib/video-paths' |
25 | 25 | ||
26 | type VideoImportYoutubeDLPayload = { | 26 | type VideoImportYoutubeDLPayload = { |
27 | type: 'youtube-dl' | 27 | type: 'youtube-dl' |
@@ -142,12 +142,12 @@ async function processFile (downloader: () => Promise<string>, videoImport: MVid | |||
142 | } | 142 | } |
143 | videoFile = new VideoFileModel(videoFileData) | 143 | videoFile = new VideoFileModel(videoFileData) |
144 | 144 | ||
145 | const videoWithFiles = Object.assign(videoImport.Video, { VideoFiles: [ videoFile ] }) | 145 | const videoWithFiles = Object.assign(videoImport.Video, { VideoFiles: [ videoFile ], VideoStreamingPlaylists: [] }) |
146 | // To clean files if the import fails | 146 | // To clean files if the import fails |
147 | const videoImportWithFiles: MVideoImportDefaultFiles = Object.assign(videoImport, { Video: videoWithFiles }) | 147 | const videoImportWithFiles: MVideoImportDefaultFiles = Object.assign(videoImport, { Video: videoWithFiles }) |
148 | 148 | ||
149 | // Move file | 149 | // Move file |
150 | videoDestFile = join(CONFIG.STORAGE.VIDEOS_DIR, videoImportWithFiles.Video.getVideoFilename(videoFile)) | 150 | videoDestFile = getVideoFilePath(videoImportWithFiles.Video, videoFile) |
151 | await move(tempVideoPath, videoDestFile) | 151 | await move(tempVideoPath, videoDestFile) |
152 | tempVideoPath = null // This path is not used anymore | 152 | tempVideoPath = null // This path is not used anymore |
153 | 153 | ||
@@ -168,7 +168,7 @@ async function processFile (downloader: () => Promise<string>, videoImport: MVid | |||
168 | } | 168 | } |
169 | 169 | ||
170 | // Create torrent | 170 | // Create torrent |
171 | await videoImportWithFiles.Video.createTorrentAndSetInfoHash(videoFile) | 171 | await createTorrentAndSetInfoHash(videoImportWithFiles.Video, videoFile) |
172 | 172 | ||
173 | const { videoImportUpdated, video } = await sequelizeTypescript.transaction(async t => { | 173 | const { videoImportUpdated, video } = await sequelizeTypescript.transaction(async t => { |
174 | const videoImportToUpdate = videoImportWithFiles as MVideoImportVideo | 174 | const videoImportToUpdate = videoImportWithFiles as MVideoImportVideo |