mirror of https://github.com/Chocobozzz/PeerTube
Fix remote image fetching
parent
e33b53abb3
commit
02988fdc0b
|
@ -3,7 +3,7 @@ import * as sharp from 'sharp'
|
||||||
import { unlinkPromise } from './core-utils'
|
import { unlinkPromise } from './core-utils'
|
||||||
|
|
||||||
async function processImage (
|
async function processImage (
|
||||||
physicalFile: Express.Multer.File,
|
physicalFile: { path: string },
|
||||||
destination: string,
|
destination: string,
|
||||||
newSize: { width: number, height: number }
|
newSize: { width: number, height: number }
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -17,11 +17,13 @@ function doRequest (
|
||||||
}
|
}
|
||||||
|
|
||||||
function doRequestAndSaveToFile (requestOptions: request.CoreOptions & request.UriOptions, destPath: string) {
|
function doRequestAndSaveToFile (requestOptions: request.CoreOptions & request.UriOptions, destPath: string) {
|
||||||
return new Bluebird<request.RequestResponse>((res, rej) => {
|
return new Bluebird<void>((res, rej) => {
|
||||||
|
const file = createWriteStream(destPath)
|
||||||
|
file.on('finish', () => res())
|
||||||
|
|
||||||
request(requestOptions)
|
request(requestOptions)
|
||||||
.on('response', response => res(response as request.RequestResponse))
|
|
||||||
.on('error', err => rej(err))
|
.on('error', err => rej(err))
|
||||||
.pipe(createWriteStream(destPath))
|
.pipe(file)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ async function run () {
|
||||||
console.log('Will download and upload %d videos.\n', videos.length)
|
console.log('Will download and upload %d videos.\n', videos.length)
|
||||||
|
|
||||||
for (const video of videos) {
|
for (const video of videos) {
|
||||||
await processVideo(video, program['languageCode'])
|
await processVideo(video, program['language'])
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('I\'m finished!')
|
console.log('I\'m finished!')
|
||||||
|
@ -107,7 +107,10 @@ async function uploadVideoOnPeerTube (videoInfo: any, videoPath: string, languag
|
||||||
const licence = getLicence(videoInfo.license)
|
const licence = getLicence(videoInfo.license)
|
||||||
let tags = []
|
let tags = []
|
||||||
if (Array.isArray(videoInfo.tags)) {
|
if (Array.isArray(videoInfo.tags)) {
|
||||||
tags = videoInfo.tags.filter(t => t.length < CONSTRAINTS_FIELDS.VIDEOS.TAG.max).slice(0, 5)
|
tags = videoInfo.tags
|
||||||
|
.filter(t => t.length < CONSTRAINTS_FIELDS.VIDEOS.TAG.max)
|
||||||
|
.map(t => t.normalize())
|
||||||
|
.slice(0, 5)
|
||||||
}
|
}
|
||||||
|
|
||||||
let thumbnailfile
|
let thumbnailfile
|
||||||
|
|
|
@ -20,6 +20,7 @@ program
|
||||||
.option('-d, --video-description <description>', 'Video description')
|
.option('-d, --video-description <description>', 'Video description')
|
||||||
.option('-t, --tags <tags>', 'Video tags', list)
|
.option('-t, --tags <tags>', 'Video tags', list)
|
||||||
.option('-b, --thumbnail <thumbnailPath>', 'Thumbnail path')
|
.option('-b, --thumbnail <thumbnailPath>', 'Thumbnail path')
|
||||||
|
.option('-v, --preview <previewPath>', 'Preview path')
|
||||||
.option('-f, --file <file>', 'Video absolute file path')
|
.option('-f, --file <file>', 'Video absolute file path')
|
||||||
.parse(process.argv)
|
.parse(process.argv)
|
||||||
|
|
||||||
|
@ -74,7 +75,8 @@ async function run () {
|
||||||
tags: program['tags'],
|
tags: program['tags'],
|
||||||
commentsEnabled: program['commentsEnabled'],
|
commentsEnabled: program['commentsEnabled'],
|
||||||
fixture: program['file'],
|
fixture: program['file'],
|
||||||
thumbnailfile: program['thumbnailPath']
|
thumbnailfile: program['thumbnailPath'],
|
||||||
|
previewfile: program['previewPath']
|
||||||
}
|
}
|
||||||
|
|
||||||
await uploadVideo(program['url'], accessToken, videoAttributes)
|
await uploadVideo(program['url'], accessToken, videoAttributes)
|
||||||
|
|
Loading…
Reference in New Issue