Support thumbnails in youtube import
This commit is contained in:
parent
e3a682a877
commit
1d791a26de
2 changed files with 19 additions and 2 deletions
|
@ -3,7 +3,7 @@
|
||||||
import { expect } from 'chai'
|
import { expect } from 'chai'
|
||||||
import { existsSync, readFile } from 'fs'
|
import { existsSync, readFile } from 'fs'
|
||||||
import * as parseTorrent from 'parse-torrent'
|
import * as parseTorrent from 'parse-torrent'
|
||||||
import { extname, isAbsolute, join } from 'path'
|
import { extname, join } from 'path'
|
||||||
import * as request from 'supertest'
|
import * as request from 'supertest'
|
||||||
import {
|
import {
|
||||||
buildAbsoluteFixturePath,
|
buildAbsoluteFixturePath,
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { join } from 'path'
|
||||||
import * as youtubeDL from 'youtube-dl'
|
import * as youtubeDL from 'youtube-dl'
|
||||||
import { VideoPrivacy } from '../../shared/models/videos'
|
import { VideoPrivacy } from '../../shared/models/videos'
|
||||||
import { unlinkPromise } from '../helpers/core-utils'
|
import { unlinkPromise } from '../helpers/core-utils'
|
||||||
|
import { doRequestAndSaveToFile } from '../helpers/requests'
|
||||||
import { getClient, getVideoCategories, login, searchVideo, uploadVideo } from '../tests/utils'
|
import { getClient, getVideoCategories, login, searchVideo, uploadVideo } from '../tests/utils'
|
||||||
|
|
||||||
program
|
program
|
||||||
|
@ -98,6 +99,16 @@ async function uploadVideoOnPeerTube (videoInfo: any, videoPath: string) {
|
||||||
const licence = getLicence(videoInfo.license)
|
const licence = getLicence(videoInfo.license)
|
||||||
const language = 13
|
const language = 13
|
||||||
|
|
||||||
|
let thumbnailfile
|
||||||
|
if (videoInfo.thumbnail) {
|
||||||
|
thumbnailfile = join(__dirname, 'thumbnail.jpg')
|
||||||
|
|
||||||
|
await doRequestAndSaveToFile({
|
||||||
|
method: 'GET',
|
||||||
|
uri: videoInfo.thumbnail
|
||||||
|
}, thumbnailfile)
|
||||||
|
}
|
||||||
|
|
||||||
const videoAttributes = {
|
const videoAttributes = {
|
||||||
name: videoInfo.title,
|
name: videoInfo.title,
|
||||||
category,
|
category,
|
||||||
|
@ -108,12 +119,18 @@ async function uploadVideoOnPeerTube (videoInfo: any, videoPath: string) {
|
||||||
description: videoInfo.description,
|
description: videoInfo.description,
|
||||||
tags: videoInfo.tags.slice(0, 5),
|
tags: videoInfo.tags.slice(0, 5),
|
||||||
privacy: VideoPrivacy.PUBLIC,
|
privacy: VideoPrivacy.PUBLIC,
|
||||||
fixture: videoPath
|
fixture: videoPath,
|
||||||
|
thumbnailfile
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('\nUploading on PeerTube video "%s".', videoAttributes.name)
|
console.log('\nUploading on PeerTube video "%s".', videoAttributes.name)
|
||||||
await uploadVideo(program['url'], accessToken, videoAttributes)
|
await uploadVideo(program['url'], accessToken, videoAttributes)
|
||||||
|
|
||||||
await unlinkPromise(videoPath)
|
await unlinkPromise(videoPath)
|
||||||
|
if (thumbnailfile) {
|
||||||
|
await unlinkPromise(thumbnailfile)
|
||||||
|
}
|
||||||
|
|
||||||
console.log('Uploaded video "%s"!\n', videoAttributes.name)
|
console.log('Uploaded video "%s"!\n', videoAttributes.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue