From 898b3a836226e8285229d77d3c798434f001f25f Mon Sep 17 00:00:00 2001 From: zijiren233 Date: Sat, 4 Nov 2023 14:02:29 +0800 Subject: [PATCH] Feat: update movie proto --- internal/model/movie.go | 10 +- internal/op/current.go | 18 +- proto/message/message.pb.go | 348 ++++++++++++++++++++++++------- proto/message/message.proto | 14 ++ proto/provider/plugin.pb.go | 2 +- proto/provider/plugin_grpc.pb.go | 2 +- server/handlers/movie.go | 4 +- 7 files changed, 308 insertions(+), 90 deletions(-) diff --git a/internal/model/movie.go b/internal/model/movie.go index e6092f7..addd8f5 100644 --- a/internal/model/movie.go +++ b/internal/model/movie.go @@ -40,7 +40,7 @@ type BaseMovie struct { RtmpSource bool `json:"rtmpSource"` Type string `json:"type"` Headers map[string]string `gorm:"serializer:fastjson" json:"headers"` - VendorInfo `gorm:"embedded;embeddedPrefix:vendor_info_" json:"vendorInfo,omitempty"` + VendorInfo VendorInfo `gorm:"embedded;embeddedPrefix:vendor_info_" json:"vendorInfo,omitempty"` } func (m *BaseMovie) Validate() error { @@ -94,7 +94,7 @@ func (m *BaseMovie) Validate() error { return errors.New("unsupported scheme") } case !m.Live && !m.Proxy, m.Live && !m.Proxy && !m.RtmpSource: - if m.VendorInfo.Vendor == "" { + if m.VendorInfo.Vendor != "" { u, err := url.Parse(m.Url) if err != nil { return err @@ -143,9 +143,9 @@ func (m *BaseMovie) validateVendorMovie() error { } type VendorInfo struct { - Vendor StreamingVendor `json:"vendor"` - Shared bool `gorm:"not null;default:false" json:"shared"` - Bilibili BilibiliVendorInfo `gorm:"embedded;embeddedPrefix:bilibili_" json:"bilibili,omitempty"` + Vendor StreamingVendor `json:"vendor"` + Shared bool `gorm:"not null;default:false" json:"shared"` + Bilibili *BilibiliVendorInfo `gorm:"embedded;embeddedPrefix:bilibili_" json:"bilibili,omitempty"` } type BilibiliVendorInfo struct { diff --git a/internal/op/current.go b/internal/op/current.go index 9621072..6e9e630 100644 --- a/internal/op/current.go +++ b/internal/op/current.go @@ -86,7 +86,7 @@ func (c *current) SetSeekRate(seek, rate, timeDiff float64) Status { } func (c *Current) Proto() *pb.Current { - return &pb.Current{ + current := &pb.Current{ Movie: &pb.MovieInfo{ Id: c.Movie.ID, Base: &pb.BaseMovieInfo{ @@ -107,6 +107,22 @@ func (c *Current) Proto() *pb.Current { Playing: c.Status.Playing, }, } + if c.Movie.Base.VendorInfo.Vendor != "" { + current.Movie.Base.VendorInfo = &pb.VendorInfo{ + Vendor: string(c.Movie.Base.VendorInfo.Vendor), + Shared: c.Movie.Base.VendorInfo.Shared, + } + switch c.Movie.Base.VendorInfo.Vendor { + case model.StreamingVendorBilibili: + current.Movie.Base.VendorInfo.Bilibili = &pb.BilibiliVendorInfo{ + Bvid: c.Movie.Base.VendorInfo.Bilibili.Bvid, + Cid: uint64(c.Movie.Base.VendorInfo.Bilibili.Cid), + Epid: uint64(c.Movie.Base.VendorInfo.Bilibili.Epid), + Quality: uint32(c.Movie.Base.VendorInfo.Bilibili.Quality), + } + } + } + return current } func (c *Current) UpdateSeek() { diff --git a/proto/message/message.pb.go b/proto/message/message.pb.go index ed9285e..7341a15 100644 --- a/proto/message/message.pb.go +++ b/proto/message/message.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.31.0 -// protoc v4.24.4 +// protoc v4.25.0 // source: proto/message/message.proto package pb @@ -111,6 +111,7 @@ type BaseMovieInfo struct { RtmpSource bool `protobuf:"varint,5,opt,name=rtmpSource,proto3" json:"rtmpSource,omitempty"` Type string `protobuf:"bytes,6,opt,name=type,proto3" json:"type,omitempty"` Headers map[string]string `protobuf:"bytes,7,rep,name=headers,proto3" json:"headers,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + VendorInfo *VendorInfo `protobuf:"bytes,8,opt,name=vendorInfo,proto3" json:"vendorInfo,omitempty"` } func (x *BaseMovieInfo) Reset() { @@ -194,6 +195,13 @@ func (x *BaseMovieInfo) GetHeaders() map[string]string { return nil } +func (x *BaseMovieInfo) GetVendorInfo() *VendorInfo { + if x != nil { + return x.VendorInfo + } + return nil +} + type MovieInfo struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -383,6 +391,140 @@ func (x *Current) GetStatus() *Status { return nil } +type VendorInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Vendor string `protobuf:"bytes,1,opt,name=vendor,proto3" json:"vendor,omitempty"` + Shared bool `protobuf:"varint,2,opt,name=shared,proto3" json:"shared,omitempty"` + Bilibili *BilibiliVendorInfo `protobuf:"bytes,3,opt,name=bilibili,proto3" json:"bilibili,omitempty"` +} + +func (x *VendorInfo) Reset() { + *x = VendorInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_message_message_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *VendorInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*VendorInfo) ProtoMessage() {} + +func (x *VendorInfo) ProtoReflect() protoreflect.Message { + mi := &file_proto_message_message_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use VendorInfo.ProtoReflect.Descriptor instead. +func (*VendorInfo) Descriptor() ([]byte, []int) { + return file_proto_message_message_proto_rawDescGZIP(), []int{4} +} + +func (x *VendorInfo) GetVendor() string { + if x != nil { + return x.Vendor + } + return "" +} + +func (x *VendorInfo) GetShared() bool { + if x != nil { + return x.Shared + } + return false +} + +func (x *VendorInfo) GetBilibili() *BilibiliVendorInfo { + if x != nil { + return x.Bilibili + } + return nil +} + +type BilibiliVendorInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Bvid string `protobuf:"bytes,1,opt,name=bvid,proto3" json:"bvid,omitempty"` + Cid uint64 `protobuf:"varint,2,opt,name=cid,proto3" json:"cid,omitempty"` + Epid uint64 `protobuf:"varint,3,opt,name=epid,proto3" json:"epid,omitempty"` + Quality uint32 `protobuf:"varint,4,opt,name=quality,proto3" json:"quality,omitempty"` +} + +func (x *BilibiliVendorInfo) Reset() { + *x = BilibiliVendorInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_message_message_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *BilibiliVendorInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BilibiliVendorInfo) ProtoMessage() {} + +func (x *BilibiliVendorInfo) ProtoReflect() protoreflect.Message { + mi := &file_proto_message_message_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BilibiliVendorInfo.ProtoReflect.Descriptor instead. +func (*BilibiliVendorInfo) Descriptor() ([]byte, []int) { + return file_proto_message_message_proto_rawDescGZIP(), []int{5} +} + +func (x *BilibiliVendorInfo) GetBvid() string { + if x != nil { + return x.Bvid + } + return "" +} + +func (x *BilibiliVendorInfo) GetCid() uint64 { + if x != nil { + return x.Cid + } + return 0 +} + +func (x *BilibiliVendorInfo) GetEpid() uint64 { + if x != nil { + return x.Epid + } + return 0 +} + +func (x *BilibiliVendorInfo) GetQuality() uint32 { + if x != nil { + return x.Quality + } + return 0 +} + type ElementMessage struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -401,7 +543,7 @@ type ElementMessage struct { func (x *ElementMessage) Reset() { *x = ElementMessage{} if protoimpl.UnsafeEnabled { - mi := &file_proto_message_message_proto_msgTypes[4] + mi := &file_proto_message_message_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -414,7 +556,7 @@ func (x *ElementMessage) String() string { func (*ElementMessage) ProtoMessage() {} func (x *ElementMessage) ProtoReflect() protoreflect.Message { - mi := &file_proto_message_message_proto_msgTypes[4] + mi := &file_proto_message_message_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -427,7 +569,7 @@ func (x *ElementMessage) ProtoReflect() protoreflect.Message { // Deprecated: Use ElementMessage.ProtoReflect.Descriptor instead. func (*ElementMessage) Descriptor() ([]byte, []int) { - return file_proto_message_message_proto_rawDescGZIP(), []int{4} + return file_proto_message_message_proto_rawDescGZIP(), []int{6} } func (x *ElementMessage) GetType() ElementMessageType { @@ -491,7 +633,7 @@ var File_proto_message_message_proto protoreflect.FileDescriptor var file_proto_message_message_proto_rawDesc = []byte{ 0x0a, 0x1b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8c, 0x02, 0x0a, 0x0d, 0x42, 0x61, 0x73, 0x65, 0x4d, 0x6f, 0x76, + 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xbf, 0x02, 0x0a, 0x0d, 0x42, 0x61, 0x73, 0x65, 0x4d, 0x6f, 0x76, 0x69, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, @@ -504,60 +646,78 @@ var file_proto_message_message_proto_rawDesc = []byte{ 0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4d, 0x6f, 0x76, 0x69, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, - 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x1a, 0x3a, 0x0a, 0x0c, 0x48, 0x65, 0x61, 0x64, 0x65, - 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, - 0x02, 0x38, 0x01, 0x22, 0x7d, 0x0a, 0x09, 0x4d, 0x6f, 0x76, 0x69, 0x65, 0x49, 0x6e, 0x66, 0x6f, - 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, - 0x12, 0x28, 0x0a, 0x04, 0x62, 0x61, 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4d, 0x6f, 0x76, 0x69, 0x65, - 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x62, 0x61, 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x63, - 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x72, 0x65, 0x61, - 0x74, 0x6f, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, - 0x6f, 0x72, 0x22, 0x4a, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x12, 0x0a, 0x04, - 0x73, 0x65, 0x65, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x01, 0x52, 0x04, 0x73, 0x65, 0x65, 0x6b, - 0x12, 0x12, 0x0a, 0x04, 0x72, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x04, - 0x72, 0x61, 0x74, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x6c, 0x61, 0x79, 0x69, 0x6e, 0x67, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x70, 0x6c, 0x61, 0x79, 0x69, 0x6e, 0x67, 0x22, 0x58, - 0x0a, 0x07, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x26, 0x0a, 0x05, 0x6d, 0x6f, 0x76, - 0x69, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x2e, 0x4d, 0x6f, 0x76, 0x69, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x6d, 0x6f, 0x76, 0x69, - 0x65, 0x12, 0x25, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x0d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x86, 0x02, 0x0a, 0x0e, 0x45, 0x6c, 0x65, - 0x6d, 0x65, 0x6e, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x2d, 0x0a, 0x04, 0x74, - 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2e, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x65, - 0x6e, 0x64, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x65, 0x6e, 0x64, - 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, - 0x72, 0x61, 0x74, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x52, 0x04, 0x72, 0x61, 0x74, 0x65, - 0x12, 0x12, 0x0a, 0x04, 0x73, 0x65, 0x65, 0x6b, 0x18, 0x05, 0x20, 0x01, 0x28, 0x01, 0x52, 0x04, - 0x73, 0x65, 0x65, 0x6b, 0x12, 0x2d, 0x0a, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x18, - 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x75, - 0x72, 0x72, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, - 0x88, 0x01, 0x01, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x65, 0x6f, 0x70, 0x6c, 0x65, 0x4e, 0x75, 0x6d, - 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x70, 0x65, 0x6f, 0x70, 0x6c, 0x65, 0x4e, 0x75, - 0x6d, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x04, 0x74, 0x69, 0x6d, 0x65, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, - 0x74, 0x2a, 0xdb, 0x01, 0x0a, 0x12, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x4d, 0x65, 0x73, - 0x73, 0x61, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, - 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, 0x01, - 0x12, 0x10, 0x0a, 0x0c, 0x43, 0x48, 0x41, 0x54, 0x5f, 0x4d, 0x45, 0x53, 0x53, 0x41, 0x47, 0x45, - 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x50, 0x4c, 0x41, 0x59, 0x10, 0x03, 0x12, 0x09, 0x0a, 0x05, - 0x50, 0x41, 0x55, 0x53, 0x45, 0x10, 0x04, 0x12, 0x0e, 0x0a, 0x0a, 0x43, 0x48, 0x45, 0x43, 0x4b, - 0x5f, 0x53, 0x45, 0x45, 0x4b, 0x10, 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x54, 0x4f, 0x4f, 0x5f, 0x46, - 0x41, 0x53, 0x54, 0x10, 0x06, 0x12, 0x0c, 0x0a, 0x08, 0x54, 0x4f, 0x4f, 0x5f, 0x53, 0x4c, 0x4f, - 0x57, 0x10, 0x07, 0x12, 0x0f, 0x0a, 0x0b, 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45, 0x5f, 0x52, 0x41, - 0x54, 0x45, 0x10, 0x08, 0x12, 0x0f, 0x0a, 0x0b, 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45, 0x5f, 0x53, - 0x45, 0x45, 0x4b, 0x10, 0x09, 0x12, 0x12, 0x0a, 0x0e, 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45, 0x5f, - 0x43, 0x55, 0x52, 0x52, 0x45, 0x4e, 0x54, 0x10, 0x0a, 0x12, 0x11, 0x0a, 0x0d, 0x43, 0x48, 0x41, - 0x4e, 0x47, 0x45, 0x5f, 0x4d, 0x4f, 0x56, 0x49, 0x45, 0x53, 0x10, 0x0b, 0x12, 0x11, 0x0a, 0x0d, - 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45, 0x5f, 0x50, 0x45, 0x4f, 0x50, 0x4c, 0x45, 0x10, 0x0c, 0x42, - 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x12, 0x31, 0x0a, 0x0a, 0x76, 0x65, 0x6e, 0x64, 0x6f, + 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2e, 0x56, 0x65, 0x6e, 0x64, 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0a, + 0x76, 0x65, 0x6e, 0x64, 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x1a, 0x3a, 0x0a, 0x0c, 0x48, 0x65, + 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x7d, 0x0a, 0x09, 0x4d, 0x6f, 0x76, 0x69, 0x65, 0x49, + 0x6e, 0x66, 0x6f, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x02, 0x69, 0x64, 0x12, 0x28, 0x0a, 0x04, 0x62, 0x61, 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x4d, 0x6f, + 0x76, 0x69, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x62, 0x61, 0x73, 0x65, 0x12, 0x1c, 0x0a, + 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x63, + 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x72, + 0x65, 0x61, 0x74, 0x6f, 0x72, 0x22, 0x4a, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, + 0x12, 0x0a, 0x04, 0x73, 0x65, 0x65, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x01, 0x52, 0x04, 0x73, + 0x65, 0x65, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x01, 0x52, 0x04, 0x72, 0x61, 0x74, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x6c, 0x61, 0x79, 0x69, + 0x6e, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x70, 0x6c, 0x61, 0x79, 0x69, 0x6e, + 0x67, 0x22, 0x58, 0x0a, 0x07, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x26, 0x0a, 0x05, + 0x6d, 0x6f, 0x76, 0x69, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2e, 0x4d, 0x6f, 0x76, 0x69, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x6d, + 0x6f, 0x76, 0x69, 0x65, 0x12, 0x25, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x73, 0x0a, 0x0a, 0x56, + 0x65, 0x6e, 0x64, 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x16, 0x0a, 0x06, 0x76, 0x65, 0x6e, + 0x64, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x76, 0x65, 0x6e, 0x64, 0x6f, + 0x72, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x06, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x12, 0x35, 0x0a, 0x08, 0x62, 0x69, 0x6c, + 0x69, 0x62, 0x69, 0x6c, 0x69, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2e, 0x42, 0x69, 0x6c, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x56, 0x65, 0x6e, 0x64, + 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x08, 0x62, 0x69, 0x6c, 0x69, 0x62, 0x69, 0x6c, 0x69, + 0x22, 0x68, 0x0a, 0x12, 0x42, 0x69, 0x6c, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x56, 0x65, 0x6e, 0x64, + 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x76, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x62, 0x76, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x69, + 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x63, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, + 0x65, 0x70, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x65, 0x70, 0x69, 0x64, + 0x12, 0x18, 0x0a, 0x07, 0x71, 0x75, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x0d, 0x52, 0x07, 0x71, 0x75, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x22, 0x86, 0x02, 0x0a, 0x0e, 0x45, + 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x2d, 0x0a, + 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x19, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2e, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, + 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x65, + 0x6e, 0x64, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x12, + 0x0a, 0x04, 0x72, 0x61, 0x74, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x52, 0x04, 0x72, 0x61, + 0x74, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x65, 0x65, 0x6b, 0x18, 0x05, 0x20, 0x01, 0x28, 0x01, + 0x52, 0x04, 0x73, 0x65, 0x65, 0x6b, 0x12, 0x2d, 0x0a, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, + 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, + 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, + 0x6e, 0x74, 0x88, 0x01, 0x01, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x65, 0x6f, 0x70, 0x6c, 0x65, 0x4e, + 0x75, 0x6d, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x70, 0x65, 0x6f, 0x70, 0x6c, 0x65, + 0x4e, 0x75, 0x6d, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x63, 0x75, 0x72, 0x72, + 0x65, 0x6e, 0x74, 0x2a, 0xdb, 0x01, 0x0a, 0x12, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x4d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, + 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x52, 0x52, 0x4f, 0x52, + 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x43, 0x48, 0x41, 0x54, 0x5f, 0x4d, 0x45, 0x53, 0x53, 0x41, + 0x47, 0x45, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x50, 0x4c, 0x41, 0x59, 0x10, 0x03, 0x12, 0x09, + 0x0a, 0x05, 0x50, 0x41, 0x55, 0x53, 0x45, 0x10, 0x04, 0x12, 0x0e, 0x0a, 0x0a, 0x43, 0x48, 0x45, + 0x43, 0x4b, 0x5f, 0x53, 0x45, 0x45, 0x4b, 0x10, 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x54, 0x4f, 0x4f, + 0x5f, 0x46, 0x41, 0x53, 0x54, 0x10, 0x06, 0x12, 0x0c, 0x0a, 0x08, 0x54, 0x4f, 0x4f, 0x5f, 0x53, + 0x4c, 0x4f, 0x57, 0x10, 0x07, 0x12, 0x0f, 0x0a, 0x0b, 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45, 0x5f, + 0x52, 0x41, 0x54, 0x45, 0x10, 0x08, 0x12, 0x0f, 0x0a, 0x0b, 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45, + 0x5f, 0x53, 0x45, 0x45, 0x4b, 0x10, 0x09, 0x12, 0x12, 0x0a, 0x0e, 0x43, 0x48, 0x41, 0x4e, 0x47, + 0x45, 0x5f, 0x43, 0x55, 0x52, 0x52, 0x45, 0x4e, 0x54, 0x10, 0x0a, 0x12, 0x11, 0x0a, 0x0d, 0x43, + 0x48, 0x41, 0x4e, 0x47, 0x45, 0x5f, 0x4d, 0x4f, 0x56, 0x49, 0x45, 0x53, 0x10, 0x0b, 0x12, 0x11, + 0x0a, 0x0d, 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45, 0x5f, 0x50, 0x45, 0x4f, 0x50, 0x4c, 0x45, 0x10, + 0x0c, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( @@ -573,28 +733,32 @@ func file_proto_message_message_proto_rawDescGZIP() []byte { } var file_proto_message_message_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_proto_message_message_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_proto_message_message_proto_msgTypes = make([]protoimpl.MessageInfo, 8) var file_proto_message_message_proto_goTypes = []interface{}{ - (ElementMessageType)(0), // 0: proto.ElementMessageType - (*BaseMovieInfo)(nil), // 1: proto.BaseMovieInfo - (*MovieInfo)(nil), // 2: proto.MovieInfo - (*Status)(nil), // 3: proto.Status - (*Current)(nil), // 4: proto.Current - (*ElementMessage)(nil), // 5: proto.ElementMessage - nil, // 6: proto.BaseMovieInfo.HeadersEntry + (ElementMessageType)(0), // 0: proto.ElementMessageType + (*BaseMovieInfo)(nil), // 1: proto.BaseMovieInfo + (*MovieInfo)(nil), // 2: proto.MovieInfo + (*Status)(nil), // 3: proto.Status + (*Current)(nil), // 4: proto.Current + (*VendorInfo)(nil), // 5: proto.VendorInfo + (*BilibiliVendorInfo)(nil), // 6: proto.BilibiliVendorInfo + (*ElementMessage)(nil), // 7: proto.ElementMessage + nil, // 8: proto.BaseMovieInfo.HeadersEntry } var file_proto_message_message_proto_depIdxs = []int32{ - 6, // 0: proto.BaseMovieInfo.headers:type_name -> proto.BaseMovieInfo.HeadersEntry - 1, // 1: proto.MovieInfo.base:type_name -> proto.BaseMovieInfo - 2, // 2: proto.Current.movie:type_name -> proto.MovieInfo - 3, // 3: proto.Current.status:type_name -> proto.Status - 0, // 4: proto.ElementMessage.type:type_name -> proto.ElementMessageType - 4, // 5: proto.ElementMessage.current:type_name -> proto.Current - 6, // [6:6] is the sub-list for method output_type - 6, // [6:6] is the sub-list for method input_type - 6, // [6:6] is the sub-list for extension type_name - 6, // [6:6] is the sub-list for extension extendee - 0, // [0:6] is the sub-list for field type_name + 8, // 0: proto.BaseMovieInfo.headers:type_name -> proto.BaseMovieInfo.HeadersEntry + 5, // 1: proto.BaseMovieInfo.vendorInfo:type_name -> proto.VendorInfo + 1, // 2: proto.MovieInfo.base:type_name -> proto.BaseMovieInfo + 2, // 3: proto.Current.movie:type_name -> proto.MovieInfo + 3, // 4: proto.Current.status:type_name -> proto.Status + 6, // 5: proto.VendorInfo.bilibili:type_name -> proto.BilibiliVendorInfo + 0, // 6: proto.ElementMessage.type:type_name -> proto.ElementMessageType + 4, // 7: proto.ElementMessage.current:type_name -> proto.Current + 8, // [8:8] is the sub-list for method output_type + 8, // [8:8] is the sub-list for method input_type + 8, // [8:8] is the sub-list for extension type_name + 8, // [8:8] is the sub-list for extension extendee + 0, // [0:8] is the sub-list for field type_name } func init() { file_proto_message_message_proto_init() } @@ -652,6 +816,30 @@ func file_proto_message_message_proto_init() { } } file_proto_message_message_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*VendorInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proto_message_message_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*BilibiliVendorInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proto_message_message_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ElementMessage); i { case 0: return &v.state @@ -664,14 +852,14 @@ func file_proto_message_message_proto_init() { } } } - file_proto_message_message_proto_msgTypes[4].OneofWrappers = []interface{}{} + file_proto_message_message_proto_msgTypes[6].OneofWrappers = []interface{}{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_proto_message_message_proto_rawDesc, NumEnums: 1, - NumMessages: 6, + NumMessages: 8, NumExtensions: 0, NumServices: 0, }, diff --git a/proto/message/message.proto b/proto/message/message.proto index bd13f52..c18ed63 100644 --- a/proto/message/message.proto +++ b/proto/message/message.proto @@ -27,6 +27,7 @@ message BaseMovieInfo { bool rtmpSource = 5; string type = 6; map headers = 7; + VendorInfo vendorInfo = 8; } message MovieInfo { @@ -47,6 +48,19 @@ message Current { Status status = 2; } +message VendorInfo { + string vendor = 1; + bool shared = 2; + BilibiliVendorInfo bilibili = 3; +} + +message BilibiliVendorInfo { + string bvid = 1; + uint64 cid = 2; + uint64 epid = 3; + uint32 quality = 4; +} + message ElementMessage { ElementMessageType type = 1; string sender = 2; diff --git a/proto/provider/plugin.pb.go b/proto/provider/plugin.pb.go index 68210bb..9c29b0d 100644 --- a/proto/provider/plugin.pb.go +++ b/proto/provider/plugin.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.31.0 -// protoc v4.24.4 +// protoc v4.25.0 // source: proto/provider/plugin.proto package providerpb diff --git a/proto/provider/plugin_grpc.pb.go b/proto/provider/plugin_grpc.pb.go index 390cad1..a6e0a1f 100644 --- a/proto/provider/plugin_grpc.pb.go +++ b/proto/provider/plugin_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.3.0 -// - protoc v4.24.4 +// - protoc v4.25.0 // source: proto/provider/plugin.proto package providerpb diff --git a/server/handlers/movie.go b/server/handlers/movie.go index 857d019..7669b61 100644 --- a/server/handlers/movie.go +++ b/server/handlers/movie.go @@ -90,7 +90,7 @@ func MovieList(ctx *gin.Context) { } func genCurrent(current *op.Current, userID string) (*op.Current, error) { - if current.Movie.Base.Vendor != "" { + if current.Movie.Base.VendorInfo.Vendor != "" { return current, parse2VendorMovie(userID, ¤t.Movie, !current.Movie.Base.Proxy) } return current, nil @@ -408,7 +408,7 @@ func ChangeCurrentMovie(ctx *gin.Context) { } current.UpdateSeek() - if current.Movie.Base.VendorInfo.Shared { + if (current.Movie.Base.VendorInfo.Vendor == "") || (current.Movie.Base.VendorInfo.Vendor != "" && current.Movie.Base.VendorInfo.Shared) { if err := room.Broadcast(&op.ElementMessage{ ElementMessage: &pb.ElementMessage{ Type: pb.ElementMessageType_CHANGE_CURRENT,