diff options
-rw-r--r-- | client/src/app/app-routing.module.ts | 3 | ||||
-rw-r--r-- | server/helpers/custom-validators/videos.ts | 7 | ||||
-rw-r--r-- | server/models/video/video.ts | 80 | ||||
-rw-r--r-- | shared/models/videos/video.model.ts | 20 |
4 files changed, 62 insertions, 48 deletions
diff --git a/client/src/app/app-routing.module.ts b/client/src/app/app-routing.module.ts index c8a6b3924..2ee3cf974 100644 --- a/client/src/app/app-routing.module.ts +++ b/client/src/app/app-routing.module.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | import { NgModule } from '@angular/core' | 1 | import { NgModule } from '@angular/core' |
2 | import { Routes, RouterModule } from '@angular/router' | 2 | import { RouterModule, Routes } from '@angular/router' |
3 | import { RedirectService } from '@app/core/routing/redirect.service' | ||
4 | 3 | ||
5 | import { PreloadSelectedModulesList } from './core' | 4 | import { PreloadSelectedModulesList } from './core' |
6 | 5 | ||
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts index a46d715ba..c08ddd24e 100644 --- a/server/helpers/custom-validators/videos.ts +++ b/server/helpers/custom-validators/videos.ts | |||
@@ -26,8 +26,12 @@ function isVideoLicenceValid (value: number) { | |||
26 | return value === null || VIDEO_LICENCES[value] !== undefined | 26 | return value === null || VIDEO_LICENCES[value] !== undefined |
27 | } | 27 | } |
28 | 28 | ||
29 | function areVideoLanguagesValid (value: number[]) { | ||
30 | return value === null || (isArray(value) && value.every(v => isVideoLanguageValid(v))) | ||
31 | } | ||
32 | |||
29 | function isVideoLanguageValid (value: number) { | 33 | function isVideoLanguageValid (value: number) { |
30 | return value === null || VIDEO_LANGUAGES[value] !== undefined | 34 | return VIDEO_LANGUAGES[value] !== undefined |
31 | } | 35 | } |
32 | 36 | ||
33 | function isVideoDurationValid (value: string) { | 37 | function isVideoDurationValid (value: string) { |
@@ -133,6 +137,7 @@ export { | |||
133 | isVideoDescriptionValid, | 137 | isVideoDescriptionValid, |
134 | isVideoFileInfoHashValid, | 138 | isVideoFileInfoHashValid, |
135 | isVideoNameValid, | 139 | isVideoNameValid, |
140 | areVideoLanguagesValid, | ||
136 | isVideoTagsValid, | 141 | isVideoTagsValid, |
137 | isVideoAbuseReasonValid, | 142 | isVideoAbuseReasonValid, |
138 | isVideoFile, | 143 | isVideoFile, |
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 14eb64102..a4d4c42f0 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -802,6 +802,27 @@ export class VideoModel extends Model<VideoModel> { | |||
802 | return {} | 802 | return {} |
803 | } | 803 | } |
804 | 804 | ||
805 | private static getCategoryLabel (id: number) { | ||
806 | let categoryLabel = VIDEO_CATEGORIES[id] | ||
807 | if (!categoryLabel) categoryLabel = 'Misc' | ||
808 | |||
809 | return categoryLabel | ||
810 | } | ||
811 | |||
812 | private static getLicenceLabel (id: number) { | ||
813 | let licenceLabel = VIDEO_LICENCES[id] | ||
814 | if (!licenceLabel) licenceLabel = 'Unknown' | ||
815 | |||
816 | return licenceLabel | ||
817 | } | ||
818 | |||
819 | private static getLanguageLabel (id: number) { | ||
820 | let languageLabel = VIDEO_LANGUAGES[id] | ||
821 | if (!languageLabel) languageLabel = 'Unknown' | ||
822 | |||
823 | return languageLabel | ||
824 | } | ||
825 | |||
805 | getOriginalFile () { | 826 | getOriginalFile () { |
806 | if (Array.isArray(this.VideoFiles) === false) return undefined | 827 | if (Array.isArray(this.VideoFiles) === false) return undefined |
807 | 828 | ||
@@ -896,12 +917,18 @@ export class VideoModel extends Model<VideoModel> { | |||
896 | id: this.id, | 917 | id: this.id, |
897 | uuid: this.uuid, | 918 | uuid: this.uuid, |
898 | name: this.name, | 919 | name: this.name, |
899 | category: this.category, | 920 | category: { |
900 | categoryLabel: this.getCategoryLabel(), | 921 | id: this.category, |
901 | licence: this.licence, | 922 | label: VideoModel.getCategoryLabel(this.category) |
902 | licenceLabel: this.getLicenceLabel(), | 923 | }, |
903 | language: this.language, | 924 | licence: { |
904 | languageLabel: this.getLanguageLabel(), | 925 | id: this.licence, |
926 | label: VideoModel.getLicenceLabel(this.licence) | ||
927 | }, | ||
928 | language: { | ||
929 | id: this.language, | ||
930 | label: VideoModel.getLanguageLabel(this.language) | ||
931 | }, | ||
905 | nsfw: this.nsfw, | 932 | nsfw: this.nsfw, |
906 | description: this.getTruncatedDescription(), | 933 | description: this.getTruncatedDescription(), |
907 | isLocal: this.isOwned(), | 934 | isLocal: this.isOwned(), |
@@ -932,8 +959,10 @@ export class VideoModel extends Model<VideoModel> { | |||
932 | if (!privacyLabel) privacyLabel = 'Unknown' | 959 | if (!privacyLabel) privacyLabel = 'Unknown' |
933 | 960 | ||
934 | const detailsJson = { | 961 | const detailsJson = { |
935 | privacyLabel, | 962 | privacy: { |
936 | privacy: this.privacy, | 963 | id: this.privacy, |
964 | label: privacyLabel | ||
965 | }, | ||
937 | support: this.support, | 966 | support: this.support, |
938 | descriptionPath: this.getDescriptionPath(), | 967 | descriptionPath: this.getDescriptionPath(), |
939 | channel: this.VideoChannel.toFormattedJSON(), | 968 | channel: this.VideoChannel.toFormattedJSON(), |
@@ -950,8 +979,10 @@ export class VideoModel extends Model<VideoModel> { | |||
950 | let resolutionLabel = videoFile.resolution + 'p' | 979 | let resolutionLabel = videoFile.resolution + 'p' |
951 | 980 | ||
952 | return { | 981 | return { |
953 | resolution: videoFile.resolution, | 982 | resolution: { |
954 | resolutionLabel, | 983 | id: videoFile.resolution, |
984 | label: resolutionLabel | ||
985 | }, | ||
955 | magnetUri: this.generateMagnetUri(videoFile, baseUrlHttp, baseUrlWs), | 986 | magnetUri: this.generateMagnetUri(videoFile, baseUrlHttp, baseUrlWs), |
956 | size: videoFile.size, | 987 | size: videoFile.size, |
957 | torrentUrl: this.getTorrentUrl(videoFile, baseUrlHttp), | 988 | torrentUrl: this.getTorrentUrl(videoFile, baseUrlHttp), |
@@ -979,8 +1010,8 @@ export class VideoModel extends Model<VideoModel> { | |||
979 | let language | 1010 | let language |
980 | if (this.language) { | 1011 | if (this.language) { |
981 | language = { | 1012 | language = { |
982 | identifier: this.language + '', | 1013 | id: this.language + '', |
983 | name: this.getLanguageLabel() | 1014 | name: VideoModel.getLanguageLabel(this.language) |
984 | } | 1015 | } |
985 | } | 1016 | } |
986 | 1017 | ||
@@ -988,7 +1019,7 @@ export class VideoModel extends Model<VideoModel> { | |||
988 | if (this.category) { | 1019 | if (this.category) { |
989 | category = { | 1020 | category = { |
990 | identifier: this.category + '', | 1021 | identifier: this.category + '', |
991 | name: this.getCategoryLabel() | 1022 | name: VideoModel.getCategoryLabel(this.category) |
992 | } | 1023 | } |
993 | } | 1024 | } |
994 | 1025 | ||
@@ -996,7 +1027,7 @@ export class VideoModel extends Model<VideoModel> { | |||
996 | if (this.licence) { | 1027 | if (this.licence) { |
997 | licence = { | 1028 | licence = { |
998 | identifier: this.licence + '', | 1029 | identifier: this.licence + '', |
999 | name: this.getLicenceLabel() | 1030 | name: VideoModel.getLicenceLabel(this.licence) |
1000 | } | 1031 | } |
1001 | } | 1032 | } |
1002 | 1033 | ||
@@ -1224,27 +1255,6 @@ export class VideoModel extends Model<VideoModel> { | |||
1224 | return `/api/${API_VERSION}/videos/${this.uuid}/description` | 1255 | return `/api/${API_VERSION}/videos/${this.uuid}/description` |
1225 | } | 1256 | } |
1226 | 1257 | ||
1227 | getCategoryLabel () { | ||
1228 | let categoryLabel = VIDEO_CATEGORIES[this.category] | ||
1229 | if (!categoryLabel) categoryLabel = 'Misc' | ||
1230 | |||
1231 | return categoryLabel | ||
1232 | } | ||
1233 | |||
1234 | getLicenceLabel () { | ||
1235 | let licenceLabel = VIDEO_LICENCES[this.licence] | ||
1236 | if (!licenceLabel) licenceLabel = 'Unknown' | ||
1237 | |||
1238 | return licenceLabel | ||
1239 | } | ||
1240 | |||
1241 | getLanguageLabel () { | ||
1242 | let languageLabel = VIDEO_LANGUAGES[this.language] | ||
1243 | if (!languageLabel) languageLabel = 'Unknown' | ||
1244 | |||
1245 | return languageLabel | ||
1246 | } | ||
1247 | |||
1248 | removeThumbnail () { | 1258 | removeThumbnail () { |
1249 | const thumbnailPath = join(CONFIG.STORAGE.THUMBNAILS_DIR, this.getThumbnailName()) | 1259 | const thumbnailPath = join(CONFIG.STORAGE.THUMBNAILS_DIR, this.getThumbnailName()) |
1250 | return unlinkPromise(thumbnailPath) | 1260 | return unlinkPromise(thumbnailPath) |
diff --git a/shared/models/videos/video.model.ts b/shared/models/videos/video.model.ts index 707cd42a7..6a096195f 100644 --- a/shared/models/videos/video.model.ts +++ b/shared/models/videos/video.model.ts | |||
@@ -3,10 +3,14 @@ import { Avatar } from '../avatars/avatar.model' | |||
3 | import { VideoChannel } from './video-channel.model' | 3 | import { VideoChannel } from './video-channel.model' |
4 | import { VideoPrivacy } from './video-privacy.enum' | 4 | import { VideoPrivacy } from './video-privacy.enum' |
5 | 5 | ||
6 | export interface VideoConstant <T> { | ||
7 | id: number | ||
8 | label: string | ||
9 | } | ||
10 | |||
6 | export interface VideoFile { | 11 | export interface VideoFile { |
7 | magnetUri: string | 12 | magnetUri: string |
8 | resolution: number | 13 | resolution: VideoConstant<number> |
9 | resolutionLabel: string | ||
10 | size: number // Bytes | 14 | size: number // Bytes |
11 | torrentUrl: string | 15 | torrentUrl: string |
12 | fileUrl: string | 16 | fileUrl: string |
@@ -17,12 +21,9 @@ export interface Video { | |||
17 | uuid: string | 21 | uuid: string |
18 | createdAt: Date | string | 22 | createdAt: Date | string |
19 | updatedAt: Date | string | 23 | updatedAt: Date | string |
20 | categoryLabel: string | 24 | category: VideoConstant<number> |
21 | category: number | 25 | licence: VideoConstant<number> |
22 | licenceLabel: string | 26 | language: VideoConstant<number> |
23 | licence: number | ||
24 | languageLabel: string | ||
25 | language: number | ||
26 | description: string | 27 | description: string |
27 | duration: number | 28 | duration: number |
28 | isLocal: boolean | 29 | isLocal: boolean |
@@ -45,8 +46,7 @@ export interface Video { | |||
45 | } | 46 | } |
46 | 47 | ||
47 | export interface VideoDetails extends Video { | 48 | export interface VideoDetails extends Video { |
48 | privacy: VideoPrivacy | 49 | privacy: VideoConstant<VideoPrivacy> |
49 | privacyLabel: string | ||
50 | descriptionPath: string | 50 | descriptionPath: string |
51 | support: string | 51 | support: string |
52 | channel: VideoChannel | 52 | channel: VideoChannel |