X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fvideo.ts;h=488b4da17149118b559664fed007fe5a0760e7b4;hb=2cfd3b7eb945063242459bfb26cd654cd5938891;hp=4bcc6d0b9497e218dc0204aa2a80308cd622ff1f;hpb=3092e9bbb05fe292fd13bc685b89069c3dda55d9;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/video.ts b/server/helpers/video.ts index 4bcc6d0b9..488b4da17 100644 --- a/server/helpers/video.ts +++ b/server/helpers/video.ts @@ -1,5 +1,8 @@ -import { VideoModel } from '../models/video/video' import * as Bluebird from 'bluebird' +import { Response } from 'express' +import { CONFIG } from '@server/initializers/config' +import { DEFAULT_AUDIO_RESOLUTION } from '@server/initializers/constants' +import { JobQueue } from '@server/lib/job-queue' import { isStreamingPlaylist, MStreamingPlaylistVideo, @@ -11,12 +14,9 @@ import { MVideoImmutable, MVideoThumbnail, MVideoWithRights -} from '@server/typings/models' -import { Response } from 'express' -import { DEFAULT_AUDIO_RESOLUTION } from '@server/initializers/constants' -import { JobQueue } from '@server/lib/job-queue' +} from '@server/types/models' import { VideoPrivacy, VideoTranscodingPayload } from '@shared/models' -import { CONFIG } from "@server/initializers/config" +import { VideoModel } from '../models/video/video' type VideoFetchType = 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none' | 'only-immutable-attributes' @@ -110,6 +110,14 @@ function getPrivaciesForFederation () { : [ { privacy: VideoPrivacy.PUBLIC } ] } +function getExtFromMimetype (mimeTypes: { [id: string]: string | string[] }, mimeType: string) { + const value = mimeTypes[mimeType] + + if (Array.isArray(value)) return value[0] + + return value +} + export { VideoFetchType, VideoFetchByUrlType, @@ -118,6 +126,7 @@ export { fetchVideoByUrl, addOptimizeOrMergeAudioJob, extractVideo, + getExtFromMimetype, isPrivacyForFederation, getPrivaciesForFederation }