diff options
author | Chocobozzz <me@florianbigard.com> | 2021-01-19 16:28:55 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-01-19 16:36:21 +0100 |
commit | 805b8619c1b8c56e08c927d93293c06e1075b50d (patch) | |
tree | a165d9929c0864ecdbf2ac6e07000ac266aa5d59 /server/helpers/utils.ts | |
parent | d487a997c80fafe6067016c6cd8e8afd6141baa3 (diff) | |
download | PeerTube-805b8619c1b8c56e08c927d93293c06e1075b50d.tar.gz PeerTube-805b8619c1b8c56e08c927d93293c06e1075b50d.tar.zst PeerTube-805b8619c1b8c56e08c927d93293c06e1075b50d.zip |
Fix (again) youtube import
Diffstat (limited to 'server/helpers/utils.ts')
-rw-r--r-- | server/helpers/utils.ts | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts index ad3b7949e..0545e8996 100644 --- a/server/helpers/utils.ts +++ b/server/helpers/utils.ts | |||
@@ -1,11 +1,10 @@ | |||
1 | import { remove } from 'fs-extra' | ||
2 | import { Instance as ParseTorrent } from 'parse-torrent' | ||
3 | import { join } from 'path' | ||
1 | import { ResultList } from '../../shared' | 4 | import { ResultList } from '../../shared' |
5 | import { CONFIG } from '../initializers/config' | ||
2 | import { execPromise, execPromise2, randomBytesPromise, sha256 } from './core-utils' | 6 | import { execPromise, execPromise2, randomBytesPromise, sha256 } from './core-utils' |
3 | import { logger } from './logger' | 7 | import { logger } from './logger' |
4 | import { join } from 'path' | ||
5 | import { Instance as ParseTorrent } from 'parse-torrent' | ||
6 | import { remove } from 'fs-extra' | ||
7 | import { CONFIG } from '../initializers/config' | ||
8 | import { isVideoFileExtnameValid } from './custom-validators/videos' | ||
9 | 8 | ||
10 | function deleteFileAsync (path: string) { | 9 | function deleteFileAsync (path: string) { |
11 | remove(path) | 10 | remove(path) |
@@ -31,16 +30,11 @@ function getFormattedObjects<U, V, T extends FormattableToJSON<U, V>> (objects: | |||
31 | } as ResultList<V> | 30 | } as ResultList<V> |
32 | } | 31 | } |
33 | 32 | ||
34 | function generateVideoImportTmpPath (target: string | ParseTorrent, extensionArg?: string) { | 33 | function generateVideoImportTmpPath (target: string | ParseTorrent, extension = '.mp4') { |
35 | const id = typeof target === 'string' | 34 | const id = typeof target === 'string' |
36 | ? target | 35 | ? target |
37 | : target.infoHash | 36 | : target.infoHash |
38 | 37 | ||
39 | let extension = '.mp4' | ||
40 | if (extensionArg && isVideoFileExtnameValid(extensionArg)) { | ||
41 | extension = extensionArg | ||
42 | } | ||
43 | |||
44 | const hash = sha256(id) | 38 | const hash = sha256(id) |
45 | return join(CONFIG.STORAGE.TMP_DIR, `${hash}-import${extension}`) | 39 | return join(CONFIG.STORAGE.TMP_DIR, `${hash}-import${extension}`) |
46 | } | 40 | } |