nsfw?: boolean
tags?: string[]
thumbnailUrl?: string
- originallyPublishedAt?: string
+ originallyPublishedAt?: Date
}
const processOptions = {
return youtubeDL
}
+function buildOriginallyPublishedAt (obj: any) {
+ let originallyPublishedAt: Date = null
+
+ const uploadDateMatcher = /^(\d{4})(\d{2})(\d{2})$/.exec(obj.upload_date)
+ if (uploadDateMatcher) {
+ originallyPublishedAt = new Date()
+ originallyPublishedAt.setHours(0, 0, 0, 0)
+
+ const year = parseInt(uploadDateMatcher[1], 10)
+ // Month starts from 0
+ const month = parseInt(uploadDateMatcher[2], 10) - 1
+ const day = parseInt(uploadDateMatcher[3], 10)
+
+ originallyPublishedAt.setFullYear(year, month, day)
+ }
+
+ return originallyPublishedAt
+}
+
// ---------------------------------------------------------------------------
export {
updateYoutubeDLBinary,
downloadYoutubeDLVideo,
getYoutubeDLInfo,
- safeGetYoutubeDL
+ safeGetYoutubeDL,
+ buildOriginallyPublishedAt
}
// ---------------------------------------------------------------------------
}
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),
nsfw: isNSFW(obj),
tags: getTags(obj.tags),
thumbnailUrl: obj.thumbnail || undefined,
- originallyPublishedAt: new Date(date).toISOString()
+ originallyPublishedAt: buildOriginallyPublishedAt(obj)
}
}
query('startDate').optional().custom(isDateValid).withMessage('Should have a valid start date'),
query('endDate').optional().custom(isDateValid).withMessage('Should have a valid end date'),
+ query('originallyPublishedStartDate').optional().custom(isDateValid).withMessage('Should have a valid published start date'),
+ query('originallyPublishedEndDate').optional().custom(isDateValid).withMessage('Should have a valid published end date'),
+
query('durationMin').optional().isInt().withMessage('Should have a valid min duration'),
query('durationMax').optional().isInt().withMessage('Should have a valid max duration'),
expect(videoHttp.description).to.equal('this is a super description')
expect(videoHttp.tags).to.deep.equal([ 'tag1', 'tag2' ])
expect(videoHttp.files).to.have.lengthOf(1)
+ expect(videoHttp.originallyPublishedAt).to.equal('2019-01-13T23:00:00.000Z')
const resMagnet = await getVideo(url, idMagnet)
const videoMagnet: VideoDetails = resMagnet.body
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
}, thumbnailfile)
}
- const date = videoInfo.upload_date.slice(0,4) + ',' + videoInfo.upload_date.slice(4,6) + ',' + videoInfo.upload_date.slice(6,8)
+ const originallyPublishedAt = buildOriginallyPublishedAt(videoInfo)
const videoAttributes = {
name: truncate(videoInfo.title, {
fixture: videoPath,
thumbnailfile,
previewfile: thumbnailfile,
- originallyPublishedAt: new Date(date).toISOString()
+ originallyPublishedAt: originallyPublishedAt ? originallyPublishedAt.toISOString() : null
}
console.log('\nUploading on PeerTube video "%s".', videoAttributes.name)
updateAt: string
privacy?: VideoPrivacy
}
- originallyPublishedAt?: string
}
function getVideoCategories (url: string) {