1 import { AllowNull, BelongsTo, Column, CreatedAt, DataType, DefaultScope, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript'
2 import { WEBSERVER } from '@server/initializers/constants'
3 import { MVideoLive, MVideoLiveVideo } from '@server/types/models'
4 import { AttributesOnly } from '@shared/core-utils'
5 import { LiveVideo, VideoState } from '@shared/models'
6 import { VideoModel } from './video'
7 import { VideoBlacklistModel } from './video-blacklist'
16 model: VideoBlacklistModel,
24 tableName: 'videoLive',
27 fields: [ 'videoId' ],
32 export class VideoLiveModel extends Model<Partial<AttributesOnly<VideoLiveModel>>> {
35 @Column(DataType.STRING)
44 permanentLive: boolean
52 @ForeignKey(() => VideoModel)
56 @BelongsTo(() => VideoModel, {
64 static loadByStreamKey (streamKey: string) {
71 model: VideoModel.unscoped(),
74 state: VideoState.WAITING_FOR_LIVE
78 model: VideoBlacklistModel.unscoped(),
86 return VideoLiveModel.findOne<MVideoLiveVideo>(query)
89 static loadByVideoId (videoId: number) {
96 return VideoLiveModel.findOne<MVideoLive>(query)
99 toFormattedJSON (): LiveVideo {
101 // If we don't have a stream key, it means this is a remote live so we don't specify the rtmp URL
102 rtmpUrl: this.streamKey
106 streamKey: this.streamKey,
107 permanentLive: this.permanentLive,
108 saveReplay: this.saveReplay