diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-06 17:13:39 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-08 09:30:31 +0200 |
commit | ce33919c24e7402d92d81f3cd8e545df52d98240 (patch) | |
tree | 7e131a2f8df649899d0a71294665cf386ffb50d4 /server/helpers/youtube-dl.ts | |
parent | 788487140c500abeb69ca44daf3a9e26efa8d36f (diff) | |
download | PeerTube-ce33919c24e7402d92d81f3cd8e545df52d98240.tar.gz PeerTube-ce33919c24e7402d92d81f3cd8e545df52d98240.tar.zst PeerTube-ce33919c24e7402d92d81f3cd8e545df52d98240.zip |
Import magnets with webtorrent
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 | ||