Support short uuid for GET video/playlist

This commit is contained in:
Chocobozzz
2021-06-28 17:30:59 +02:00
committed by Chocobozzz
parent 62ddc31a9e
commit d4a8e7a65f
94 changed files with 1029 additions and 673 deletions

View File

@@ -1,3 +1,4 @@
import { uuidToShort } from '@server/helpers/uuid'
import { generateMagnetUri } from '@server/helpers/webtorrent'
import { getLocalVideoFileMetadataUrl } from '@server/lib/video-paths'
import { VideoFile } from '@shared/models/videos/video-file.model'
@@ -47,6 +48,8 @@ function videoModelToFormattedJSON (video: MVideoFormattable, options?: VideoFor
const videoObject: Video = {
id: video.id,
uuid: video.uuid,
shortUUID: uuidToShort(video.uuid),
name: video.name,
category: {
id: video.category,

View File

@@ -15,7 +15,7 @@ import {
Table,
UpdatedAt
} from 'sequelize-typescript'
import { v4 as uuidv4 } from 'uuid'
import { buildUUID } from '@server/helpers/uuid'
import { MVideo, MVideoCaption, MVideoCaptionFormattable, MVideoCaptionVideo } from '@server/types/models'
import { AttributesOnly } from '@shared/core-utils'
import { VideoCaption } from '../../../shared/models/videos/caption/video-caption.model'
@@ -182,7 +182,7 @@ export class VideoCaptionModel extends Model<Partial<AttributesOnly<VideoCaption
}
static generateCaptionName (language: string) {
return `${uuidv4()}-${language}.vtt`
return `${buildUUID()}-${language}.vtt`
}
isOwned () {

View File

@@ -17,8 +17,8 @@ import {
Table,
UpdatedAt
} from 'sequelize-typescript'
import { v4 as uuidv4 } from 'uuid'
import { setAsUpdated } from '@server/helpers/database-utils'
import { buildUUID, uuidToShort } from '@server/helpers/uuid'
import { MAccountId, MChannelId } from '@server/types/models'
import { AttributesOnly } from '@shared/core-utils'
import { ActivityIconObject } from '../../../shared/models/activitypub/objects'
@@ -545,7 +545,7 @@ export class VideoPlaylistModel extends Model<Partial<AttributesOnly<VideoPlayli
generateThumbnailName () {
const extension = '.jpg'
return 'playlist-' + uuidv4() + extension
return 'playlist-' + buildUUID() + extension
}
getThumbnailUrl () {
@@ -617,6 +617,8 @@ export class VideoPlaylistModel extends Model<Partial<AttributesOnly<VideoPlayli
return {
id: this.id,
uuid: this.uuid,
shortUUID: uuidToShort(this.uuid),
isLocal: this.isOwned(),
url: this.url,