From fbad87b0472f574409f7aa3ae7f8b54927d0cdd6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 2 Aug 2018 15:34:09 +0200 Subject: Add ability to import video with youtube-dl --- server/initializers/constants.ts | 18 ++++++++++++++++-- server/initializers/database.ts | 4 +++- 2 files changed, 19 insertions(+), 3 deletions(-) (limited to 'server/initializers') diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index bec343bb7..fdd772d84 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -8,6 +8,7 @@ import { VideoPrivacy } from '../../shared/models/videos' import { buildPath, isTestInstance, root, sanitizeHost, sanitizeUrl } from '../helpers/core-utils' import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' import { invert } from 'lodash' +import { VideoImportState } from '../../shared/models/videos/video-import-state.enum' // Use a variable to reload the configuration if we need let config: IConfig = require('config') @@ -85,6 +86,7 @@ const JOB_ATTEMPTS: { [ id in JobType ]: number } = { 'activitypub-follow': 5, 'video-file-import': 1, 'video-file': 1, + 'video-import': 1, 'email': 5 } const JOB_CONCURRENCY: { [ id in JobType ]: number } = { @@ -94,6 +96,7 @@ const JOB_CONCURRENCY: { [ id in JobType ]: number } = { 'activitypub-follow': 3, 'video-file-import': 1, 'video-file': 1, + 'video-import': 1, 'email': 5 } const BROADCAST_CONCURRENCY = 10 // How many requests in parallel we do in activitypub-http-broadcast job @@ -248,6 +251,9 @@ const CONSTRAINTS_FIELDS = { } } }, + VIDEO_IMPORTS: { + URL: { min: 3, max: 2000 } // Length + }, VIDEOS: { NAME: { min: 3, max: 120 }, // Length LANGUAGE: { min: 1, max: 10 }, // Length @@ -262,7 +268,7 @@ const CONSTRAINTS_FIELDS = { }, EXTNAME: [ '.mp4', '.ogv', '.webm' ], INFO_HASH: { min: 40, max: 40 }, // Length, info hash is 20 bytes length but we represent it in hexadecimal so 20 * 2 - DURATION: { min: 1 }, // Number + DURATION: { min: 0 }, // Number TAGS: { min: 0, max: 5 }, // Number of total tags TAG: { min: 2, max: 30 }, // Length THUMBNAIL: { min: 2, max: 30 }, @@ -363,7 +369,14 @@ const VIDEO_PRIVACIES = { const VIDEO_STATES = { [VideoState.PUBLISHED]: 'Published', - [VideoState.TO_TRANSCODE]: 'To transcode' + [VideoState.TO_TRANSCODE]: 'To transcode', + [VideoState.TO_IMPORT]: 'To import' +} + +const VIDEO_IMPORT_STATES = { + [VideoImportState.FAILED]: 'Failed', + [VideoImportState.PENDING]: 'Pending', + [VideoImportState.SUCCESS]: 'Success' } const VIDEO_MIMETYPE_EXT = { @@ -585,6 +598,7 @@ export { RATES_LIMIT, VIDEO_EXT_MIMETYPE, JOB_COMPLETED_LIFETIME, + VIDEO_IMPORT_STATES, VIDEO_VIEW_LIFETIME, buildLanguages } diff --git a/server/initializers/database.ts b/server/initializers/database.ts index 21c083084..0be752363 100644 --- a/server/initializers/database.ts +++ b/server/initializers/database.ts @@ -24,6 +24,7 @@ import { VideoTagModel } from '../models/video/video-tag' import { CONFIG } from './constants' import { ScheduleVideoUpdateModel } from '../models/video/schedule-video-update' import { VideoCaptionModel } from '../models/video/video-caption' +import { VideoImportModel } from '../models/video/video-import' require('pg').defaults.parseInt8 = true // Avoid BIGINT to be converted to string @@ -81,7 +82,8 @@ async function initDatabaseModels (silent: boolean) { VideoTagModel, VideoModel, VideoCommentModel, - ScheduleVideoUpdateModel + ScheduleVideoUpdateModel, + VideoImportModel ]) // Check extensions exist in the database -- cgit v1.2.3