aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-02-15 18:40:24 +0100
committerChocobozzz <me@florianbigard.com>2018-02-15 18:40:24 +0100
commit02988fdc0bdd345bddf89171d258822cab4229d6 (patch)
tree7c8fb4385e9175bc8701588bd9bf1a71c68a3d2c /server
parente33b53abb397fd4d3e7e94829f2099601f03657c (diff)
downloadPeerTube-02988fdc0bdd345bddf89171d258822cab4229d6.tar.gz
PeerTube-02988fdc0bdd345bddf89171d258822cab4229d6.tar.zst
PeerTube-02988fdc0bdd345bddf89171d258822cab4229d6.zip
Fix remote image fetching
Diffstat (limited to 'server')
-rw-r--r--server/helpers/image-utils.ts2
-rw-r--r--server/helpers/requests.ts8
-rw-r--r--server/tools/import-youtube.ts7
-rw-r--r--server/tools/upload.ts4
4 files changed, 14 insertions, 7 deletions
diff --git a/server/helpers/image-utils.ts b/server/helpers/image-utils.ts
index ba57b5812..0065f4210 100644
--- a/server/helpers/image-utils.ts
+++ b/server/helpers/image-utils.ts
@@ -3,7 +3,7 @@ import * as sharp from 'sharp'
3import { unlinkPromise } from './core-utils' 3import { unlinkPromise } from './core-utils'
4 4
5async function processImage ( 5async function processImage (
6 physicalFile: Express.Multer.File, 6 physicalFile: { path: string },
7 destination: string, 7 destination: string,
8 newSize: { width: number, height: number } 8 newSize: { width: number, height: number }
9) { 9) {
diff --git a/server/helpers/requests.ts b/server/helpers/requests.ts
index eb8a12868..64e3ce663 100644
--- a/server/helpers/requests.ts
+++ b/server/helpers/requests.ts
@@ -17,11 +17,13 @@ function doRequest (
17} 17}
18 18
19function doRequestAndSaveToFile (requestOptions: request.CoreOptions & request.UriOptions, destPath: string) { 19function doRequestAndSaveToFile (requestOptions: request.CoreOptions & request.UriOptions, destPath: string) {
20 return new Bluebird<request.RequestResponse>((res, rej) => { 20 return new Bluebird<void>((res, rej) => {
21 const file = createWriteStream(destPath)
22 file.on('finish', () => res())
23
21 request(requestOptions) 24 request(requestOptions)
22 .on('response', response => res(response as request.RequestResponse))
23 .on('error', err => rej(err)) 25 .on('error', err => rej(err))
24 .pipe(createWriteStream(destPath)) 26 .pipe(file)
25 }) 27 })
26} 28}
27 29
diff --git a/server/tools/import-youtube.ts b/server/tools/import-youtube.ts
index 295109cd8..ab91afbc0 100644
--- a/server/tools/import-youtube.ts
+++ b/server/tools/import-youtube.ts
@@ -62,7 +62,7 @@ async function run () {
62 console.log('Will download and upload %d videos.\n', videos.length) 62 console.log('Will download and upload %d videos.\n', videos.length)
63 63
64 for (const video of videos) { 64 for (const video of videos) {
65 await processVideo(video, program['languageCode']) 65 await processVideo(video, program['language'])
66 } 66 }
67 67
68 console.log('I\'m finished!') 68 console.log('I\'m finished!')
@@ -107,7 +107,10 @@ async function uploadVideoOnPeerTube (videoInfo: any, videoPath: string, languag
107 const licence = getLicence(videoInfo.license) 107 const licence = getLicence(videoInfo.license)
108 let tags = [] 108 let tags = []
109 if (Array.isArray(videoInfo.tags)) { 109 if (Array.isArray(videoInfo.tags)) {
110 tags = videoInfo.tags.filter(t => t.length < CONSTRAINTS_FIELDS.VIDEOS.TAG.max).slice(0, 5) 110 tags = videoInfo.tags
111 .filter(t => t.length < CONSTRAINTS_FIELDS.VIDEOS.TAG.max)
112 .map(t => t.normalize())
113 .slice(0, 5)
111 } 114 }
112 115
113 let thumbnailfile 116 let thumbnailfile
diff --git a/server/tools/upload.ts b/server/tools/upload.ts
index de8ff8d26..97e24dc88 100644
--- a/server/tools/upload.ts
+++ b/server/tools/upload.ts
@@ -20,6 +20,7 @@ program
20 .option('-d, --video-description <description>', 'Video description') 20 .option('-d, --video-description <description>', 'Video description')
21 .option('-t, --tags <tags>', 'Video tags', list) 21 .option('-t, --tags <tags>', 'Video tags', list)
22 .option('-b, --thumbnail <thumbnailPath>', 'Thumbnail path') 22 .option('-b, --thumbnail <thumbnailPath>', 'Thumbnail path')
23 .option('-v, --preview <previewPath>', 'Preview path')
23 .option('-f, --file <file>', 'Video absolute file path') 24 .option('-f, --file <file>', 'Video absolute file path')
24 .parse(process.argv) 25 .parse(process.argv)
25 26
@@ -74,7 +75,8 @@ async function run () {
74 tags: program['tags'], 75 tags: program['tags'],
75 commentsEnabled: program['commentsEnabled'], 76 commentsEnabled: program['commentsEnabled'],
76 fixture: program['file'], 77 fixture: program['file'],
77 thumbnailfile: program['thumbnailPath'] 78 thumbnailfile: program['thumbnailPath'],
79 previewfile: program['previewPath']
78 } 80 }
79 81
80 await uploadVideo(program['url'], accessToken, videoAttributes) 82 await uploadVideo(program['url'], accessToken, videoAttributes)