aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/youtube-dl.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-04-03 15:41:39 +0200
committerChocobozzz <me@florianbigard.com>2020-04-03 15:41:39 +0200
commitd57d1d83c6a4d98a735b21f4e8e749a5c1e1a479 (patch)
treed625ca7c2c626fcf186bb55c6852c1e5a7b51c9e /server/helpers/youtube-dl.ts
parent1fe654e0963da8c2801561be10de3222055a2497 (diff)
downloadPeerTube-d57d1d83c6a4d98a735b21f4e8e749a5c1e1a479.tar.gz
PeerTube-d57d1d83c6a4d98a735b21f4e8e749a5c1e1a479.tar.zst
PeerTube-d57d1d83c6a4d98a735b21f4e8e749a5c1e1a479.zip
Support audio files import
Diffstat (limited to 'server/helpers/youtube-dl.ts')
-rw-r--r--server/helpers/youtube-dl.ts10
1 files changed, 6 insertions, 4 deletions
diff --git a/server/helpers/youtube-dl.ts b/server/helpers/youtube-dl.ts
index 26dbe6543..07c85797a 100644
--- a/server/helpers/youtube-dl.ts
+++ b/server/helpers/youtube-dl.ts
@@ -16,6 +16,7 @@ export type YoutubeDLInfo = {
16 nsfw?: boolean 16 nsfw?: boolean
17 tags?: string[] 17 tags?: string[]
18 thumbnailUrl?: string 18 thumbnailUrl?: string
19 fileExt?: string
19 originallyPublishedAt?: Date 20 originallyPublishedAt?: Date
20} 21}
21 22
@@ -44,11 +45,11 @@ function getYoutubeDLInfo (url: string, opts?: string[]): Promise<YoutubeDLInfo>
44 }) 45 })
45} 46}
46 47
47function downloadYoutubeDLVideo (url: string, timeout: number) { 48function downloadYoutubeDLVideo (url: string, extension: string, timeout: number) {
48 const path = generateVideoImportTmpPath(url) 49 const path = generateVideoImportTmpPath(url, extension)
49 let timer 50 let timer
50 51
51 logger.info('Importing youtubeDL video %s', url) 52 logger.info('Importing youtubeDL video %s to %s', url, path)
52 53
53 let options = [ '-f', 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best', '-o', path ] 54 let options = [ '-f', 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best', '-o', path ]
54 options = wrapWithProxyOptions(options) 55 options = wrapWithProxyOptions(options)
@@ -219,7 +220,8 @@ function buildVideoInfo (obj: any) {
219 nsfw: isNSFW(obj), 220 nsfw: isNSFW(obj),
220 tags: getTags(obj.tags), 221 tags: getTags(obj.tags),
221 thumbnailUrl: obj.thumbnail || undefined, 222 thumbnailUrl: obj.thumbnail || undefined,
222 originallyPublishedAt: buildOriginallyPublishedAt(obj) 223 originallyPublishedAt: buildOriginallyPublishedAt(obj),
224 fileExt: obj.ext
223 } 225 }
224} 226}
225 227