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 { LiveVideo, VideoState } from '@shared/models'
5 import { VideoModel } from './video'
6 import { VideoBlacklistModel } from './video-blacklist'
15 model: VideoBlacklistModel,
23 tableName: 'videoLive',
26 fields: [ 'videoId' ],
31 export class VideoLiveModel extends Model<VideoLiveModel> {
34 @Column(DataType.STRING)
47 @ForeignKey(() => VideoModel)
51 @BelongsTo(() => VideoModel, {
59 static loadByStreamKey (streamKey: string) {
66 model: VideoModel.unscoped(),
69 state: VideoState.WAITING_FOR_LIVE
73 model: VideoBlacklistModel.unscoped(),
81 return VideoLiveModel.findOne<MVideoLiveVideo>(query)
84 static loadByVideoId (videoId: number) {
91 return VideoLiveModel.findOne<MVideoLive>(query)
94 toFormattedJSON (): LiveVideo {
96 // If we don't have a stream key, it means this is a remote live so we don't specify the rtmp URL
97 rtmpUrl: this.streamKey
101 streamKey: this.streamKey,
102 saveReplay: this.saveReplay