diff options
author | Chocobozzz <me@florianbigard.com> | 2020-08-10 14:25:29 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-08-11 07:57:20 +0200 |
commit | 30bc55c88b3b7416c2224925e88639694fd32746 (patch) | |
tree | aebe3b1b8657198e432080f7d15a5694f19a8389 /server/helpers/video.ts | |
parent | 560605026bfadab711cf6d34e9c7ea865887816a (diff) | |
download | PeerTube-30bc55c88b3b7416c2224925e88639694fd32746.tar.gz PeerTube-30bc55c88b3b7416c2224925e88639694fd32746.tar.zst PeerTube-30bc55c88b3b7416c2224925e88639694fd32746.zip |
Refactor video extensions logic in server
Diffstat (limited to 'server/helpers/video.ts')
-rw-r--r-- | server/helpers/video.ts | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/server/helpers/video.ts b/server/helpers/video.ts index 89c85accb..488b4da17 100644 --- a/server/helpers/video.ts +++ b/server/helpers/video.ts | |||
@@ -1,5 +1,8 @@ | |||
1 | import { VideoModel } from '../models/video/video' | ||
2 | import * as Bluebird from 'bluebird' | 1 | import * as Bluebird from 'bluebird' |
2 | import { Response } from 'express' | ||
3 | import { CONFIG } from '@server/initializers/config' | ||
4 | import { DEFAULT_AUDIO_RESOLUTION } from '@server/initializers/constants' | ||
5 | import { JobQueue } from '@server/lib/job-queue' | ||
3 | import { | 6 | import { |
4 | isStreamingPlaylist, | 7 | isStreamingPlaylist, |
5 | MStreamingPlaylistVideo, | 8 | MStreamingPlaylistVideo, |
@@ -12,11 +15,8 @@ import { | |||
12 | MVideoThumbnail, | 15 | MVideoThumbnail, |
13 | MVideoWithRights | 16 | MVideoWithRights |
14 | } from '@server/types/models' | 17 | } from '@server/types/models' |
15 | import { Response } from 'express' | ||
16 | import { DEFAULT_AUDIO_RESOLUTION } from '@server/initializers/constants' | ||
17 | import { JobQueue } from '@server/lib/job-queue' | ||
18 | import { VideoPrivacy, VideoTranscodingPayload } from '@shared/models' | 18 | import { VideoPrivacy, VideoTranscodingPayload } from '@shared/models' |
19 | import { CONFIG } from "@server/initializers/config" | 19 | import { VideoModel } from '../models/video/video' |
20 | 20 | ||
21 | type VideoFetchType = 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none' | 'only-immutable-attributes' | 21 | type VideoFetchType = 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none' | 'only-immutable-attributes' |
22 | 22 | ||
@@ -110,6 +110,14 @@ function getPrivaciesForFederation () { | |||
110 | : [ { privacy: VideoPrivacy.PUBLIC } ] | 110 | : [ { privacy: VideoPrivacy.PUBLIC } ] |
111 | } | 111 | } |
112 | 112 | ||
113 | function getExtFromMimetype (mimeTypes: { [id: string]: string | string[] }, mimeType: string) { | ||
114 | const value = mimeTypes[mimeType] | ||
115 | |||
116 | if (Array.isArray(value)) return value[0] | ||
117 | |||
118 | return value | ||
119 | } | ||
120 | |||
113 | export { | 121 | export { |
114 | VideoFetchType, | 122 | VideoFetchType, |
115 | VideoFetchByUrlType, | 123 | VideoFetchByUrlType, |
@@ -118,6 +126,7 @@ export { | |||
118 | fetchVideoByUrl, | 126 | fetchVideoByUrl, |
119 | addOptimizeOrMergeAudioJob, | 127 | addOptimizeOrMergeAudioJob, |
120 | extractVideo, | 128 | extractVideo, |
129 | getExtFromMimetype, | ||
121 | isPrivacyForFederation, | 130 | isPrivacyForFederation, |
122 | getPrivaciesForFederation | 131 | getPrivaciesForFederation |
123 | } | 132 | } |