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 {
34 @Column(DataType.STRING)
43 permanentLive: boolean
51 @ForeignKey(() => VideoModel)
55 @BelongsTo(() => VideoModel, {
63 static loadByStreamKey (streamKey: string) {
70 model: VideoModel.unscoped(),
73 state: VideoState.WAITING_FOR_LIVE
77 model: VideoBlacklistModel.unscoped(),
85 return VideoLiveModel.findOne<MVideoLiveVideo>(query)
88 static loadByVideoId (videoId: number) {
95 return VideoLiveModel.findOne<MVideoLive>(query)
98 toFormattedJSON (): LiveVideo {
100 // If we don't have a stream key, it means this is a remote live so we don't specify the rtmp URL
101 rtmpUrl: this.streamKey
105 streamKey: this.streamKey,
106 permanentLive: this.permanentLive,
107 saveReplay: this.saveReplay