return {}
}
+ private static getCategoryLabel (id: number) {
+ let categoryLabel = VIDEO_CATEGORIES[id]
+ if (!categoryLabel) categoryLabel = 'Misc'
+
+ return categoryLabel
+ }
+
+ private static getLicenceLabel (id: number) {
+ let licenceLabel = VIDEO_LICENCES[id]
+ if (!licenceLabel) licenceLabel = 'Unknown'
+
+ return licenceLabel
+ }
+
+ private static getLanguageLabel (id: number) {
+ let languageLabel = VIDEO_LANGUAGES[id]
+ if (!languageLabel) languageLabel = 'Unknown'
+
+ return languageLabel
+ }
+
getOriginalFile () {
if (Array.isArray(this.VideoFiles) === false) return undefined
id: this.id,
uuid: this.uuid,
name: this.name,
- category: this.category,
- categoryLabel: this.getCategoryLabel(),
- licence: this.licence,
- licenceLabel: this.getLicenceLabel(),
- language: this.language,
- languageLabel: this.getLanguageLabel(),
+ category: {
+ id: this.category,
+ label: VideoModel.getCategoryLabel(this.category)
+ },
+ licence: {
+ id: this.licence,
+ label: VideoModel.getLicenceLabel(this.licence)
+ },
+ language: {
+ id: this.language,
+ label: VideoModel.getLanguageLabel(this.language)
+ },
nsfw: this.nsfw,
description: this.getTruncatedDescription(),
isLocal: this.isOwned(),
if (!privacyLabel) privacyLabel = 'Unknown'
const detailsJson = {
- privacyLabel,
- privacy: this.privacy,
+ privacy: {
+ id: this.privacy,
+ label: privacyLabel
+ },
support: this.support,
descriptionPath: this.getDescriptionPath(),
channel: this.VideoChannel.toFormattedJSON(),
let resolutionLabel = videoFile.resolution + 'p'
return {
- resolution: videoFile.resolution,
- resolutionLabel,
+ resolution: {
+ id: videoFile.resolution,
+ label: resolutionLabel
+ },
magnetUri: this.generateMagnetUri(videoFile, baseUrlHttp, baseUrlWs),
size: videoFile.size,
torrentUrl: this.getTorrentUrl(videoFile, baseUrlHttp),
let language
if (this.language) {
language = {
- identifier: this.language + '',
- name: this.getLanguageLabel()
+ id: this.language + '',
+ name: VideoModel.getLanguageLabel(this.language)
}
}
if (this.category) {
category = {
identifier: this.category + '',
- name: this.getCategoryLabel()
+ name: VideoModel.getCategoryLabel(this.category)
}
}
if (this.licence) {
licence = {
identifier: this.licence + '',
- name: this.getLicenceLabel()
+ name: VideoModel.getLicenceLabel(this.licence)
}
}
return `/api/${API_VERSION}/videos/${this.uuid}/description`
}
- getCategoryLabel () {
- let categoryLabel = VIDEO_CATEGORIES[this.category]
- if (!categoryLabel) categoryLabel = 'Misc'
-
- return categoryLabel
- }
-
- getLicenceLabel () {
- let licenceLabel = VIDEO_LICENCES[this.licence]
- if (!licenceLabel) licenceLabel = 'Unknown'
-
- return licenceLabel
- }
-
- getLanguageLabel () {
- let languageLabel = VIDEO_LANGUAGES[this.language]
- if (!languageLabel) languageLabel = 'Unknown'
-
- return languageLabel
- }
-
removeThumbnail () {
const thumbnailPath = join(CONFIG.STORAGE.THUMBNAILS_DIR, this.getThumbnailName())
return unlinkPromise(thumbnailPath)
import { VideoChannel } from './video-channel.model'
import { VideoPrivacy } from './video-privacy.enum'
+export interface VideoConstant <T> {
+ id: number
+ label: string
+}
+
export interface VideoFile {
magnetUri: string
- resolution: number
- resolutionLabel: string
+ resolution: VideoConstant<number>
size: number // Bytes
torrentUrl: string
fileUrl: string
uuid: string
createdAt: Date | string
updatedAt: Date | string
- categoryLabel: string
- category: number
- licenceLabel: string
- licence: number
- languageLabel: string
- language: number
+ category: VideoConstant<number>
+ licence: VideoConstant<number>
+ language: VideoConstant<number>
description: string
duration: number
isLocal: boolean
}
export interface VideoDetails extends Video {
- privacy: VideoPrivacy
- privacyLabel: string
+ privacy: VideoConstant<VideoPrivacy>
descriptionPath: string
support: string
channel: VideoChannel