From 9639bd175726b73f8fe664b5ced12a72407b1f0b Mon Sep 17 00:00:00 2001 From: buoyantair Date: Mon, 29 Oct 2018 22:18:31 +0530 Subject: Move utils to /shared Move utils used by /server/tools/* & /server/tests/**/* into /shared folder. Issue: #1336 --- server/tools/peertube-get-access-token.ts | 2 +- server/tools/peertube-import-videos.ts | 2 +- server/tools/peertube-upload.ts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'server/tools') diff --git a/server/tools/peertube-get-access-token.ts b/server/tools/peertube-get-access-token.ts index eb2571a03..a68665f5b 100644 --- a/server/tools/peertube-get-access-token.ts +++ b/server/tools/peertube-get-access-token.ts @@ -6,7 +6,7 @@ import { Server, Client, User -} from '../tests/utils/index' +} from '../../shared/utils' program .option('-u, --url ', 'Server url') diff --git a/server/tools/peertube-import-videos.ts b/server/tools/peertube-import-videos.ts index 21505b79d..1fe0a9348 100644 --- a/server/tools/peertube-import-videos.ts +++ b/server/tools/peertube-import-videos.ts @@ -6,7 +6,7 @@ import { join } from 'path' import { VideoPrivacy } from '../../shared/models/videos' import { doRequestAndSaveToFile } from '../helpers/requests' import { CONSTRAINTS_FIELDS } from '../initializers' -import { getClient, getVideoCategories, login, searchVideoWithSort, uploadVideo } from '../tests/utils' +import { getClient, getVideoCategories, login, searchVideoWithSort, uploadVideo } from '../../shared/utils/index' import { truncate } from 'lodash' import * as prompt from 'prompt' import { remove } from 'fs-extra' diff --git a/server/tools/peertube-upload.ts b/server/tools/peertube-upload.ts index 6248fb47d..cc7bd9b4c 100644 --- a/server/tools/peertube-upload.ts +++ b/server/tools/peertube-upload.ts @@ -1,8 +1,8 @@ import * as program from 'commander' import { access, constants } from 'fs-extra' import { isAbsolute } from 'path' -import { getClient, login } from '../tests/utils' -import { uploadVideo } from '../tests/utils/index' +import { getClient, login } from '../../shared/utils' +import { uploadVideo } from '../../shared/utils/' import { VideoPrivacy } from '../../shared/models/videos' import { netrc, getSettings } from './cli' -- cgit v1.2.3 From ab4dbe36579f6d92511e78cae2762c49a97001fe Mon Sep 17 00:00:00 2001 From: HesioZ Date: Sat, 15 Dec 2018 01:43:04 +0100 Subject: Remove the eventual trailing '/' at the end of urls (see #1453) (#1480) remove eventual trailing '/' at the end of urls in import script (see #1453) --- server/tools/peertube-import-videos.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'server/tools') diff --git a/server/tools/peertube-import-videos.ts b/server/tools/peertube-import-videos.ts index 1fe0a9348..2874a2131 100644 --- a/server/tools/peertube-import-videos.ts +++ b/server/tools/peertube-import-videos.ts @@ -58,6 +58,7 @@ getSettings() settings.remotes[settings.default] : settings.remotes[0] } + if (!program['username']) program['username'] = netrc.machines[program['url']].login if (!program['password']) program['password'] = netrc.machines[program['url']].password } @@ -69,6 +70,9 @@ getSettings() process.exit(-1) } + removeEndSlashes(program['url']) + removeEndSlashes(program['targetUrl']) + const user = { username: program['username'], password: program['password'] @@ -321,3 +325,9 @@ function isNSFW (info: any) { return false } + +function removeEndSlashes (url: string) { + while (url.endsWith('/')) { + url.slice(0, -1) + } +} -- cgit v1.2.3 From bb8f7872f5a473c47a688b0c282ff34cd78a9835 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 14 Jan 2019 11:01:40 +0100 Subject: Fix peertube CLI documentation --- server/tools/peertube-import-videos.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'server/tools') diff --git a/server/tools/peertube-import-videos.ts b/server/tools/peertube-import-videos.ts index 2874a2131..f50aafc35 100644 --- a/server/tools/peertube-import-videos.ts +++ b/server/tools/peertube-import-videos.ts @@ -78,7 +78,11 @@ getSettings() password: program['password'] } - run(user, program['url']).catch(err => console.error(err)) + run(user, program['url']) + .catch(err => { + console.error(err) + process.exit(-1) + }) }) async function promptPassword () { @@ -112,8 +116,12 @@ async function run (user, url: string) { secret: res.body.client_secret } - const res2 = await login(url, client, user) - accessToken = res2.body.access_token + try { + const res = await login(program[ 'url' ], client, user) + accessToken = res.body.access_token + } catch (err) { + throw new Error('Cannot authenticate. Please check your username/password.') + } const youtubeDL = await safeGetYoutubeDL() -- cgit v1.2.3