diff options
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/database-utils.ts | 8 | ||||
-rw-r--r-- | server/helpers/video.ts | 28 |
2 files changed, 9 insertions, 27 deletions
diff --git a/server/helpers/database-utils.ts b/server/helpers/database-utils.ts index 87f10f913..2b916efc2 100644 --- a/server/helpers/database-utils.ts +++ b/server/helpers/database-utils.ts | |||
@@ -4,6 +4,14 @@ import { Model } from 'sequelize-typescript' | |||
4 | import { logger } from './logger' | 4 | import { logger } from './logger' |
5 | import { Transaction } from 'sequelize' | 5 | import { Transaction } from 'sequelize' |
6 | 6 | ||
7 | function retryTransactionWrapper <T, A, B, C, D> ( | ||
8 | functionToRetry: (arg1: A, arg2: B, arg3: C, arg4: D) => Promise<T> | Bluebird<T>, | ||
9 | arg1: A, | ||
10 | arg2: B, | ||
11 | arg3: C, | ||
12 | arg4: D, | ||
13 | ): Promise<T> | ||
14 | |||
7 | function retryTransactionWrapper <T, A, B, C> ( | 15 | function retryTransactionWrapper <T, A, B, C> ( |
8 | functionToRetry: (arg1: A, arg2: B, arg3: C) => Promise<T> | Bluebird<T>, | 16 | functionToRetry: (arg1: A, arg2: B, arg3: C) => Promise<T> | Bluebird<T>, |
9 | arg1: A, | 17 | arg1: A, |
diff --git a/server/helpers/video.ts b/server/helpers/video.ts index bfd5a9627..7c510f474 100644 --- a/server/helpers/video.ts +++ b/server/helpers/video.ts | |||
@@ -1,20 +1,17 @@ | |||
1 | import { Response } from 'express' | 1 | import { Response } from 'express' |
2 | import { CONFIG } from '@server/initializers/config' | 2 | import { CONFIG } from '@server/initializers/config' |
3 | import { DEFAULT_AUDIO_RESOLUTION } from '@server/initializers/constants' | ||
4 | import { JobQueue } from '@server/lib/job-queue' | ||
5 | import { | 3 | import { |
6 | isStreamingPlaylist, | 4 | isStreamingPlaylist, |
7 | MStreamingPlaylistVideo, | 5 | MStreamingPlaylistVideo, |
8 | MVideo, | 6 | MVideo, |
9 | MVideoAccountLightBlacklistAllFiles, | 7 | MVideoAccountLightBlacklistAllFiles, |
10 | MVideoFile, | ||
11 | MVideoFullLight, | 8 | MVideoFullLight, |
12 | MVideoIdThumbnail, | 9 | MVideoIdThumbnail, |
13 | MVideoImmutable, | 10 | MVideoImmutable, |
14 | MVideoThumbnail, | 11 | MVideoThumbnail, |
15 | MVideoWithRights | 12 | MVideoWithRights |
16 | } from '@server/types/models' | 13 | } from '@server/types/models' |
17 | import { VideoPrivacy, VideoState, VideoTranscodingPayload } from '@shared/models' | 14 | import { VideoPrivacy, VideoState } from '@shared/models' |
18 | import { VideoModel } from '../models/video/video' | 15 | import { VideoModel } from '../models/video/video' |
19 | 16 | ||
20 | type VideoFetchType = 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none' | 'only-immutable-attributes' | 17 | type VideoFetchType = 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none' | 'only-immutable-attributes' |
@@ -69,27 +66,6 @@ function getVideoWithAttributes (res: Response) { | |||
69 | return res.locals.videoAll || res.locals.onlyVideo || res.locals.onlyVideoWithRights | 66 | return res.locals.videoAll || res.locals.onlyVideo || res.locals.onlyVideoWithRights |
70 | } | 67 | } |
71 | 68 | ||
72 | function addOptimizeOrMergeAudioJob (video: MVideo, videoFile: MVideoFile) { | ||
73 | let dataInput: VideoTranscodingPayload | ||
74 | |||
75 | if (videoFile.isAudio()) { | ||
76 | dataInput = { | ||
77 | type: 'merge-audio-to-webtorrent', | ||
78 | resolution: DEFAULT_AUDIO_RESOLUTION, | ||
79 | videoUUID: video.uuid, | ||
80 | isNewVideo: true | ||
81 | } | ||
82 | } else { | ||
83 | dataInput = { | ||
84 | type: 'optimize-to-webtorrent', | ||
85 | videoUUID: video.uuid, | ||
86 | isNewVideo: true | ||
87 | } | ||
88 | } | ||
89 | |||
90 | return JobQueue.Instance.createJobWithPromise({ type: 'video-transcoding', payload: dataInput }) | ||
91 | } | ||
92 | |||
93 | function extractVideo (videoOrPlaylist: MVideo | MStreamingPlaylistVideo) { | 69 | function extractVideo (videoOrPlaylist: MVideo | MStreamingPlaylistVideo) { |
94 | return isStreamingPlaylist(videoOrPlaylist) | 70 | return isStreamingPlaylist(videoOrPlaylist) |
95 | ? videoOrPlaylist.Video | 71 | ? videoOrPlaylist.Video |
@@ -107,7 +83,6 @@ function isStateForFederation (state: VideoState) { | |||
107 | const castedState = parseInt(state + '', 10) | 83 | const castedState = parseInt(state + '', 10) |
108 | 84 | ||
109 | return castedState === VideoState.PUBLISHED || castedState === VideoState.WAITING_FOR_LIVE || castedState === VideoState.LIVE_ENDED | 85 | return castedState === VideoState.PUBLISHED || castedState === VideoState.WAITING_FOR_LIVE || castedState === VideoState.LIVE_ENDED |
110 | |||
111 | } | 86 | } |
112 | 87 | ||
113 | function getPrivaciesForFederation () { | 88 | function getPrivaciesForFederation () { |
@@ -130,7 +105,6 @@ export { | |||
130 | fetchVideo, | 105 | fetchVideo, |
131 | getVideoWithAttributes, | 106 | getVideoWithAttributes, |
132 | fetchVideoByUrl, | 107 | fetchVideoByUrl, |
133 | addOptimizeOrMergeAudioJob, | ||
134 | extractVideo, | 108 | extractVideo, |
135 | getExtFromMimetype, | 109 | getExtFromMimetype, |
136 | isStateForFederation, | 110 | isStateForFederation, |