aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/utils.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/utils.ts
parent1fe654e0963da8c2801561be10de3222055a2497 (diff)
downloadPeerTube-d57d1d83c6a4d98a735b21f4e8e749a5c1e1a479.tar.gz
PeerTube-d57d1d83c6a4d98a735b21f4e8e749a5c1e1a479.tar.zst
PeerTube-d57d1d83c6a4d98a735b21f4e8e749a5c1e1a479.zip
Support audio files import
Diffstat (limited to 'server/helpers/utils.ts')
-rw-r--r--server/helpers/utils.ts14
1 files changed, 11 insertions, 3 deletions
diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts
index 7a4c781cc..11c118292 100644
--- a/server/helpers/utils.ts
+++ b/server/helpers/utils.ts
@@ -7,6 +7,7 @@ import { Instance as ParseTorrent } from 'parse-torrent'
7import { remove } from 'fs-extra' 7import { remove } from 'fs-extra'
8import * as memoizee from 'memoizee' 8import * as memoizee from 'memoizee'
9import { CONFIG } from '../initializers/config' 9import { CONFIG } from '../initializers/config'
10import { isVideoFileExtnameValid } from './custom-validators/videos'
10 11
11function deleteFileAsync (path: string) { 12function deleteFileAsync (path: string) {
12 remove(path) 13 remove(path)
@@ -42,11 +43,18 @@ const getServerActor = memoizee(async function () {
42 return actor 43 return actor
43}, { promise: true }) 44}, { promise: true })
44 45
45function generateVideoImportTmpPath (target: string | ParseTorrent) { 46function generateVideoImportTmpPath (target: string | ParseTorrent, extensionArg?: string) {
46 const id = typeof target === 'string' ? target : target.infoHash 47 const id = typeof target === 'string'
48 ? target
49 : target.infoHash
50
51 let extension = '.mp4'
52 if (extensionArg && isVideoFileExtnameValid(extensionArg)) {
53 extension = extensionArg
54 }
47 55
48 const hash = sha256(id) 56 const hash = sha256(id)
49 return join(CONFIG.STORAGE.TMP_DIR, hash + '-import.mp4') 57 return join(CONFIG.STORAGE.TMP_DIR, `${hash}-import${extension}`)
50} 58}
51 59
52function getSecureTorrentName (originalName: string) { 60function getSecureTorrentName (originalName: string) {