-function buildVideo (channelId: number, body: VideoImportCreate, importData: YoutubeDLInfo) {
- const videoData = {
- name: body.name || importData.name || 'Unknown name',
- remote: false,
- category: body.category || importData.category,
- licence: body.licence || importData.licence,
- language: body.language || undefined,
- commentsEnabled: body.commentsEnabled !== false, // If the value is not "false", the default is "true"
- downloadEnabled: body.downloadEnabled !== false,
- waitTranscoding: body.waitTranscoding || false,
- state: VideoState.TO_IMPORT,
- nsfw: body.nsfw || importData.nsfw || false,
- description: body.description || importData.description,
- support: body.support || null,
- privacy: body.privacy || VideoPrivacy.PRIVATE,
- duration: 0, // duration will be set by the import job
- channelId: channelId,
- originallyPublishedAt: importData.originallyPublishedAt
+ return res.json(videoImport.toFormattedJSON()).end()
+ } catch (err) {
+ logger.error('An error occurred while importing the video %s. ', targetUrl, { err })
+
+ return res.fail({
+ message: err.message,
+ status: statusFromYtDlImportError(err),
+ data: {
+ targetUrl
+ }
+ })