aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrés Maldonado <amaldona@etu.utc.fr>2019-01-05 19:55:40 +0100
committerChocobozzz <me@florianbigard.com>2019-02-12 11:19:19 +0100
commit84929846e743f4b5f3971b386ea2c447db8c416f (patch)
treebc774e50d0607137071b6aa23fef88e18dbc9f8c
parent4e553a41fdc67c4da186502522ac99a5ba230453 (diff)
downloadPeerTube-84929846e743f4b5f3971b386ea2c447db8c416f.tar.gz
PeerTube-84929846e743f4b5f3971b386ea2c447db8c416f.tar.zst
PeerTube-84929846e743f4b5f3971b386ea2c447db8c416f.zip
Import original publication date (CLI)
* Import original publication date when importing a video from YouTube using the CLI * Fix lint issues
-rw-r--r--server/helpers/youtube-dl.ts2
-rw-r--r--server/tools/peertube-import-videos.ts5
-rw-r--r--shared/utils/videos/videos.ts5
3 files changed, 10 insertions, 2 deletions
diff --git a/server/helpers/youtube-dl.ts b/server/helpers/youtube-dl.ts
index 4d4b37ef9..a5ab92df0 100644
--- a/server/helpers/youtube-dl.ts
+++ b/server/helpers/youtube-dl.ts
@@ -175,7 +175,7 @@ function normalizeObject (obj: any) {
175 175
176function buildVideoInfo (obj: any) { 176function buildVideoInfo (obj: any) {
177 177
178 const date = obj.upload_date.slice(0,4)+","+obj.upload_date.slice(4,6)+","+obj.upload_date.slice(6,8) 178 const date = obj.upload_date.slice(0,4) + ',' + obj.upload_date.slice(4,6) + ',' + obj.upload_date.slice(6,8)
179 179
180 return { 180 return {
181 name: titleTruncation(obj.title), 181 name: titleTruncation(obj.title),
diff --git a/server/tools/peertube-import-videos.ts b/server/tools/peertube-import-videos.ts
index 151c5a989..4032c5e0d 100644
--- a/server/tools/peertube-import-videos.ts
+++ b/server/tools/peertube-import-videos.ts
@@ -212,6 +212,8 @@ async function uploadVideoOnPeerTube (videoInfo: any, videoPath: string, cwd: st
212 }, thumbnailfile) 212 }, thumbnailfile)
213 } 213 }
214 214
215 const date = videoInfo.upload_date.slice(0,4) + ',' + videoInfo.upload_date.slice(4,6) + ',' + videoInfo.upload_date.slice(6,8)
216
215 const videoAttributes = { 217 const videoAttributes = {
216 name: truncate(videoInfo.title, { 218 name: truncate(videoInfo.title, {
217 'length': CONSTRAINTS_FIELDS.VIDEOS.NAME.max, 219 'length': CONSTRAINTS_FIELDS.VIDEOS.NAME.max,
@@ -231,7 +233,8 @@ async function uploadVideoOnPeerTube (videoInfo: any, videoPath: string, cwd: st
231 privacy: VideoPrivacy.PUBLIC, 233 privacy: VideoPrivacy.PUBLIC,
232 fixture: videoPath, 234 fixture: videoPath,
233 thumbnailfile, 235 thumbnailfile,
234 previewfile: thumbnailfile 236 previewfile: thumbnailfile,
237 originallyPublishedAt: new Date(date).toISOString()
235 } 238 }
236 239
237 console.log('\nUploading on PeerTube video "%s".', videoAttributes.name) 240 console.log('\nUploading on PeerTube video "%s".', videoAttributes.name)
diff --git a/shared/utils/videos/videos.ts b/shared/utils/videos/videos.ts
index 16ecbfe84..92dadfb69 100644
--- a/shared/utils/videos/videos.ts
+++ b/shared/utils/videos/videos.ts
@@ -42,6 +42,7 @@ type VideoAttributes = {
42 updateAt: string 42 updateAt: string
43 privacy?: VideoPrivacy 43 privacy?: VideoPrivacy
44 } 44 }
45 originallyPublishedAt?: string
45} 46}
46 47
47function getVideoCategories (url: string) { 48function getVideoCategories (url: string) {
@@ -373,6 +374,10 @@ async function uploadVideo (url: string, accessToken: string, videoAttributesArg
373 } 374 }
374 } 375 }
375 376
377 if (attributes.originallyPublishedAt !== undefined) {
378 req.field('originallyPublishedAt', attributes.originallyPublishedAt)
379 }
380
376 return req.attach('videofile', buildAbsoluteFixturePath(attributes.fixture)) 381 return req.attach('videofile', buildAbsoluteFixturePath(attributes.fixture))
377 .expect(specialStatus) 382 .expect(specialStatus)
378} 383}