aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/youtube-dl.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/youtube-dl.ts')
-rw-r--r--server/helpers/youtube-dl.ts24
1 files changed, 11 insertions, 13 deletions
diff --git a/server/helpers/youtube-dl.ts b/server/helpers/youtube-dl.ts
index c59ab9de0..77986f407 100644
--- a/server/helpers/youtube-dl.ts
+++ b/server/helpers/youtube-dl.ts
@@ -1,18 +1,17 @@
1import * as youtubeDL from 'youtube-dl' 1import * as youtubeDL from 'youtube-dl'
2import { truncate } from 'lodash' 2import { truncate } from 'lodash'
3import { CONFIG, CONSTRAINTS_FIELDS, VIDEO_CATEGORIES } from '../initializers' 3import { CONSTRAINTS_FIELDS, VIDEO_CATEGORIES } from '../initializers'
4import { join } from 'path'
5import * as crypto from 'crypto'
6import { logger } from './logger' 4import { logger } from './logger'
5import { generateVideoTmpPath } from './utils'
7 6
8export type YoutubeDLInfo = { 7export type YoutubeDLInfo = {
9 name: string 8 name?: string
10 description: string 9 description?: string
11 category: number 10 category?: number
12 licence: number 11 licence?: number
13 nsfw: boolean 12 nsfw?: boolean
14 tags: string[] 13 tags?: string[]
15 thumbnailUrl: string 14 thumbnailUrl?: string
16} 15}
17 16
18function getYoutubeDLInfo (url: string): Promise<YoutubeDLInfo> { 17function getYoutubeDLInfo (url: string): Promise<YoutubeDLInfo> {
@@ -30,10 +29,9 @@ function getYoutubeDLInfo (url: string): Promise<YoutubeDLInfo> {
30} 29}
31 30
32function downloadYoutubeDLVideo (url: string) { 31function downloadYoutubeDLVideo (url: string) {
33 const hash = crypto.createHash('sha256').update(url).digest('hex') 32 const path = generateVideoTmpPath(url)
34 const path = join(CONFIG.STORAGE.VIDEOS_DIR, hash + '-import.mp4')
35 33
36 logger.info('Importing video %s', url) 34 logger.info('Importing youtubeDL video %s', url)
37 35
38 const options = [ '-f', 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best', '-o', path ] 36 const options = [ '-f', 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best', '-o', path ]
39 37