]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tools/peertube-import-videos.ts
Add default playlist image
[github/Chocobozzz/PeerTube.git] / server / tools / peertube-import-videos.ts
index f50aafc355ecdd1d1347653e53ed3a49fc6a4922..8c4c711f78daf0d4d34624c3ba25b8baf0f008a1 100644 (file)
@@ -5,13 +5,13 @@ import * as program from 'commander'
 import { join } from 'path'
 import { VideoPrivacy } from '../../shared/models/videos'
 import { doRequestAndSaveToFile } from '../helpers/requests'
-import { CONSTRAINTS_FIELDS } from '../initializers'
-import { getClient, getVideoCategories, login, searchVideoWithSort, uploadVideo } from '../../shared/utils/index'
+import { CONSTRAINTS_FIELDS } from '../initializers/constants'
+import { getClient, getVideoCategories, login, searchVideoWithSort, uploadVideo } from '../../shared/extra-utils/index'
 import { truncate } from 'lodash'
 import * as prompt from 'prompt'
 import { remove } from 'fs-extra'
 import { sha256 } from '../helpers/core-utils'
-import { safeGetYoutubeDL } from '../helpers/youtube-dl'
+import { safeGetYoutubeDL, buildOriginallyPublishedAt } from '../helpers/youtube-dl'
 import { getSettings, netrc } from './cli'
 
 let accessToken: string
@@ -212,6 +212,8 @@ async function uploadVideoOnPeerTube (videoInfo: any, videoPath: string, cwd: st
     }, thumbnailfile)
   }
 
+  const originallyPublishedAt = buildOriginallyPublishedAt(videoInfo)
+
   const videoAttributes = {
     name: truncate(videoInfo.title, {
       'length': CONSTRAINTS_FIELDS.VIDEOS.NAME.max,
@@ -224,13 +226,15 @@ async function uploadVideoOnPeerTube (videoInfo: any, videoPath: string, cwd: st
     nsfw: isNSFW(videoInfo),
     waitTranscoding: true,
     commentsEnabled: true,
+    downloadEnabled: true,
     description: videoInfo.description || undefined,
     support: undefined,
     tags,
     privacy: VideoPrivacy.PUBLIC,
     fixture: videoPath,
     thumbnailfile,
-    previewfile: thumbnailfile
+    previewfile: thumbnailfile,
+    originallyPublishedAt: originallyPublishedAt ? originallyPublishedAt.toISOString() : null
   }
 
   console.log('\nUploading on PeerTube video "%s".', videoAttributes.name)