X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fyoutube-dl.ts;h=87a0d0584e174ed73ee7c0da721893e60904f38e;hb=5c7d650827cc471a03e7fa18362bcbcbe5d30838;hp=782dd2e2e194dde892a4a73ec21493a4cc5eeb05;hpb=c74c9be934fa1584edf6f4f7a41f00c4d3f2a8b3;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/youtube-dl.ts b/server/helpers/youtube-dl.ts index 782dd2e2e..87a0d0584 100644 --- a/server/helpers/youtube-dl.ts +++ b/server/helpers/youtube-dl.ts @@ -1,10 +1,9 @@ -import { truncate } from 'lodash' -import { CONSTRAINTS_FIELDS, VIDEO_CATEGORIES } from '../initializers' +import { CONSTRAINTS_FIELDS, VIDEO_CATEGORIES } from '../initializers/constants' import { logger } from './logger' import { generateVideoImportTmpPath } from './utils' import { join } from 'path' -import { root } from './core-utils' -import { ensureDir, writeFile, remove } from 'fs-extra' +import { peertubeTruncate, root } from './core-utils' +import { ensureDir, remove, writeFile } from 'fs-extra' import * as request from 'request' import { createWriteStream } from 'fs' @@ -48,6 +47,11 @@ function downloadYoutubeDLVideo (url: string, timeout: number) { const options = [ '-f', 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best', '-o', path ] + if (process.env.FFMPEG_PATH) { + options.push('--ffmpeg-location') + options.push(process.env.FFMPEG_PATH) + } + return new Promise(async (res, rej) => { const youtubeDL = await safeGetYoutubeDL() youtubeDL.exec(url, options, processOptions, err => { @@ -207,20 +211,20 @@ function buildVideoInfo (obj: any) { } function titleTruncation (title: string) { - return truncate(title, { - 'length': CONSTRAINTS_FIELDS.VIDEOS.NAME.max, - 'separator': /,? +/, - 'omission': ' […]' + return peertubeTruncate(title, { + length: CONSTRAINTS_FIELDS.VIDEOS.NAME.max, + separator: /,? +/, + omission: ' […]' }) } function descriptionTruncation (description: string) { if (!description || description.length < CONSTRAINTS_FIELDS.VIDEOS.DESCRIPTION.min) return undefined - return truncate(description, { - 'length': CONSTRAINTS_FIELDS.VIDEOS.DESCRIPTION.max, - 'separator': /,? +/, - 'omission': ' […]' + return peertubeTruncate(description, { + length: CONSTRAINTS_FIELDS.VIDEOS.DESCRIPTION.max, + separator: /,? +/, + omission: ' […]' }) }