diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-21 15:51:30 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-21 15:51:30 +0200 |
commit | a24bd1ed41b43790bab6ba789580bb4e85f07d85 (patch) | |
tree | a54b0f6c921ba83a6e909cd0ced325b2d4b8863c /server/tools/peertube-upload.ts | |
parent | 5f26f13b3c16ac5ae0a3b0a7142d84a9528cf565 (diff) | |
parent | c63830f15403ac4e750829f27d8bbbdc9a59282c (diff) | |
download | PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.gz PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.zst PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.zip |
Merge branch 'next' into develop
Diffstat (limited to 'server/tools/peertube-upload.ts')
-rw-r--r-- | server/tools/peertube-upload.ts | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/server/tools/peertube-upload.ts b/server/tools/peertube-upload.ts index 02edbd809..01fb1fe8d 100644 --- a/server/tools/peertube-upload.ts +++ b/server/tools/peertube-upload.ts | |||
@@ -4,9 +4,7 @@ registerTSPaths() | |||
4 | import { program } from 'commander' | 4 | import { program } from 'commander' |
5 | import { access, constants } from 'fs-extra' | 5 | import { access, constants } from 'fs-extra' |
6 | import { isAbsolute } from 'path' | 6 | import { isAbsolute } from 'path' |
7 | import { getAccessToken } from '../../shared/extra-utils' | 7 | import { assignToken, buildCommonVideoOptions, buildServer, buildVideoAttributesFromCommander, getServerCredentials } from './cli' |
8 | import { uploadVideo } from '../../shared/extra-utils/' | ||
9 | import { buildCommonVideoOptions, buildVideoAttributesFromCommander, getServerCredentials } from './cli' | ||
10 | 8 | ||
11 | let command = program | 9 | let command = program |
12 | .name('upload') | 10 | .name('upload') |
@@ -46,22 +44,25 @@ getServerCredentials(command) | |||
46 | .catch(err => console.error(err)) | 44 | .catch(err => console.error(err)) |
47 | 45 | ||
48 | async function run (url: string, username: string, password: string) { | 46 | async function run (url: string, username: string, password: string) { |
49 | const accessToken = await getAccessToken(url, username, password) | 47 | const server = buildServer(url) |
48 | await assignToken(server, username, password) | ||
50 | 49 | ||
51 | await access(options.file, constants.F_OK) | 50 | await access(options.file, constants.F_OK) |
52 | 51 | ||
53 | console.log('Uploading %s video...', options.videoName) | 52 | console.log('Uploading %s video...', options.videoName) |
54 | 53 | ||
55 | const videoAttributes = await buildVideoAttributesFromCommander(url, program) | 54 | const baseAttributes = await buildVideoAttributesFromCommander(server, program) |
55 | |||
56 | const attributes = { | ||
57 | ...baseAttributes, | ||
56 | 58 | ||
57 | Object.assign(videoAttributes, { | ||
58 | fixture: options.file, | 59 | fixture: options.file, |
59 | thumbnailfile: options.thumbnail, | 60 | thumbnailfile: options.thumbnail, |
60 | previewfile: options.preview | 61 | previewfile: options.preview |
61 | }) | 62 | } |
62 | 63 | ||
63 | try { | 64 | try { |
64 | await uploadVideo(url, accessToken, videoAttributes) | 65 | await server.videos.upload({ attributes }) |
65 | console.log(`Video ${options.videoName} uploaded.`) | 66 | console.log(`Video ${options.videoName} uploaded.`) |
66 | process.exit(0) | 67 | process.exit(0) |
67 | } catch (err) { | 68 | } catch (err) { |