Import original publication date (web UI)
authorAndrés Maldonado <amaldona@etu.utc.fr>
Tue, 11 Dec 2018 14:05:42 +0000 (15:05 +0100)
committerChocobozzz <me@florianbigard.com>
Tue, 12 Feb 2019 10:19:19 +0000 (11:19 +0100)
Import original publication date when importing a video from YouTube in the web UI

server/controllers/api/videos/import.ts
server/helpers/youtube-dl.ts
shared/models/videos/import/video-import.model.ts

index 7053d5253c9bc89f56412f38516480ac29edb8ab..626c81ecaf0bee160646e0b0d13b5af1682702d0 100644 (file)
@@ -172,7 +172,8 @@ function buildVideo (channelId: number, body: VideoImportCreate, importData: You
     support: body.support || null,
     privacy: body.privacy || VideoPrivacy.PRIVATE,
     duration: 0, // duration will be set by the import job
-    channelId: channelId
+    channelId: channelId,
+    originallyPublishedAt: importData.originallyPublishedAt
   }
   const video = new VideoModel(videoData)
   video.url = getVideoActivityPubUrl(video)
index b74351b4219a72963c04cfe092c8081a5a7ad63f..4d4b37ef938fcd74249df092b71ada6c0950c7b6 100644 (file)
@@ -16,6 +16,7 @@ export type YoutubeDLInfo = {
   nsfw?: boolean
   tags?: string[]
   thumbnailUrl?: string
+  originallyPublishedAt?: string
 }
 
 const processOptions = {
@@ -173,6 +174,9 @@ function normalizeObject (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 {
     name: titleTruncation(obj.title),
     description: descriptionTruncation(obj.description),
@@ -180,7 +184,8 @@ function buildVideoInfo (obj: any) {
     licence: getLicence(obj.license),
     nsfw: isNSFW(obj),
     tags: getTags(obj.tags),
-    thumbnailUrl: obj.thumbnail || undefined
+    thumbnailUrl: obj.thumbnail || undefined,
+    originallyPublishedAt: new Date(date).toISOString()
   }
 }
 
index e2a56617d6da8d88f687dcc56d2d2e2e2382eb82..92856c70f5262bb3a4f159a9c1c6de3c7e7ecbee 100644 (file)
@@ -11,6 +11,7 @@ export interface VideoImport {
 
   createdAt: string
   updatedAt: string
+  originallyPublishedAt?: string
   state: VideoConstant<VideoImportState>
   error?: string