diff options
Diffstat (limited to 'server/helpers/youtube-dl.ts')
-rw-r--r-- | server/helpers/youtube-dl.ts | 24 |
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 @@ | |||
1 | import * as youtubeDL from 'youtube-dl' | 1 | import * as youtubeDL from 'youtube-dl' |
2 | import { truncate } from 'lodash' | 2 | import { truncate } from 'lodash' |
3 | import { CONFIG, CONSTRAINTS_FIELDS, VIDEO_CATEGORIES } from '../initializers' | 3 | import { CONSTRAINTS_FIELDS, VIDEO_CATEGORIES } from '../initializers' |
4 | import { join } from 'path' | ||
5 | import * as crypto from 'crypto' | ||
6 | import { logger } from './logger' | 4 | import { logger } from './logger' |
5 | import { generateVideoTmpPath } from './utils' | ||
7 | 6 | ||
8 | export type YoutubeDLInfo = { | 7 | export 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 | ||
18 | function getYoutubeDLInfo (url: string): Promise<YoutubeDLInfo> { | 17 | function getYoutubeDLInfo (url: string): Promise<YoutubeDLInfo> { |
@@ -30,10 +29,9 @@ function getYoutubeDLInfo (url: string): Promise<YoutubeDLInfo> { | |||
30 | } | 29 | } |
31 | 30 | ||
32 | function downloadYoutubeDLVideo (url: string) { | 31 | function 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 | ||