diff options
Diffstat (limited to 'shared')
-rw-r--r-- | shared/extra-utils/miscs/miscs.ts | 25 | ||||
-rw-r--r-- | shared/extra-utils/miscs/sql.ts | 1 | ||||
-rw-r--r-- | shared/extra-utils/server/redundancy.ts | 70 | ||||
-rw-r--r-- | shared/extra-utils/videos/videos.ts | 18 | ||||
-rw-r--r-- | shared/models/redundancy/index.ts | 4 | ||||
-rw-r--r-- | shared/models/redundancy/video-redundancies-filters.model.ts | 1 | ||||
-rw-r--r-- | shared/models/redundancy/video-redundancy.model.ts | 33 | ||||
-rw-r--r-- | shared/models/redundancy/videos-redundancy-strategy.model.ts (renamed from shared/models/redundancy/videos-redundancy.model.ts) | 3 | ||||
-rw-r--r-- | shared/models/server/job.model.ts | 3 | ||||
-rw-r--r-- | shared/models/server/server-stats.model.ts | 18 | ||||
-rw-r--r-- | shared/models/users/user-right.enum.ts | 4 | ||||
-rw-r--r-- | shared/models/videos/video-transcoding-fps.model.ts | 8 | ||||
-rw-r--r-- | shared/models/videos/video.model.ts | 2 |
13 files changed, 167 insertions, 23 deletions
diff --git a/shared/extra-utils/miscs/miscs.ts b/shared/extra-utils/miscs/miscs.ts index 6b0f6d990..c957a6abe 100644 --- a/shared/extra-utils/miscs/miscs.ts +++ b/shared/extra-utils/miscs/miscs.ts | |||
@@ -104,6 +104,28 @@ async function generateHighBitrateVideo () { | |||
104 | return tempFixturePath | 104 | return tempFixturePath |
105 | } | 105 | } |
106 | 106 | ||
107 | async function generateVideoWithFramerate (fps = 60) { | ||
108 | const tempFixturePath = buildAbsoluteFixturePath(`video_${fps}fps.mp4`, true) | ||
109 | |||
110 | await ensureDir(dirname(tempFixturePath)) | ||
111 | |||
112 | const exists = await pathExists(tempFixturePath) | ||
113 | if (!exists) { | ||
114 | return new Promise<string>(async (res, rej) => { | ||
115 | ffmpeg() | ||
116 | .outputOptions([ '-f rawvideo', '-video_size 320x240', '-i /dev/urandom' ]) | ||
117 | .outputOptions([ '-ac 2', '-f s16le', '-i /dev/urandom', '-t 10' ]) | ||
118 | .outputOptions([ `-r ${fps}` ]) | ||
119 | .output(tempFixturePath) | ||
120 | .on('error', rej) | ||
121 | .on('end', () => res(tempFixturePath)) | ||
122 | .run() | ||
123 | }) | ||
124 | } | ||
125 | |||
126 | return tempFixturePath | ||
127 | } | ||
128 | |||
107 | // --------------------------------------------------------------------------- | 129 | // --------------------------------------------------------------------------- |
108 | 130 | ||
109 | export { | 131 | export { |
@@ -115,5 +137,6 @@ export { | |||
115 | testImage, | 137 | testImage, |
116 | buildAbsoluteFixturePath, | 138 | buildAbsoluteFixturePath, |
117 | root, | 139 | root, |
118 | generateHighBitrateVideo | 140 | generateHighBitrateVideo, |
141 | generateVideoWithFramerate | ||
119 | } | 142 | } |
diff --git a/shared/extra-utils/miscs/sql.ts b/shared/extra-utils/miscs/sql.ts index 167649c6d..42599c20e 100644 --- a/shared/extra-utils/miscs/sql.ts +++ b/shared/extra-utils/miscs/sql.ts | |||
@@ -59,7 +59,6 @@ async function countVideoViewsOf (internalServerNumber: number, uuid: string) { | |||
59 | 59 | ||
60 | if (!total) return 0 | 60 | if (!total) return 0 |
61 | 61 | ||
62 | // FIXME: check if we really need parseInt | ||
63 | return parseInt(total + '', 10) | 62 | return parseInt(total + '', 10) |
64 | } | 63 | } |
65 | 64 | ||
diff --git a/shared/extra-utils/server/redundancy.ts b/shared/extra-utils/server/redundancy.ts index c39ff2c8b..7b488e23e 100644 --- a/shared/extra-utils/server/redundancy.ts +++ b/shared/extra-utils/server/redundancy.ts | |||
@@ -1,6 +1,7 @@ | |||
1 | import { makePutBodyRequest } from '../requests/requests' | 1 | import { makeDeleteRequest, makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests' |
2 | import { VideoRedundanciesTarget } from '@shared/models' | ||
2 | 3 | ||
3 | async function updateRedundancy (url: string, accessToken: string, host: string, redundancyAllowed: boolean, expectedStatus = 204) { | 4 | function updateRedundancy (url: string, accessToken: string, host: string, redundancyAllowed: boolean, expectedStatus = 204) { |
4 | const path = '/api/v1/server/redundancy/' + host | 5 | const path = '/api/v1/server/redundancy/' + host |
5 | 6 | ||
6 | return makePutBodyRequest({ | 7 | return makePutBodyRequest({ |
@@ -12,6 +13,69 @@ async function updateRedundancy (url: string, accessToken: string, host: string, | |||
12 | }) | 13 | }) |
13 | } | 14 | } |
14 | 15 | ||
16 | function listVideoRedundancies (options: { | ||
17 | url: string | ||
18 | accessToken: string, | ||
19 | target: VideoRedundanciesTarget, | ||
20 | start?: number, | ||
21 | count?: number, | ||
22 | sort?: string, | ||
23 | statusCodeExpected?: number | ||
24 | }) { | ||
25 | const path = '/api/v1/server/redundancy/videos' | ||
26 | |||
27 | const { url, accessToken, target, statusCodeExpected, start, count, sort } = options | ||
28 | |||
29 | return makeGetRequest({ | ||
30 | url, | ||
31 | token: accessToken, | ||
32 | path, | ||
33 | query: { | ||
34 | start: start ?? 0, | ||
35 | count: count ?? 5, | ||
36 | sort: sort ?? 'name', | ||
37 | target | ||
38 | }, | ||
39 | statusCodeExpected: statusCodeExpected || 200 | ||
40 | }) | ||
41 | } | ||
42 | |||
43 | function addVideoRedundancy (options: { | ||
44 | url: string, | ||
45 | accessToken: string, | ||
46 | videoId: number | ||
47 | }) { | ||
48 | const path = '/api/v1/server/redundancy/videos' | ||
49 | const { url, accessToken, videoId } = options | ||
50 | |||
51 | return makePostBodyRequest({ | ||
52 | url, | ||
53 | token: accessToken, | ||
54 | path, | ||
55 | fields: { videoId }, | ||
56 | statusCodeExpected: 204 | ||
57 | }) | ||
58 | } | ||
59 | |||
60 | function removeVideoRedundancy (options: { | ||
61 | url: string, | ||
62 | accessToken: string, | ||
63 | redundancyId: number | ||
64 | }) { | ||
65 | const { url, accessToken, redundancyId } = options | ||
66 | const path = '/api/v1/server/redundancy/videos/' + redundancyId | ||
67 | |||
68 | return makeDeleteRequest({ | ||
69 | url, | ||
70 | token: accessToken, | ||
71 | path, | ||
72 | statusCodeExpected: 204 | ||
73 | }) | ||
74 | } | ||
75 | |||
15 | export { | 76 | export { |
16 | updateRedundancy | 77 | updateRedundancy, |
78 | listVideoRedundancies, | ||
79 | addVideoRedundancy, | ||
80 | removeVideoRedundancy | ||
17 | } | 81 | } |
diff --git a/shared/extra-utils/videos/videos.ts b/shared/extra-utils/videos/videos.ts index 7a77a03ad..aa13273ae 100644 --- a/shared/extra-utils/videos/videos.ts +++ b/shared/extra-utils/videos/videos.ts | |||
@@ -607,15 +607,28 @@ async function videoUUIDToId (url: string, id: number | string) { | |||
607 | return res.body.id | 607 | return res.body.id |
608 | } | 608 | } |
609 | 609 | ||
610 | async function uploadVideoAndGetId (options: { server: ServerInfo, videoName: string, nsfw?: boolean, token?: string }) { | 610 | async function uploadVideoAndGetId (options: { |
611 | server: ServerInfo, | ||
612 | videoName: string, | ||
613 | nsfw?: boolean, | ||
614 | privacy?: VideoPrivacy, | ||
615 | token?: string | ||
616 | }) { | ||
611 | const videoAttrs: any = { name: options.videoName } | 617 | const videoAttrs: any = { name: options.videoName } |
612 | if (options.nsfw) videoAttrs.nsfw = options.nsfw | 618 | if (options.nsfw) videoAttrs.nsfw = options.nsfw |
619 | if (options.privacy) videoAttrs.privacy = options.privacy | ||
613 | 620 | ||
614 | const res = await uploadVideo(options.server.url, options.token || options.server.accessToken, videoAttrs) | 621 | const res = await uploadVideo(options.server.url, options.token || options.server.accessToken, videoAttrs) |
615 | 622 | ||
616 | return { id: res.body.video.id, uuid: res.body.video.uuid } | 623 | return { id: res.body.video.id, uuid: res.body.video.uuid } |
617 | } | 624 | } |
618 | 625 | ||
626 | async function getLocalIdByUUID (url: string, uuid: string) { | ||
627 | const res = await getVideo(url, uuid) | ||
628 | |||
629 | return res.body.id | ||
630 | } | ||
631 | |||
619 | // --------------------------------------------------------------------------- | 632 | // --------------------------------------------------------------------------- |
620 | 633 | ||
621 | export { | 634 | export { |
@@ -645,5 +658,6 @@ export { | |||
645 | completeVideoCheck, | 658 | completeVideoCheck, |
646 | checkVideoFilesWereRemoved, | 659 | checkVideoFilesWereRemoved, |
647 | getPlaylistVideos, | 660 | getPlaylistVideos, |
648 | uploadVideoAndGetId | 661 | uploadVideoAndGetId, |
662 | getLocalIdByUUID | ||
649 | } | 663 | } |
diff --git a/shared/models/redundancy/index.ts b/shared/models/redundancy/index.ts index 61bf0fca7..649cc489f 100644 --- a/shared/models/redundancy/index.ts +++ b/shared/models/redundancy/index.ts | |||
@@ -1 +1,3 @@ | |||
1 | export * from './videos-redundancy.model' | 1 | export * from './videos-redundancy-strategy.model' |
2 | export * from './video-redundancies-filters.model' | ||
3 | export * from './video-redundancy.model' | ||
diff --git a/shared/models/redundancy/video-redundancies-filters.model.ts b/shared/models/redundancy/video-redundancies-filters.model.ts new file mode 100644 index 000000000..05ba7dfd3 --- /dev/null +++ b/shared/models/redundancy/video-redundancies-filters.model.ts | |||
@@ -0,0 +1 @@ | |||
export type VideoRedundanciesTarget = 'my-videos' | 'remote-videos' | |||
diff --git a/shared/models/redundancy/video-redundancy.model.ts b/shared/models/redundancy/video-redundancy.model.ts new file mode 100644 index 000000000..014f69634 --- /dev/null +++ b/shared/models/redundancy/video-redundancy.model.ts | |||
@@ -0,0 +1,33 @@ | |||
1 | export interface VideoRedundancy { | ||
2 | id: number | ||
3 | name: string | ||
4 | url: string | ||
5 | uuid: string | ||
6 | |||
7 | redundancies: { | ||
8 | files: FileRedundancyInformation[] | ||
9 | |||
10 | streamingPlaylists: StreamingPlaylistRedundancyInformation[] | ||
11 | } | ||
12 | } | ||
13 | |||
14 | interface RedundancyInformation { | ||
15 | id: number | ||
16 | fileUrl: string | ||
17 | strategy: string | ||
18 | |||
19 | createdAt: Date | string | ||
20 | updatedAt: Date | string | ||
21 | |||
22 | expiresOn: Date | string | ||
23 | |||
24 | size: number | ||
25 | } | ||
26 | |||
27 | export interface FileRedundancyInformation extends RedundancyInformation { | ||
28 | |||
29 | } | ||
30 | |||
31 | export interface StreamingPlaylistRedundancyInformation extends RedundancyInformation { | ||
32 | |||
33 | } | ||
diff --git a/shared/models/redundancy/videos-redundancy.model.ts b/shared/models/redundancy/videos-redundancy-strategy.model.ts index a8c2743c1..15409abf0 100644 --- a/shared/models/redundancy/videos-redundancy.model.ts +++ b/shared/models/redundancy/videos-redundancy-strategy.model.ts | |||
@@ -1,4 +1,5 @@ | |||
1 | export type VideoRedundancyStrategy = 'most-views' | 'trending' | 'recently-added' | 1 | export type VideoRedundancyStrategy = 'most-views' | 'trending' | 'recently-added' |
2 | export type VideoRedundancyStrategyWithManual = VideoRedundancyStrategy | 'manual' | ||
2 | 3 | ||
3 | export type MostViewsRedundancyStrategy = { | 4 | export type MostViewsRedundancyStrategy = { |
4 | strategy: 'most-views' | 5 | strategy: 'most-views' |
@@ -19,4 +20,4 @@ export type RecentlyAddedStrategy = { | |||
19 | minLifetime: number | 20 | minLifetime: number |
20 | } | 21 | } |
21 | 22 | ||
22 | export type VideosRedundancy = MostViewsRedundancyStrategy | TrendingRedundancyStrategy | RecentlyAddedStrategy | 23 | export type VideosRedundancyStrategy = MostViewsRedundancyStrategy | TrendingRedundancyStrategy | RecentlyAddedStrategy |
diff --git a/shared/models/server/job.model.ts b/shared/models/server/job.model.ts index b82a633b2..19fd4c659 100644 --- a/shared/models/server/job.model.ts +++ b/shared/models/server/job.model.ts | |||
@@ -9,7 +9,8 @@ export type JobType = 'activitypub-http-unicast' | | |||
9 | 'email' | | 9 | 'email' | |
10 | 'video-import' | | 10 | 'video-import' | |
11 | 'videos-views' | | 11 | 'videos-views' | |
12 | 'activitypub-refresher' | 12 | 'activitypub-refresher' | |
13 | 'video-redundancy' | ||
13 | 14 | ||
14 | export interface Job { | 15 | export interface Job { |
15 | id: number | 16 | id: number |
diff --git a/shared/models/server/server-stats.model.ts b/shared/models/server/server-stats.model.ts index 74f3de5d3..11778e6ed 100644 --- a/shared/models/server/server-stats.model.ts +++ b/shared/models/server/server-stats.model.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { VideoRedundancyStrategy } from '../redundancy' | 1 | import { VideoRedundancyStrategyWithManual } from '../redundancy' |
2 | 2 | ||
3 | export interface ServerStats { | 3 | export interface ServerStats { |
4 | totalUsers: number | 4 | totalUsers: number |
@@ -13,11 +13,13 @@ export interface ServerStats { | |||
13 | totalInstanceFollowers: number | 13 | totalInstanceFollowers: number |
14 | totalInstanceFollowing: number | 14 | totalInstanceFollowing: number |
15 | 15 | ||
16 | videosRedundancy: { | 16 | videosRedundancy: VideosRedundancyStats[] |
17 | strategy: VideoRedundancyStrategy | 17 | } |
18 | totalSize: number | 18 | |
19 | totalUsed: number | 19 | export interface VideosRedundancyStats { |
20 | totalVideoFiles: number | 20 | strategy: VideoRedundancyStrategyWithManual |
21 | totalVideos: number | 21 | totalSize: number |
22 | }[] | 22 | totalUsed: number |
23 | totalVideoFiles: number | ||
24 | totalVideos: number | ||
23 | } | 25 | } |
diff --git a/shared/models/users/user-right.enum.ts b/shared/models/users/user-right.enum.ts index 4a28a229d..2f88a65de 100644 --- a/shared/models/users/user-right.enum.ts +++ b/shared/models/users/user-right.enum.ts | |||
@@ -33,5 +33,7 @@ export enum UserRight { | |||
33 | SEE_ALL_VIDEOS, | 33 | SEE_ALL_VIDEOS, |
34 | CHANGE_VIDEO_OWNERSHIP, | 34 | CHANGE_VIDEO_OWNERSHIP, |
35 | 35 | ||
36 | MANAGE_PLUGINS | 36 | MANAGE_PLUGINS, |
37 | |||
38 | MANAGE_VIDEOS_REDUNDANCIES | ||
37 | } | 39 | } |
diff --git a/shared/models/videos/video-transcoding-fps.model.ts b/shared/models/videos/video-transcoding-fps.model.ts index 82022d2f1..25fc1c2da 100644 --- a/shared/models/videos/video-transcoding-fps.model.ts +++ b/shared/models/videos/video-transcoding-fps.model.ts | |||
@@ -1,6 +1,8 @@ | |||
1 | export type VideoTranscodingFPS = { | 1 | export type VideoTranscodingFPS = { |
2 | MIN: number, | 2 | MIN: number |
3 | AVERAGE: number, | 3 | STANDARD: number[] |
4 | MAX: number, | 4 | HD_STANDARD: number[] |
5 | AVERAGE: number | ||
6 | MAX: number | ||
5 | KEEP_ORIGIN_FPS_RESOLUTION_MIN: number | 7 | KEEP_ORIGIN_FPS_RESOLUTION_MIN: number |
6 | } | 8 | } |
diff --git a/shared/models/videos/video.model.ts b/shared/models/videos/video.model.ts index 7576439fe..a69152759 100644 --- a/shared/models/videos/video.model.ts +++ b/shared/models/videos/video.model.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { AccountSummary, VideoChannelSummary, VideoResolution, VideoState } from '../../index' | 1 | import { AccountSummary, VideoChannelSummary, VideoState } from '../../index' |
2 | import { Account } from '../actors' | 2 | import { Account } from '../actors' |
3 | import { VideoChannel } from './channel/video-channel.model' | 3 | import { VideoChannel } from './channel/video-channel.model' |
4 | import { VideoPrivacy } from './video-privacy.enum' | 4 | import { VideoPrivacy } from './video-privacy.enum' |