diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/benchmark.ts | 17 | ||||
-rwxr-xr-x | scripts/build/client.sh | 1 | ||||
-rwxr-xr-x | scripts/ci.sh | 6 | ||||
-rwxr-xr-x | scripts/create-transcoding-job.ts | 2 | ||||
-rw-r--r-- | scripts/migrations/peertube-4.2.ts | 123 | ||||
-rw-r--r-- | scripts/print-transcode-command.ts | 8 | ||||
-rwxr-xr-x | scripts/test.sh | 1 |
7 files changed, 151 insertions, 7 deletions
diff --git a/scripts/benchmark.ts b/scripts/benchmark.ts index 3c3c666a1..c9486eb37 100644 --- a/scripts/benchmark.ts +++ b/scripts/benchmark.ts | |||
@@ -1,4 +1,5 @@ | |||
1 | import autocannon, { printResult } from 'autocannon' | 1 | import autocannon, { printResult } from 'autocannon' |
2 | import { program } from 'commander' | ||
2 | import { writeJson } from 'fs-extra' | 3 | import { writeJson } from 'fs-extra' |
3 | import { Video, VideoPrivacy } from '@shared/models' | 4 | import { Video, VideoPrivacy } from '@shared/models' |
4 | import { createSingleServer, killallServers, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' | 5 | import { createSingleServer, killallServers, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' |
@@ -7,7 +8,15 @@ let server: PeerTubeServer | |||
7 | let video: Video | 8 | let video: Video |
8 | let threadId: number | 9 | let threadId: number |
9 | 10 | ||
10 | const outfile = process.argv[2] | 11 | program |
12 | .option('-o, --outfile [outfile]', 'Outfile') | ||
13 | .option('--grep [string]', 'Filter tests you want to execute') | ||
14 | .description('Run API REST benchmark') | ||
15 | .parse(process.argv) | ||
16 | |||
17 | const options = program.opts() | ||
18 | |||
19 | const outfile = options.outfile | ||
11 | 20 | ||
12 | run() | 21 | run() |
13 | .catch(err => console.error(err)) | 22 | .catch(err => console.error(err)) |
@@ -135,7 +144,11 @@ async function run () { | |||
135 | return status === 200 && body.startsWith('{"client":') | 144 | return status === 200 && body.startsWith('{"client":') |
136 | } | 145 | } |
137 | } | 146 | } |
138 | ] | 147 | ].filter(t => { |
148 | if (!options.grep) return true | ||
149 | |||
150 | return t.title.includes(options.grep) | ||
151 | }) | ||
139 | 152 | ||
140 | const finalResult: any[] = [] | 153 | const finalResult: any[] = [] |
141 | 154 | ||
diff --git a/scripts/build/client.sh b/scripts/build/client.sh index bae91a2b6..f4f9b1352 100755 --- a/scripts/build/client.sh +++ b/scripts/build/client.sh | |||
@@ -8,6 +8,7 @@ defaultLanguage="en-US" | |||
8 | # Supported languages | 8 | # Supported languages |
9 | languages=( | 9 | languages=( |
10 | ["ar"]="ar" | 10 | ["ar"]="ar" |
11 | ["fa"]="fa-IR" | ||
11 | ["en"]="en-US" | 12 | ["en"]="en-US" |
12 | ["vi"]="vi-VN" | 13 | ["vi"]="vi-VN" |
13 | ["hu"]="hu-HU" | 14 | ["hu"]="hu-HU" |
diff --git a/scripts/ci.sh b/scripts/ci.sh index 2bacf2a2e..5f1230d33 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh | |||
@@ -94,6 +94,12 @@ elif [ "$1" = "api-4" ]; then | |||
94 | activitypubFiles=$(findTestFiles ./dist/server/tests/api/activitypub) | 94 | activitypubFiles=$(findTestFiles ./dist/server/tests/api/activitypub) |
95 | 95 | ||
96 | MOCHA_PARALLEL=true runTest "$1" 2 $moderationFiles $redundancyFiles $activitypubFiles $objectStorageFiles | 96 | MOCHA_PARALLEL=true runTest "$1" 2 $moderationFiles $redundancyFiles $activitypubFiles $objectStorageFiles |
97 | elif [ "$1" = "api-5" ]; then | ||
98 | npm run build:server | ||
99 | |||
100 | transcodingFiles=$(findTestFiles ./dist/server/tests/api/transcoding) | ||
101 | |||
102 | MOCHA_PARALLEL=true runTest "$1" 2 $transcodingFiles | ||
97 | elif [ "$1" = "external-plugins" ]; then | 103 | elif [ "$1" = "external-plugins" ]; then |
98 | npm run build:server | 104 | npm run build:server |
99 | 105 | ||
diff --git a/scripts/create-transcoding-job.ts b/scripts/create-transcoding-job.ts index c4b376431..59fc84ad5 100755 --- a/scripts/create-transcoding-job.ts +++ b/scripts/create-transcoding-job.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { program } from 'commander' | 1 | import { program } from 'commander' |
2 | import { isUUIDValid, toCompleteUUID } from '@server/helpers/custom-validators/misc' | 2 | import { isUUIDValid, toCompleteUUID } from '@server/helpers/custom-validators/misc' |
3 | import { computeLowerResolutionsToTranscode } from '@server/helpers/ffprobe-utils' | 3 | import { computeLowerResolutionsToTranscode } from '@server/helpers/ffmpeg' |
4 | import { CONFIG } from '@server/initializers/config' | 4 | import { CONFIG } from '@server/initializers/config' |
5 | import { addTranscodingJob } from '@server/lib/video' | 5 | import { addTranscodingJob } from '@server/lib/video' |
6 | import { VideoState, VideoTranscodingPayload } from '@shared/models' | 6 | import { VideoState, VideoTranscodingPayload } from '@shared/models' |
diff --git a/scripts/migrations/peertube-4.2.ts b/scripts/migrations/peertube-4.2.ts new file mode 100644 index 000000000..22f9ff9f0 --- /dev/null +++ b/scripts/migrations/peertube-4.2.ts | |||
@@ -0,0 +1,123 @@ | |||
1 | import { minBy } from 'lodash' | ||
2 | import { join } from 'path' | ||
3 | import { getImageSize, processImage } from '@server/helpers/image-utils' | ||
4 | import { CONFIG } from '@server/initializers/config' | ||
5 | import { ACTOR_IMAGES_SIZE } from '@server/initializers/constants' | ||
6 | import { updateActorImages } from '@server/lib/activitypub/actors' | ||
7 | import { sendUpdateActor } from '@server/lib/activitypub/send' | ||
8 | import { getBiggestActorImage } from '@server/lib/actor-image' | ||
9 | import { JobQueue } from '@server/lib/job-queue' | ||
10 | import { AccountModel } from '@server/models/account/account' | ||
11 | import { ActorModel } from '@server/models/actor/actor' | ||
12 | import { VideoChannelModel } from '@server/models/video/video-channel' | ||
13 | import { MAccountDefault, MActorDefault, MChannelDefault } from '@server/types/models' | ||
14 | import { getLowercaseExtension } from '@shared/core-utils' | ||
15 | import { buildUUID } from '@shared/extra-utils' | ||
16 | import { ActorImageType } from '@shared/models' | ||
17 | import { initDatabaseModels } from '../../server/initializers/database' | ||
18 | |||
19 | run() | ||
20 | .then(() => process.exit(0)) | ||
21 | .catch(err => { | ||
22 | console.error(err) | ||
23 | process.exit(-1) | ||
24 | }) | ||
25 | |||
26 | async function run () { | ||
27 | console.log('Generate avatar miniatures from existing avatars.') | ||
28 | |||
29 | await initDatabaseModels(true) | ||
30 | JobQueue.Instance.init(true) | ||
31 | |||
32 | const accounts: AccountModel[] = await AccountModel.findAll({ | ||
33 | include: [ | ||
34 | { | ||
35 | model: ActorModel, | ||
36 | required: true, | ||
37 | where: { | ||
38 | serverId: null | ||
39 | } | ||
40 | }, | ||
41 | { | ||
42 | model: VideoChannelModel, | ||
43 | include: [ | ||
44 | { | ||
45 | model: AccountModel | ||
46 | } | ||
47 | ] | ||
48 | } | ||
49 | ] | ||
50 | }) | ||
51 | |||
52 | for (const account of accounts) { | ||
53 | try { | ||
54 | await fillAvatarSizeIfNeeded(account) | ||
55 | await generateSmallerAvatarIfNeeded(account) | ||
56 | } catch (err) { | ||
57 | console.error(`Cannot process account avatar ${account.name}`, err) | ||
58 | } | ||
59 | |||
60 | for (const videoChannel of account.VideoChannels) { | ||
61 | try { | ||
62 | await generateSmallerAvatarIfNeeded(videoChannel) | ||
63 | } catch (err) { | ||
64 | console.error(`Cannot process channel avatar ${videoChannel.name}`, err) | ||
65 | } | ||
66 | } | ||
67 | } | ||
68 | |||
69 | console.log('Generation finished!') | ||
70 | } | ||
71 | |||
72 | async function fillAvatarSizeIfNeeded (accountOrChannel: MAccountDefault | MChannelDefault) { | ||
73 | const avatars = accountOrChannel.Actor.Avatars | ||
74 | |||
75 | for (const avatar of avatars) { | ||
76 | if (avatar.width && avatar.height) continue | ||
77 | |||
78 | console.log('Filling size of avatars of %s.', accountOrChannel.name) | ||
79 | |||
80 | const { width, height } = await getImageSize(join(CONFIG.STORAGE.ACTOR_IMAGES, avatar.filename)) | ||
81 | avatar.width = width | ||
82 | avatar.height = height | ||
83 | |||
84 | await avatar.save() | ||
85 | } | ||
86 | } | ||
87 | |||
88 | async function generateSmallerAvatarIfNeeded (accountOrChannel: MAccountDefault | MChannelDefault) { | ||
89 | const avatars = accountOrChannel.Actor.Avatars | ||
90 | if (avatars.length !== 1) { | ||
91 | return | ||
92 | } | ||
93 | |||
94 | console.log(`Processing ${accountOrChannel.name}.`) | ||
95 | |||
96 | await generateSmallerAvatar(accountOrChannel.Actor) | ||
97 | accountOrChannel.Actor = Object.assign(accountOrChannel.Actor, { Server: null }) | ||
98 | |||
99 | return sendUpdateActor(accountOrChannel, undefined) | ||
100 | } | ||
101 | |||
102 | async function generateSmallerAvatar (actor: MActorDefault) { | ||
103 | const bigAvatar = getBiggestActorImage(actor.Avatars) | ||
104 | |||
105 | const imageSize = minBy(ACTOR_IMAGES_SIZE[ActorImageType.AVATAR], 'width') | ||
106 | const sourceFilename = bigAvatar.filename | ||
107 | |||
108 | const newImageName = buildUUID() + getLowercaseExtension(sourceFilename) | ||
109 | const source = join(CONFIG.STORAGE.ACTOR_IMAGES, sourceFilename) | ||
110 | const destination = join(CONFIG.STORAGE.ACTOR_IMAGES, newImageName) | ||
111 | |||
112 | await processImage(source, destination, imageSize, true) | ||
113 | |||
114 | const actorImageInfo = { | ||
115 | name: newImageName, | ||
116 | fileUrl: null, | ||
117 | height: imageSize.height, | ||
118 | width: imageSize.width, | ||
119 | onDisk: true | ||
120 | } | ||
121 | |||
122 | await updateActorImages(actor, ActorImageType.AVATAR, [ actorImageInfo ], undefined) | ||
123 | } | ||
diff --git a/scripts/print-transcode-command.ts b/scripts/print-transcode-command.ts index 21667f544..ef671c0aa 100644 --- a/scripts/print-transcode-command.ts +++ b/scripts/print-transcode-command.ts | |||
@@ -1,8 +1,8 @@ | |||
1 | import { program } from 'commander' | 1 | import { program } from 'commander' |
2 | import ffmpeg from 'fluent-ffmpeg' | 2 | import ffmpeg from 'fluent-ffmpeg' |
3 | import { exit } from 'process' | 3 | import { exit } from 'process' |
4 | import { buildx264VODCommand, runCommand, TranscodeOptions } from '@server/helpers/ffmpeg-utils' | 4 | import { buildVODCommand, runCommand, TranscodeVODOptions } from '@server/helpers/ffmpeg' |
5 | import { VideoTranscodingProfilesManager } from '@server/lib/transcoding/video-transcoding-profiles' | 5 | import { VideoTranscodingProfilesManager } from '@server/lib/transcoding/default-transcoding-profiles' |
6 | 6 | ||
7 | program | 7 | program |
8 | .arguments('<path>') | 8 | .arguments('<path>') |
@@ -33,12 +33,12 @@ async function run (path: string, cmd: any) { | |||
33 | 33 | ||
34 | resolution: +cmd.resolution, | 34 | resolution: +cmd.resolution, |
35 | isPortraitMode: false | 35 | isPortraitMode: false |
36 | } as TranscodeOptions | 36 | } as TranscodeVODOptions |
37 | 37 | ||
38 | let command = ffmpeg(options.inputPath) | 38 | let command = ffmpeg(options.inputPath) |
39 | .output(options.outputPath) | 39 | .output(options.outputPath) |
40 | 40 | ||
41 | command = await buildx264VODCommand(command, options) | 41 | command = await buildVODCommand(command, options) |
42 | 42 | ||
43 | command.on('start', (cmdline) => { | 43 | command.on('start', (cmdline) => { |
44 | console.log(cmdline) | 44 | console.log(cmdline) |
diff --git a/scripts/test.sh b/scripts/test.sh index 4d1d8720a..3b294b386 100755 --- a/scripts/test.sh +++ b/scripts/test.sh | |||
@@ -9,6 +9,7 @@ npm run ci -- api-1 | |||
9 | npm run ci -- api-2 | 9 | npm run ci -- api-2 |
10 | npm run ci -- api-3 | 10 | npm run ci -- api-3 |
11 | npm run ci -- api-4 | 11 | npm run ci -- api-4 |
12 | npm run ci -- api-5 | ||
12 | npm run ci -- external-plugins | 13 | npm run ci -- external-plugins |
13 | 14 | ||
14 | npm run ci -- lint | 15 | npm run ci -- lint |