diff options
author | Andrés Maldonado <amaldona@etu.utc.fr> | 2018-12-11 15:05:42 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-02-12 11:19:19 +0100 |
commit | 4e553a41fdc67c4da186502522ac99a5ba230453 (patch) | |
tree | 116b3d461c496a3bbc011daeec02619a0b1e1c09 | |
parent | 31d065cc50e17a9abf263ed8c606cb272cd4933d (diff) | |
download | PeerTube-4e553a41fdc67c4da186502522ac99a5ba230453.tar.gz PeerTube-4e553a41fdc67c4da186502522ac99a5ba230453.tar.zst PeerTube-4e553a41fdc67c4da186502522ac99a5ba230453.zip |
Import original publication date (web UI)
Import original publication date when importing a video from YouTube in the web UI
-rw-r--r-- | server/controllers/api/videos/import.ts | 3 | ||||
-rw-r--r-- | server/helpers/youtube-dl.ts | 7 | ||||
-rw-r--r-- | shared/models/videos/import/video-import.model.ts | 1 |
3 files changed, 9 insertions, 2 deletions
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts index 7053d5253..626c81eca 100644 --- a/server/controllers/api/videos/import.ts +++ b/server/controllers/api/videos/import.ts | |||
@@ -172,7 +172,8 @@ function buildVideo (channelId: number, body: VideoImportCreate, importData: You | |||
172 | support: body.support || null, | 172 | support: body.support || null, |
173 | privacy: body.privacy || VideoPrivacy.PRIVATE, | 173 | privacy: body.privacy || VideoPrivacy.PRIVATE, |
174 | duration: 0, // duration will be set by the import job | 174 | duration: 0, // duration will be set by the import job |
175 | channelId: channelId | 175 | channelId: channelId, |
176 | originallyPublishedAt: importData.originallyPublishedAt | ||
176 | } | 177 | } |
177 | const video = new VideoModel(videoData) | 178 | const video = new VideoModel(videoData) |
178 | video.url = getVideoActivityPubUrl(video) | 179 | video.url = getVideoActivityPubUrl(video) |
diff --git a/server/helpers/youtube-dl.ts b/server/helpers/youtube-dl.ts index b74351b42..4d4b37ef9 100644 --- a/server/helpers/youtube-dl.ts +++ b/server/helpers/youtube-dl.ts | |||
@@ -16,6 +16,7 @@ export type YoutubeDLInfo = { | |||
16 | nsfw?: boolean | 16 | nsfw?: boolean |
17 | tags?: string[] | 17 | tags?: string[] |
18 | thumbnailUrl?: string | 18 | thumbnailUrl?: string |
19 | originallyPublishedAt?: string | ||
19 | } | 20 | } |
20 | 21 | ||
21 | const processOptions = { | 22 | const processOptions = { |
@@ -173,6 +174,9 @@ function normalizeObject (obj: any) { | |||
173 | } | 174 | } |
174 | 175 | ||
175 | function buildVideoInfo (obj: any) { | 176 | function buildVideoInfo (obj: any) { |
177 | |||
178 | const date = obj.upload_date.slice(0,4)+","+obj.upload_date.slice(4,6)+","+obj.upload_date.slice(6,8) | ||
179 | |||
176 | return { | 180 | return { |
177 | name: titleTruncation(obj.title), | 181 | name: titleTruncation(obj.title), |
178 | description: descriptionTruncation(obj.description), | 182 | description: descriptionTruncation(obj.description), |
@@ -180,7 +184,8 @@ function buildVideoInfo (obj: any) { | |||
180 | licence: getLicence(obj.license), | 184 | licence: getLicence(obj.license), |
181 | nsfw: isNSFW(obj), | 185 | nsfw: isNSFW(obj), |
182 | tags: getTags(obj.tags), | 186 | tags: getTags(obj.tags), |
183 | thumbnailUrl: obj.thumbnail || undefined | 187 | thumbnailUrl: obj.thumbnail || undefined, |
188 | originallyPublishedAt: new Date(date).toISOString() | ||
184 | } | 189 | } |
185 | } | 190 | } |
186 | 191 | ||
diff --git a/shared/models/videos/import/video-import.model.ts b/shared/models/videos/import/video-import.model.ts index e2a56617d..92856c70f 100644 --- a/shared/models/videos/import/video-import.model.ts +++ b/shared/models/videos/import/video-import.model.ts | |||
@@ -11,6 +11,7 @@ export interface VideoImport { | |||
11 | 11 | ||
12 | createdAt: string | 12 | createdAt: string |
13 | updatedAt: string | 13 | updatedAt: string |
14 | originallyPublishedAt?: string | ||
14 | state: VideoConstant<VideoImportState> | 15 | state: VideoConstant<VideoImportState> |
15 | error?: string | 16 | error?: string |
16 | 17 | ||