Import original publication date (web UI)

Import original publication date when importing a video from YouTube in the web UI
This commit is contained in:
Andrés Maldonado 2018-12-11 15:05:42 +01:00 committed by Chocobozzz
parent 31d065cc50
commit 4e553a41fd
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
3 changed files with 9 additions and 2 deletions

View File

@ -172,7 +172,8 @@ function buildVideo (channelId: number, body: VideoImportCreate, importData: You
support: body.support || null, support: body.support || null,
privacy: body.privacy || VideoPrivacy.PRIVATE, privacy: body.privacy || VideoPrivacy.PRIVATE,
duration: 0, // duration will be set by the import job duration: 0, // duration will be set by the import job
channelId: channelId channelId: channelId,
originallyPublishedAt: importData.originallyPublishedAt
} }
const video = new VideoModel(videoData) const video = new VideoModel(videoData)
video.url = getVideoActivityPubUrl(video) video.url = getVideoActivityPubUrl(video)

View File

@ -16,6 +16,7 @@ export type YoutubeDLInfo = {
nsfw?: boolean nsfw?: boolean
tags?: string[] tags?: string[]
thumbnailUrl?: string thumbnailUrl?: string
originallyPublishedAt?: string
} }
const processOptions = { const processOptions = {
@ -173,6 +174,9 @@ function normalizeObject (obj: any) {
} }
function buildVideoInfo (obj: any) { function buildVideoInfo (obj: any) {
const date = obj.upload_date.slice(0,4)+","+obj.upload_date.slice(4,6)+","+obj.upload_date.slice(6,8)
return { return {
name: titleTruncation(obj.title), name: titleTruncation(obj.title),
description: descriptionTruncation(obj.description), description: descriptionTruncation(obj.description),
@ -180,7 +184,8 @@ function buildVideoInfo (obj: any) {
licence: getLicence(obj.license), licence: getLicence(obj.license),
nsfw: isNSFW(obj), nsfw: isNSFW(obj),
tags: getTags(obj.tags), tags: getTags(obj.tags),
thumbnailUrl: obj.thumbnail || undefined thumbnailUrl: obj.thumbnail || undefined,
originallyPublishedAt: new Date(date).toISOString()
} }
} }

View File

@ -11,6 +11,7 @@ export interface VideoImport {
createdAt: string createdAt: string
updatedAt: string updatedAt: string
originallyPublishedAt?: string
state: VideoConstant<VideoImportState> state: VideoConstant<VideoImportState>
error?: string error?: string