From 9b474844e85cce916370693cc24f53339a695570 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 19 Jul 2019 10:37:35 +0200 Subject: Add CLI plugins tests --- shared/extra-utils/users/users.ts | 21 ++++++----- shared/models/videos/video-resolution.enum.ts | 53 +++++++++++++++------------ 2 files changed, 41 insertions(+), 33 deletions(-) (limited to 'shared') diff --git a/shared/extra-utils/users/users.ts b/shared/extra-utils/users/users.ts index 5fa8cde0c..30ed1bf4a 100644 --- a/shared/extra-utils/users/users.ts +++ b/shared/extra-utils/users/users.ts @@ -6,6 +6,7 @@ import { UserRegister } from '../../models/users/user-register.model' import { UserRole } from '../../models/users/user-role' import { ServerInfo } from '../server/servers' import { userLogin } from './login' +import { UserUpdateMe } from '../../models/users' type CreateUserArgs = { url: string, accessToken: string, @@ -224,19 +225,21 @@ function updateMyUser (options: { displayName?: string description?: string videosHistoryEnabled?: boolean + theme?: string }) { const path = '/api/v1/users/me' - const toSend = {} - if (options.currentPassword !== undefined && options.currentPassword !== null) toSend['currentPassword'] = options.currentPassword - if (options.newPassword !== undefined && options.newPassword !== null) toSend['password'] = options.newPassword - if (options.nsfwPolicy !== undefined && options.nsfwPolicy !== null) toSend['nsfwPolicy'] = options.nsfwPolicy - if (options.autoPlayVideo !== undefined && options.autoPlayVideo !== null) toSend['autoPlayVideo'] = options.autoPlayVideo - if (options.email !== undefined && options.email !== null) toSend['email'] = options.email - if (options.description !== undefined && options.description !== null) toSend['description'] = options.description - if (options.displayName !== undefined && options.displayName !== null) toSend['displayName'] = options.displayName + const toSend: UserUpdateMe = {} + if (options.currentPassword !== undefined && options.currentPassword !== null) toSend.currentPassword = options.currentPassword + if (options.newPassword !== undefined && options.newPassword !== null) toSend.password = options.newPassword + if (options.nsfwPolicy !== undefined && options.nsfwPolicy !== null) toSend.nsfwPolicy = options.nsfwPolicy + if (options.autoPlayVideo !== undefined && options.autoPlayVideo !== null) toSend.autoPlayVideo = options.autoPlayVideo + if (options.email !== undefined && options.email !== null) toSend.email = options.email + if (options.description !== undefined && options.description !== null) toSend.description = options.description + if (options.displayName !== undefined && options.displayName !== null) toSend.displayName = options.displayName + if (options.theme !== undefined && options.theme !== null) toSend.theme = options.theme if (options.videosHistoryEnabled !== undefined && options.videosHistoryEnabled !== null) { - toSend['videosHistoryEnabled'] = options.videosHistoryEnabled + toSend.videosHistoryEnabled = options.videosHistoryEnabled } return makePutBodyRequest({ diff --git a/shared/models/videos/video-resolution.enum.ts b/shared/models/videos/video-resolution.enum.ts index 51efa2e8b..fa26fc3cc 100644 --- a/shared/models/videos/video-resolution.enum.ts +++ b/shared/models/videos/video-resolution.enum.ts @@ -18,30 +18,35 @@ export enum VideoResolution { */ function getBaseBitrate (resolution: VideoResolution) { switch (resolution) { - case VideoResolution.H_240P: - // quality according to Google Live Encoder: 300 - 700 Kbps - // Quality according to YouTube Video Info: 186 Kbps - return 250 * 1000 - case VideoResolution.H_360P: - // quality according to Google Live Encoder: 400 - 1,000 Kbps - // Quality according to YouTube Video Info: 480 Kbps - return 500 * 1000 - case VideoResolution.H_480P: - // quality according to Google Live Encoder: 500 - 2,000 Kbps - // Quality according to YouTube Video Info: 879 Kbps - return 900 * 1000 - case VideoResolution.H_720P: - // quality according to Google Live Encoder: 1,500 - 4,000 Kbps - // Quality according to YouTube Video Info: 1752 Kbps - return 1750 * 1000 - case VideoResolution.H_1080P: - // quality according to Google Live Encoder: 3000 - 6000 Kbps - // Quality according to YouTube Video Info: 3277 Kbps - return 3300 * 1000 - case VideoResolution.H_4K: // fallthrough - default: - // quality according to Google Live Encoder: 13000 - 34000 Kbps - return 15000 * 1000 + case VideoResolution.H_240P: + // quality according to Google Live Encoder: 300 - 700 Kbps + // Quality according to YouTube Video Info: 186 Kbps + return 250 * 1000 + + case VideoResolution.H_360P: + // quality according to Google Live Encoder: 400 - 1,000 Kbps + // Quality according to YouTube Video Info: 480 Kbps + return 500 * 1000 + + case VideoResolution.H_480P: + // quality according to Google Live Encoder: 500 - 2,000 Kbps + // Quality according to YouTube Video Info: 879 Kbps + return 900 * 1000 + + case VideoResolution.H_720P: + // quality according to Google Live Encoder: 1,500 - 4,000 Kbps + // Quality according to YouTube Video Info: 1752 Kbps + return 1750 * 1000 + + case VideoResolution.H_1080P: + // quality according to Google Live Encoder: 3000 - 6000 Kbps + // Quality according to YouTube Video Info: 3277 Kbps + return 3300 * 1000 + + case VideoResolution.H_4K: // fallthrough + default: + // quality according to Google Live Encoder: 13000 - 34000 Kbps + return 15000 * 1000 } } -- cgit v1.2.3