From 35b62f1e599a719886cf3c738c85a51ae4d676df Mon Sep 17 00:00:00 2001 From: Rob Watson Date: Thu, 13 Jan 2022 20:05:09 +0100 Subject: [PATCH] Fetch title, description and author from Youtube --- .../generated/pb/media_set/media_set.pb.go | 172 +++++++++--------- backend/generated/store/models.go | 3 + backend/generated/store/queries.sql.go | 45 ++++- backend/media/service.go | 22 ++- backend/media/types.go | 9 +- backend/server/grpc_handler.go | 3 + ...dia_set_title_desc_author_columns.down.sql | 3 + ...media_set_title_desc_author_columns.up.sql | 5 + backend/sql/queries.sql | 4 +- frontend/src/generated/media_set.ts | 75 ++++---- frontend/src/generated/media_set_pb.js | 158 +++++++++------- proto/media_set.proto | 3 + 12 files changed, 308 insertions(+), 194 deletions(-) create mode 100644 backend/sql/migrations/20220113135856_add_media_set_title_desc_author_columns.down.sql create mode 100644 backend/sql/migrations/20220113135856_add_media_set_title_desc_author_columns.up.sql diff --git a/backend/generated/pb/media_set/media_set.pb.go b/backend/generated/pb/media_set/media_set.pb.go index 9c3311a..b55e08e 100644 --- a/backend/generated/pb/media_set/media_set.pb.go +++ b/backend/generated/pb/media_set/media_set.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.27.1 -// protoc v3.17.3 +// protoc v3.19.1 // source: media_set.proto package media_set @@ -74,6 +74,9 @@ type MediaSet struct { Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` YoutubeId string `protobuf:"bytes,2,opt,name=youtube_id,json=youtubeId,proto3" json:"youtube_id,omitempty"` + Title string `protobuf:"bytes,12,opt,name=title,proto3" json:"title,omitempty"` + Description string `protobuf:"bytes,13,opt,name=description,proto3" json:"description,omitempty"` + Author string `protobuf:"bytes,14,opt,name=author,proto3" json:"author,omitempty"` AudioChannels int32 `protobuf:"varint,3,opt,name=audio_channels,json=audioChannels,proto3" json:"audio_channels,omitempty"` AudioApproxFrames int64 `protobuf:"varint,4,opt,name=audio_approx_frames,json=audioApproxFrames,proto3" json:"audio_approx_frames,omitempty"` AudioFrames int64 `protobuf:"varint,5,opt,name=audio_frames,json=audioFrames,proto3" json:"audio_frames,omitempty"` @@ -131,6 +134,27 @@ func (x *MediaSet) GetYoutubeId() string { return "" } +func (x *MediaSet) GetTitle() string { + if x != nil { + return x.Title + } + return "" +} + +func (x *MediaSet) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *MediaSet) GetAuthor() string { + if x != nil { + return x.Author + } + return "" +} + func (x *MediaSet) GetAudioChannels() int32 { if x != nil { return x.AudioChannels @@ -553,8 +577,6 @@ type GetAudioSegmentProgress struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - MimeType string `protobuf:"bytes,1,opt,name=mime_type,json=mimeType,proto3" json:"mime_type,omitempty"` - Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` PercentComplete float32 `protobuf:"fixed32,3,opt,name=percent_complete,json=percentComplete,proto3" json:"percent_complete,omitempty"` AudioData []byte `protobuf:"bytes,4,opt,name=audio_data,json=audioData,proto3" json:"audio_data,omitempty"` } @@ -591,20 +613,6 @@ func (*GetAudioSegmentProgress) Descriptor() ([]byte, []int) { return file_media_set_proto_rawDescGZIP(), []int{7} } -func (x *GetAudioSegmentProgress) GetMimeType() string { - if x != nil { - return x.MimeType - } - return "" -} - -func (x *GetAudioSegmentProgress) GetMessage() string { - if x != nil { - return x.Message - } - return "" -} - func (x *GetAudioSegmentProgress) GetPercentComplete() float32 { if x != nil { return x.PercentComplete @@ -837,11 +845,16 @@ var file_media_set_proto_rawDesc = []byte{ 0x0a, 0x0f, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x5f, 0x73, 0x65, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x5f, 0x73, 0x65, 0x74, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x75, - 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xcd, 0x03, 0x0a, + 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x9d, 0x04, 0x0a, 0x08, 0x4d, 0x65, 0x64, 0x69, 0x61, 0x53, 0x65, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x79, 0x6f, 0x75, 0x74, 0x75, 0x62, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x79, - 0x6f, 0x75, 0x74, 0x75, 0x62, 0x65, 0x49, 0x64, 0x12, 0x25, 0x0a, 0x0e, 0x61, 0x75, 0x64, 0x69, + 0x6f, 0x75, 0x74, 0x75, 0x62, 0x65, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, + 0x65, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x20, + 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0d, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, + 0x12, 0x16, 0x0a, 0x06, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x06, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x12, 0x25, 0x0a, 0x0e, 0x61, 0x75, 0x64, 0x69, 0x6f, 0x5f, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x61, 0x75, 0x64, 0x69, 0x6f, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x73, 0x12, 0x2e, 0x0a, 0x13, 0x61, 0x75, 0x64, 0x69, 0x6f, 0x5f, 0x61, 0x70, 0x70, 0x72, 0x6f, 0x78, 0x5f, @@ -901,68 +914,65 @@ var file_media_set_proto_rawDesc = []byte{ 0x6d, 0x65, 0x12, 0x2e, 0x0a, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x16, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x5f, 0x73, 0x65, 0x74, 0x2e, 0x41, 0x75, 0x64, 0x69, 0x6f, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x52, 0x06, 0x66, 0x6f, 0x72, 0x6d, - 0x61, 0x74, 0x22, 0x9a, 0x01, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x41, 0x75, 0x64, 0x69, 0x6f, 0x53, - 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1b, - 0x0a, 0x09, 0x6d, 0x69, 0x6d, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x6d, 0x69, 0x6d, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, - 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x70, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, - 0x5f, 0x63, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x02, 0x52, - 0x0f, 0x70, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, - 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x75, 0x64, 0x69, 0x6f, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x61, 0x75, 0x64, 0x69, 0x6f, 0x44, 0x61, 0x74, 0x61, 0x22, - 0x21, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, - 0x69, 0x64, 0x22, 0x4f, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x50, 0x72, - 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x12, 0x29, 0x0a, 0x10, 0x70, 0x65, 0x72, 0x63, 0x65, 0x6e, - 0x74, 0x5f, 0x63, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x02, - 0x52, 0x0f, 0x70, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, - 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, - 0x75, 0x72, 0x6c, 0x22, 0x2a, 0x0a, 0x18, 0x47, 0x65, 0x74, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x54, - 0x68, 0x75, 0x6d, 0x62, 0x6e, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, - 0x5f, 0x0a, 0x19, 0x47, 0x65, 0x74, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x54, 0x68, 0x75, 0x6d, 0x62, - 0x6e, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, - 0x69, 0x6d, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x69, 0x6d, 0x61, - 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x77, 0x69, 0x64, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x05, 0x77, 0x69, 0x64, 0x74, 0x68, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, - 0x68, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, - 0x2a, 0x1f, 0x0a, 0x0b, 0x41, 0x75, 0x64, 0x69, 0x6f, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x12, - 0x07, 0x0a, 0x03, 0x57, 0x41, 0x56, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x4d, 0x50, 0x33, 0x10, - 0x01, 0x32, 0xfd, 0x03, 0x0a, 0x0f, 0x4d, 0x65, 0x64, 0x69, 0x61, 0x53, 0x65, 0x74, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x33, 0x0a, 0x03, 0x47, 0x65, 0x74, 0x12, 0x15, 0x2e, 0x6d, - 0x65, 0x64, 0x69, 0x61, 0x5f, 0x73, 0x65, 0x74, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x5f, 0x73, 0x65, 0x74, 0x2e, - 0x4d, 0x65, 0x64, 0x69, 0x61, 0x53, 0x65, 0x74, 0x22, 0x00, 0x12, 0x47, 0x0a, 0x08, 0x47, 0x65, - 0x74, 0x50, 0x65, 0x61, 0x6b, 0x73, 0x12, 0x1a, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x5f, 0x73, - 0x65, 0x74, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x65, 0x61, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x5f, 0x73, 0x65, 0x74, 0x2e, 0x47, - 0x65, 0x74, 0x50, 0x65, 0x61, 0x6b, 0x73, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x22, - 0x00, 0x30, 0x01, 0x12, 0x63, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x50, 0x65, 0x61, 0x6b, 0x73, 0x46, - 0x6f, 0x72, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x24, 0x2e, 0x6d, 0x65, 0x64, 0x69, - 0x61, 0x5f, 0x73, 0x65, 0x74, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x65, 0x61, 0x6b, 0x73, 0x46, 0x6f, - 0x72, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x25, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x5f, 0x73, 0x65, 0x74, 0x2e, 0x47, 0x65, 0x74, 0x50, - 0x65, 0x61, 0x6b, 0x73, 0x46, 0x6f, 0x72, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5c, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x41, - 0x75, 0x64, 0x69, 0x6f, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x21, 0x2e, 0x6d, 0x65, - 0x64, 0x69, 0x61, 0x5f, 0x73, 0x65, 0x74, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x75, 0x64, 0x69, 0x6f, - 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, - 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x5f, 0x73, 0x65, 0x74, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x75, - 0x64, 0x69, 0x6f, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x65, - 0x73, 0x73, 0x22, 0x00, 0x30, 0x01, 0x12, 0x47, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x56, 0x69, 0x64, - 0x65, 0x6f, 0x12, 0x1a, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x5f, 0x73, 0x65, 0x74, 0x2e, 0x47, - 0x65, 0x74, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, - 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x5f, 0x73, 0x65, 0x74, 0x2e, 0x47, 0x65, 0x74, 0x56, 0x69, - 0x64, 0x65, 0x6f, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x22, 0x00, 0x30, 0x01, 0x12, - 0x60, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x54, 0x68, 0x75, 0x6d, 0x62, - 0x6e, 0x61, 0x69, 0x6c, 0x12, 0x23, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x5f, 0x73, 0x65, 0x74, - 0x2e, 0x47, 0x65, 0x74, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x54, 0x68, 0x75, 0x6d, 0x62, 0x6e, 0x61, - 0x69, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x6d, 0x65, 0x64, 0x69, - 0x61, 0x5f, 0x73, 0x65, 0x74, 0x2e, 0x47, 0x65, 0x74, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x54, 0x68, - 0x75, 0x6d, 0x62, 0x6e, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x42, 0x0e, 0x5a, 0x0c, 0x70, 0x62, 0x2f, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x5f, 0x73, 0x65, - 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x61, 0x74, 0x22, 0x63, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x41, 0x75, 0x64, 0x69, 0x6f, 0x53, 0x65, + 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x12, 0x29, 0x0a, + 0x10, 0x70, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x5f, 0x63, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, + 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x02, 0x52, 0x0f, 0x70, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, + 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x75, 0x64, 0x69, + 0x6f, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x61, 0x75, + 0x64, 0x69, 0x6f, 0x44, 0x61, 0x74, 0x61, 0x22, 0x21, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x56, 0x69, + 0x64, 0x65, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x4f, 0x0a, 0x10, 0x47, 0x65, + 0x74, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x12, 0x29, + 0x0a, 0x10, 0x70, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x5f, 0x63, 0x6f, 0x6d, 0x70, 0x6c, 0x65, + 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x02, 0x52, 0x0f, 0x70, 0x65, 0x72, 0x63, 0x65, 0x6e, + 0x74, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x22, 0x2a, 0x0a, 0x18, 0x47, + 0x65, 0x74, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x54, 0x68, 0x75, 0x6d, 0x62, 0x6e, 0x61, 0x69, 0x6c, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x5f, 0x0a, 0x19, 0x47, 0x65, 0x74, 0x56, 0x69, + 0x64, 0x65, 0x6f, 0x54, 0x68, 0x75, 0x6d, 0x62, 0x6e, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x05, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x77, 0x69, + 0x64, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x77, 0x69, 0x64, 0x74, 0x68, + 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x2a, 0x1f, 0x0a, 0x0b, 0x41, 0x75, 0x64, 0x69, + 0x6f, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x12, 0x07, 0x0a, 0x03, 0x57, 0x41, 0x56, 0x10, 0x00, + 0x12, 0x07, 0x0a, 0x03, 0x4d, 0x50, 0x33, 0x10, 0x01, 0x32, 0xfd, 0x03, 0x0a, 0x0f, 0x4d, 0x65, + 0x64, 0x69, 0x61, 0x53, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x33, 0x0a, + 0x03, 0x47, 0x65, 0x74, 0x12, 0x15, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x5f, 0x73, 0x65, 0x74, + 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x6d, 0x65, + 0x64, 0x69, 0x61, 0x5f, 0x73, 0x65, 0x74, 0x2e, 0x4d, 0x65, 0x64, 0x69, 0x61, 0x53, 0x65, 0x74, + 0x22, 0x00, 0x12, 0x47, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x50, 0x65, 0x61, 0x6b, 0x73, 0x12, 0x1a, + 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x5f, 0x73, 0x65, 0x74, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x65, + 0x61, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x6d, 0x65, 0x64, + 0x69, 0x61, 0x5f, 0x73, 0x65, 0x74, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x65, 0x61, 0x6b, 0x73, 0x50, + 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x22, 0x00, 0x30, 0x01, 0x12, 0x63, 0x0a, 0x12, 0x47, + 0x65, 0x74, 0x50, 0x65, 0x61, 0x6b, 0x73, 0x46, 0x6f, 0x72, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, + 0x74, 0x12, 0x24, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x5f, 0x73, 0x65, 0x74, 0x2e, 0x47, 0x65, + 0x74, 0x50, 0x65, 0x61, 0x6b, 0x73, 0x46, 0x6f, 0x72, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x5f, + 0x73, 0x65, 0x74, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x65, 0x61, 0x6b, 0x73, 0x46, 0x6f, 0x72, 0x53, + 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x12, 0x5c, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x41, 0x75, 0x64, 0x69, 0x6f, 0x53, 0x65, 0x67, 0x6d, + 0x65, 0x6e, 0x74, 0x12, 0x21, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x5f, 0x73, 0x65, 0x74, 0x2e, + 0x47, 0x65, 0x74, 0x41, 0x75, 0x64, 0x69, 0x6f, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x5f, 0x73, + 0x65, 0x74, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x75, 0x64, 0x69, 0x6f, 0x53, 0x65, 0x67, 0x6d, 0x65, + 0x6e, 0x74, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x22, 0x00, 0x30, 0x01, 0x12, 0x47, + 0x0a, 0x08, 0x47, 0x65, 0x74, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x12, 0x1a, 0x2e, 0x6d, 0x65, 0x64, + 0x69, 0x61, 0x5f, 0x73, 0x65, 0x74, 0x2e, 0x47, 0x65, 0x74, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x5f, 0x73, + 0x65, 0x74, 0x2e, 0x47, 0x65, 0x74, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x50, 0x72, 0x6f, 0x67, 0x72, + 0x65, 0x73, 0x73, 0x22, 0x00, 0x30, 0x01, 0x12, 0x60, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x56, 0x69, + 0x64, 0x65, 0x6f, 0x54, 0x68, 0x75, 0x6d, 0x62, 0x6e, 0x61, 0x69, 0x6c, 0x12, 0x23, 0x2e, 0x6d, + 0x65, 0x64, 0x69, 0x61, 0x5f, 0x73, 0x65, 0x74, 0x2e, 0x47, 0x65, 0x74, 0x56, 0x69, 0x64, 0x65, + 0x6f, 0x54, 0x68, 0x75, 0x6d, 0x62, 0x6e, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x24, 0x2e, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x5f, 0x73, 0x65, 0x74, 0x2e, 0x47, 0x65, + 0x74, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x54, 0x68, 0x75, 0x6d, 0x62, 0x6e, 0x61, 0x69, 0x6c, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x0e, 0x5a, 0x0c, 0x70, 0x62, 0x2f, + 0x6d, 0x65, 0x64, 0x69, 0x61, 0x5f, 0x73, 0x65, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( diff --git a/backend/generated/store/models.go b/backend/generated/store/models.go index 21a5425..350b7d6 100644 --- a/backend/generated/store/models.go +++ b/backend/generated/store/models.go @@ -36,4 +36,7 @@ type MediaSet struct { VideoContentLength int64 AudioEncodedS3Key sql.NullString AudioEncodedS3UploadedAt sql.NullTime + Title string + Description string + Author string } diff --git a/backend/generated/store/queries.sql.go b/backend/generated/store/queries.sql.go index 270eeac..1cef792 100644 --- a/backend/generated/store/queries.sql.go +++ b/backend/generated/store/queries.sql.go @@ -11,13 +11,16 @@ import ( ) const createMediaSet = `-- name: CreateMediaSet :one -INSERT INTO media_sets (youtube_id, audio_youtube_itag, audio_channels, audio_frames_approx, audio_sample_rate, audio_content_length, audio_encoded_mime_type, video_youtube_itag, video_content_length, video_mime_type, video_duration_nanos, created_at, updated_at) - VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, NOW(), NOW()) - RETURNING id, youtube_id, audio_youtube_itag, audio_channels, audio_frames_approx, audio_frames, audio_sample_rate, audio_raw_s3_key, audio_raw_s3_uploaded_at, audio_encoded_mime_type, video_youtube_itag, video_s3_key, video_s3_uploaded_at, video_mime_type, video_duration_nanos, video_thumbnail_s3_key, video_thumbnail_s3_uploaded_at, video_thumbnail_mime_type, video_thumbnail_width, video_thumbnail_height, created_at, updated_at, audio_content_length, video_content_length, audio_encoded_s3_key, audio_encoded_s3_uploaded_at +INSERT INTO media_sets (youtube_id, title, description, author, audio_youtube_itag, audio_channels, audio_frames_approx, audio_sample_rate, audio_content_length, audio_encoded_mime_type, video_youtube_itag, video_content_length, video_mime_type, video_duration_nanos, created_at, updated_at) + VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, NOW(), NOW()) + RETURNING id, youtube_id, audio_youtube_itag, audio_channels, audio_frames_approx, audio_frames, audio_sample_rate, audio_raw_s3_key, audio_raw_s3_uploaded_at, audio_encoded_mime_type, video_youtube_itag, video_s3_key, video_s3_uploaded_at, video_mime_type, video_duration_nanos, video_thumbnail_s3_key, video_thumbnail_s3_uploaded_at, video_thumbnail_mime_type, video_thumbnail_width, video_thumbnail_height, created_at, updated_at, audio_content_length, video_content_length, audio_encoded_s3_key, audio_encoded_s3_uploaded_at, title, description, author ` type CreateMediaSetParams struct { YoutubeID string + Title string + Description string + Author string AudioYoutubeItag int32 AudioChannels int32 AudioFramesApprox int64 @@ -33,6 +36,9 @@ type CreateMediaSetParams struct { func (q *Queries) CreateMediaSet(ctx context.Context, arg CreateMediaSetParams) (MediaSet, error) { row := q.db.QueryRow(ctx, createMediaSet, arg.YoutubeID, + arg.Title, + arg.Description, + arg.Author, arg.AudioYoutubeItag, arg.AudioChannels, arg.AudioFramesApprox, @@ -72,12 +78,15 @@ func (q *Queries) CreateMediaSet(ctx context.Context, arg CreateMediaSetParams) &i.VideoContentLength, &i.AudioEncodedS3Key, &i.AudioEncodedS3UploadedAt, + &i.Title, + &i.Description, + &i.Author, ) return i, err } const getMediaSet = `-- name: GetMediaSet :one -SELECT id, youtube_id, audio_youtube_itag, audio_channels, audio_frames_approx, audio_frames, audio_sample_rate, audio_raw_s3_key, audio_raw_s3_uploaded_at, audio_encoded_mime_type, video_youtube_itag, video_s3_key, video_s3_uploaded_at, video_mime_type, video_duration_nanos, video_thumbnail_s3_key, video_thumbnail_s3_uploaded_at, video_thumbnail_mime_type, video_thumbnail_width, video_thumbnail_height, created_at, updated_at, audio_content_length, video_content_length, audio_encoded_s3_key, audio_encoded_s3_uploaded_at FROM media_sets WHERE id = $1 +SELECT id, youtube_id, audio_youtube_itag, audio_channels, audio_frames_approx, audio_frames, audio_sample_rate, audio_raw_s3_key, audio_raw_s3_uploaded_at, audio_encoded_mime_type, video_youtube_itag, video_s3_key, video_s3_uploaded_at, video_mime_type, video_duration_nanos, video_thumbnail_s3_key, video_thumbnail_s3_uploaded_at, video_thumbnail_mime_type, video_thumbnail_width, video_thumbnail_height, created_at, updated_at, audio_content_length, video_content_length, audio_encoded_s3_key, audio_encoded_s3_uploaded_at, title, description, author FROM media_sets WHERE id = $1 ` func (q *Queries) GetMediaSet(ctx context.Context, id uuid.UUID) (MediaSet, error) { @@ -110,12 +119,15 @@ func (q *Queries) GetMediaSet(ctx context.Context, id uuid.UUID) (MediaSet, erro &i.VideoContentLength, &i.AudioEncodedS3Key, &i.AudioEncodedS3UploadedAt, + &i.Title, + &i.Description, + &i.Author, ) return i, err } const getMediaSetByYoutubeID = `-- name: GetMediaSetByYoutubeID :one -SELECT id, youtube_id, audio_youtube_itag, audio_channels, audio_frames_approx, audio_frames, audio_sample_rate, audio_raw_s3_key, audio_raw_s3_uploaded_at, audio_encoded_mime_type, video_youtube_itag, video_s3_key, video_s3_uploaded_at, video_mime_type, video_duration_nanos, video_thumbnail_s3_key, video_thumbnail_s3_uploaded_at, video_thumbnail_mime_type, video_thumbnail_width, video_thumbnail_height, created_at, updated_at, audio_content_length, video_content_length, audio_encoded_s3_key, audio_encoded_s3_uploaded_at FROM media_sets WHERE youtube_id = $1 +SELECT id, youtube_id, audio_youtube_itag, audio_channels, audio_frames_approx, audio_frames, audio_sample_rate, audio_raw_s3_key, audio_raw_s3_uploaded_at, audio_encoded_mime_type, video_youtube_itag, video_s3_key, video_s3_uploaded_at, video_mime_type, video_duration_nanos, video_thumbnail_s3_key, video_thumbnail_s3_uploaded_at, video_thumbnail_mime_type, video_thumbnail_width, video_thumbnail_height, created_at, updated_at, audio_content_length, video_content_length, audio_encoded_s3_key, audio_encoded_s3_uploaded_at, title, description, author FROM media_sets WHERE youtube_id = $1 ` func (q *Queries) GetMediaSetByYoutubeID(ctx context.Context, youtubeID string) (MediaSet, error) { @@ -148,6 +160,9 @@ func (q *Queries) GetMediaSetByYoutubeID(ctx context.Context, youtubeID string) &i.VideoContentLength, &i.AudioEncodedS3Key, &i.AudioEncodedS3UploadedAt, + &i.Title, + &i.Description, + &i.Author, ) return i, err } @@ -156,7 +171,7 @@ const setEncodedAudioUploaded = `-- name: SetEncodedAudioUploaded :one UPDATE media_sets SET audio_encoded_s3_key = $2, audio_encoded_s3_uploaded_at = NOW(), updated_at = NOW() WHERE id = $1 - RETURNING id, youtube_id, audio_youtube_itag, audio_channels, audio_frames_approx, audio_frames, audio_sample_rate, audio_raw_s3_key, audio_raw_s3_uploaded_at, audio_encoded_mime_type, video_youtube_itag, video_s3_key, video_s3_uploaded_at, video_mime_type, video_duration_nanos, video_thumbnail_s3_key, video_thumbnail_s3_uploaded_at, video_thumbnail_mime_type, video_thumbnail_width, video_thumbnail_height, created_at, updated_at, audio_content_length, video_content_length, audio_encoded_s3_key, audio_encoded_s3_uploaded_at + RETURNING id, youtube_id, audio_youtube_itag, audio_channels, audio_frames_approx, audio_frames, audio_sample_rate, audio_raw_s3_key, audio_raw_s3_uploaded_at, audio_encoded_mime_type, video_youtube_itag, video_s3_key, video_s3_uploaded_at, video_mime_type, video_duration_nanos, video_thumbnail_s3_key, video_thumbnail_s3_uploaded_at, video_thumbnail_mime_type, video_thumbnail_width, video_thumbnail_height, created_at, updated_at, audio_content_length, video_content_length, audio_encoded_s3_key, audio_encoded_s3_uploaded_at, title, description, author ` type SetEncodedAudioUploadedParams struct { @@ -194,6 +209,9 @@ func (q *Queries) SetEncodedAudioUploaded(ctx context.Context, arg SetEncodedAud &i.VideoContentLength, &i.AudioEncodedS3Key, &i.AudioEncodedS3UploadedAt, + &i.Title, + &i.Description, + &i.Author, ) return i, err } @@ -202,7 +220,7 @@ const setRawAudioUploaded = `-- name: SetRawAudioUploaded :one UPDATE media_sets SET audio_raw_s3_key = $2, audio_frames = $3, audio_raw_s3_uploaded_at = NOW(), updated_at = NOW() WHERE id = $1 - RETURNING id, youtube_id, audio_youtube_itag, audio_channels, audio_frames_approx, audio_frames, audio_sample_rate, audio_raw_s3_key, audio_raw_s3_uploaded_at, audio_encoded_mime_type, video_youtube_itag, video_s3_key, video_s3_uploaded_at, video_mime_type, video_duration_nanos, video_thumbnail_s3_key, video_thumbnail_s3_uploaded_at, video_thumbnail_mime_type, video_thumbnail_width, video_thumbnail_height, created_at, updated_at, audio_content_length, video_content_length, audio_encoded_s3_key, audio_encoded_s3_uploaded_at + RETURNING id, youtube_id, audio_youtube_itag, audio_channels, audio_frames_approx, audio_frames, audio_sample_rate, audio_raw_s3_key, audio_raw_s3_uploaded_at, audio_encoded_mime_type, video_youtube_itag, video_s3_key, video_s3_uploaded_at, video_mime_type, video_duration_nanos, video_thumbnail_s3_key, video_thumbnail_s3_uploaded_at, video_thumbnail_mime_type, video_thumbnail_width, video_thumbnail_height, created_at, updated_at, audio_content_length, video_content_length, audio_encoded_s3_key, audio_encoded_s3_uploaded_at, title, description, author ` type SetRawAudioUploadedParams struct { @@ -241,6 +259,9 @@ func (q *Queries) SetRawAudioUploaded(ctx context.Context, arg SetRawAudioUpload &i.VideoContentLength, &i.AudioEncodedS3Key, &i.AudioEncodedS3UploadedAt, + &i.Title, + &i.Description, + &i.Author, ) return i, err } @@ -249,7 +270,7 @@ const setVideoThumbnailUploaded = `-- name: SetVideoThumbnailUploaded :one UPDATE media_sets SET video_thumbnail_width = $2, video_thumbnail_height = $3, video_thumbnail_mime_type = $4, video_thumbnail_s3_key = $5, video_thumbnail_s3_uploaded_at = NOW(), updated_at = NOW() WHERE id = $1 -RETURNING id, youtube_id, audio_youtube_itag, audio_channels, audio_frames_approx, audio_frames, audio_sample_rate, audio_raw_s3_key, audio_raw_s3_uploaded_at, audio_encoded_mime_type, video_youtube_itag, video_s3_key, video_s3_uploaded_at, video_mime_type, video_duration_nanos, video_thumbnail_s3_key, video_thumbnail_s3_uploaded_at, video_thumbnail_mime_type, video_thumbnail_width, video_thumbnail_height, created_at, updated_at, audio_content_length, video_content_length, audio_encoded_s3_key, audio_encoded_s3_uploaded_at +RETURNING id, youtube_id, audio_youtube_itag, audio_channels, audio_frames_approx, audio_frames, audio_sample_rate, audio_raw_s3_key, audio_raw_s3_uploaded_at, audio_encoded_mime_type, video_youtube_itag, video_s3_key, video_s3_uploaded_at, video_mime_type, video_duration_nanos, video_thumbnail_s3_key, video_thumbnail_s3_uploaded_at, video_thumbnail_mime_type, video_thumbnail_width, video_thumbnail_height, created_at, updated_at, audio_content_length, video_content_length, audio_encoded_s3_key, audio_encoded_s3_uploaded_at, title, description, author ` type SetVideoThumbnailUploadedParams struct { @@ -296,6 +317,9 @@ func (q *Queries) SetVideoThumbnailUploaded(ctx context.Context, arg SetVideoThu &i.VideoContentLength, &i.AudioEncodedS3Key, &i.AudioEncodedS3UploadedAt, + &i.Title, + &i.Description, + &i.Author, ) return i, err } @@ -304,7 +328,7 @@ const setVideoUploaded = `-- name: SetVideoUploaded :one UPDATE media_sets SET video_s3_key = $2, video_s3_uploaded_at = NOW(), updated_at = NOW() WHERE id = $1 - RETURNING id, youtube_id, audio_youtube_itag, audio_channels, audio_frames_approx, audio_frames, audio_sample_rate, audio_raw_s3_key, audio_raw_s3_uploaded_at, audio_encoded_mime_type, video_youtube_itag, video_s3_key, video_s3_uploaded_at, video_mime_type, video_duration_nanos, video_thumbnail_s3_key, video_thumbnail_s3_uploaded_at, video_thumbnail_mime_type, video_thumbnail_width, video_thumbnail_height, created_at, updated_at, audio_content_length, video_content_length, audio_encoded_s3_key, audio_encoded_s3_uploaded_at + RETURNING id, youtube_id, audio_youtube_itag, audio_channels, audio_frames_approx, audio_frames, audio_sample_rate, audio_raw_s3_key, audio_raw_s3_uploaded_at, audio_encoded_mime_type, video_youtube_itag, video_s3_key, video_s3_uploaded_at, video_mime_type, video_duration_nanos, video_thumbnail_s3_key, video_thumbnail_s3_uploaded_at, video_thumbnail_mime_type, video_thumbnail_width, video_thumbnail_height, created_at, updated_at, audio_content_length, video_content_length, audio_encoded_s3_key, audio_encoded_s3_uploaded_at, title, description, author ` type SetVideoUploadedParams struct { @@ -342,6 +366,9 @@ func (q *Queries) SetVideoUploaded(ctx context.Context, arg SetVideoUploadedPara &i.VideoContentLength, &i.AudioEncodedS3Key, &i.AudioEncodedS3UploadedAt, + &i.Title, + &i.Description, + &i.Author, ) return i, err } diff --git a/backend/media/service.go b/backend/media/service.go index 6a9ec16..b3ec3c1 100644 --- a/backend/media/service.go +++ b/backend/media/service.go @@ -9,6 +9,7 @@ import ( "fmt" "io" "strconv" + "strings" "time" "git.netflux.io/rob/clipper/config" @@ -100,6 +101,9 @@ func (s *MediaSetService) createMediaSet(ctx context.Context, youtubeID string) storeParams := store.CreateMediaSetParams{ YoutubeID: youtubeID, + Title: strings.TrimSpace(video.Title), + Description: strings.TrimSpace(video.Description), + Author: strings.TrimSpace(video.Author), AudioYoutubeItag: int32(audioMetadata.YoutubeItag), AudioChannels: int32(audioMetadata.Channels), AudioFramesApprox: audioMetadata.ApproxFrames, @@ -117,10 +121,13 @@ func (s *MediaSetService) createMediaSet(ctx context.Context, youtubeID string) } return &MediaSet{ - ID: mediaSet.ID, - YoutubeID: youtubeID, - Audio: audioMetadata, - Video: videoMetadata, + ID: mediaSet.ID, + YoutubeID: youtubeID, + Title: mediaSet.Title, + Description: mediaSet.Description, + Author: mediaSet.Author, + Audio: audioMetadata, + Video: videoMetadata, }, nil } @@ -135,8 +142,11 @@ func (s *MediaSetService) findMediaSet(ctx context.Context, youtubeID string) (* } return &MediaSet{ - ID: mediaSet.ID, - YoutubeID: mediaSet.YoutubeID, + ID: mediaSet.ID, + YoutubeID: mediaSet.YoutubeID, + Title: mediaSet.Title, + Description: mediaSet.Description, + Author: mediaSet.Author, Audio: Audio{ YoutubeItag: int(mediaSet.AudioYoutubeItag), ContentLength: mediaSet.AudioContentLength, diff --git a/backend/media/types.go b/backend/media/types.go index 429e25b..c6625a3 100644 --- a/backend/media/types.go +++ b/backend/media/types.go @@ -20,10 +20,11 @@ const SizeOfInt16 = 2 // MediaSet represents the media and metadata associated with a single media // resource (for example, a YouTube video). type MediaSet struct { - Audio Audio - Video Video - ID uuid.UUID - YoutubeID string + Audio Audio + Video Video + ID uuid.UUID + YoutubeID string + Title, Description, Author string } // Audio contains the metadata for the audio part of the media set. diff --git a/backend/server/grpc_handler.go b/backend/server/grpc_handler.go index 8e76b9b..03e7a8b 100644 --- a/backend/server/grpc_handler.go +++ b/backend/server/grpc_handler.go @@ -31,6 +31,9 @@ func (c *mediaSetServiceController) Get(ctx context.Context, request *pbmediaset result := pbmediaset.MediaSet{ Id: mediaSet.ID.String(), + Title: mediaSet.Title, + Description: mediaSet.Description, + Author: mediaSet.Author, YoutubeId: mediaSet.YoutubeID, AudioChannels: int32(mediaSet.Audio.Channels), AudioFrames: mediaSet.Audio.Frames, diff --git a/backend/sql/migrations/20220113135856_add_media_set_title_desc_author_columns.down.sql b/backend/sql/migrations/20220113135856_add_media_set_title_desc_author_columns.down.sql new file mode 100644 index 0000000..87f8722 --- /dev/null +++ b/backend/sql/migrations/20220113135856_add_media_set_title_desc_author_columns.down.sql @@ -0,0 +1,3 @@ +ALTER TABLE media_sets DROP COLUMN title; +ALTER TABLE media_sets DROP COLUMN description; +ALTER TABLE media_sets DROP COLUMN author; diff --git a/backend/sql/migrations/20220113135856_add_media_set_title_desc_author_columns.up.sql b/backend/sql/migrations/20220113135856_add_media_set_title_desc_author_columns.up.sql new file mode 100644 index 0000000..5b323b3 --- /dev/null +++ b/backend/sql/migrations/20220113135856_add_media_set_title_desc_author_columns.up.sql @@ -0,0 +1,5 @@ +ALTER TABLE media_sets ADD COLUMN title CHARACTER VARYING(256) NOT NULL DEFAULT ''; +ALTER TABLE media_sets ADD COLUMN description text NOT NULL DEFAULT ''; +ALTER TABLE media_sets ADD COLUMN author CHARACTER VARYING(256) NOT NULL DEFAULT ''; + +ALTER TABLE media_sets ADD CONSTRAINT check_description_length CHECK (LENGTH(description) <= 4096); diff --git a/backend/sql/queries.sql b/backend/sql/queries.sql index 9b6b9b1..28a2f53 100644 --- a/backend/sql/queries.sql +++ b/backend/sql/queries.sql @@ -5,8 +5,8 @@ SELECT * FROM media_sets WHERE id = $1; SELECT * FROM media_sets WHERE youtube_id = $1; -- name: CreateMediaSet :one -INSERT INTO media_sets (youtube_id, audio_youtube_itag, audio_channels, audio_frames_approx, audio_sample_rate, audio_content_length, audio_encoded_mime_type, video_youtube_itag, video_content_length, video_mime_type, video_duration_nanos, created_at, updated_at) - VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, NOW(), NOW()) +INSERT INTO media_sets (youtube_id, title, description, author, audio_youtube_itag, audio_channels, audio_frames_approx, audio_sample_rate, audio_content_length, audio_encoded_mime_type, video_youtube_itag, video_content_length, video_mime_type, video_duration_nanos, created_at, updated_at) + VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, NOW(), NOW()) RETURNING *; -- name: SetRawAudioUploaded :one diff --git a/frontend/src/generated/media_set.ts b/frontend/src/generated/media_set.ts index 81b1c7b..fb7243a 100644 --- a/frontend/src/generated/media_set.ts +++ b/frontend/src/generated/media_set.ts @@ -44,6 +44,9 @@ export function audioFormatToJSON(object: AudioFormat): string { export interface MediaSet { id: string; youtubeId: string; + title: string; + description: string; + author: string; audioChannels: number; audioApproxFrames: number; audioFrames: number; @@ -89,8 +92,6 @@ export interface GetAudioSegmentRequest { } export interface GetAudioSegmentProgress { - mimeType: string; - message: string; percentComplete: number; audioData: Uint8Array; } @@ -117,6 +118,9 @@ export interface GetVideoThumbnailResponse { const baseMediaSet: object = { id: "", youtubeId: "", + title: "", + description: "", + author: "", audioChannels: 0, audioApproxFrames: 0, audioFrames: 0, @@ -138,6 +142,15 @@ export const MediaSet = { if (message.youtubeId !== "") { writer.uint32(18).string(message.youtubeId); } + if (message.title !== "") { + writer.uint32(98).string(message.title); + } + if (message.description !== "") { + writer.uint32(106).string(message.description); + } + if (message.author !== "") { + writer.uint32(114).string(message.author); + } if (message.audioChannels !== 0) { writer.uint32(24).int32(message.audioChannels); } @@ -181,6 +194,15 @@ export const MediaSet = { case 2: message.youtubeId = reader.string(); break; + case 12: + message.title = reader.string(); + break; + case 13: + message.description = reader.string(); + break; + case 14: + message.author = reader.string(); + break; case 3: message.audioChannels = reader.int32(); break; @@ -224,6 +246,18 @@ export const MediaSet = { object.youtubeId !== undefined && object.youtubeId !== null ? String(object.youtubeId) : ""; + message.title = + object.title !== undefined && object.title !== null + ? String(object.title) + : ""; + message.description = + object.description !== undefined && object.description !== null + ? String(object.description) + : ""; + message.author = + object.author !== undefined && object.author !== null + ? String(object.author) + : ""; message.audioChannels = object.audioChannels !== undefined && object.audioChannels !== null ? Number(object.audioChannels) @@ -268,6 +302,10 @@ export const MediaSet = { const obj: any = {}; message.id !== undefined && (obj.id = message.id); message.youtubeId !== undefined && (obj.youtubeId = message.youtubeId); + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && + (obj.description = message.description); + message.author !== undefined && (obj.author = message.author); message.audioChannels !== undefined && (obj.audioChannels = message.audioChannels); message.audioApproxFrames !== undefined && @@ -295,6 +333,9 @@ export const MediaSet = { const message = { ...baseMediaSet } as MediaSet; message.id = object.id ?? ""; message.youtubeId = object.youtubeId ?? ""; + message.title = object.title ?? ""; + message.description = object.description ?? ""; + message.author = object.author ?? ""; message.audioChannels = object.audioChannels ?? 0; message.audioApproxFrames = object.audioApproxFrames ?? 0; message.audioFrames = object.audioFrames ?? 0; @@ -796,23 +837,13 @@ export const GetAudioSegmentRequest = { }, }; -const baseGetAudioSegmentProgress: object = { - mimeType: "", - message: "", - percentComplete: 0, -}; +const baseGetAudioSegmentProgress: object = { percentComplete: 0 }; export const GetAudioSegmentProgress = { encode( message: GetAudioSegmentProgress, writer: _m0.Writer = _m0.Writer.create() ): _m0.Writer { - if (message.mimeType !== "") { - writer.uint32(10).string(message.mimeType); - } - if (message.message !== "") { - writer.uint32(18).string(message.message); - } if (message.percentComplete !== 0) { writer.uint32(29).float(message.percentComplete); } @@ -835,12 +866,6 @@ export const GetAudioSegmentProgress = { while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { - case 1: - message.mimeType = reader.string(); - break; - case 2: - message.message = reader.string(); - break; case 3: message.percentComplete = reader.float(); break; @@ -859,14 +884,6 @@ export const GetAudioSegmentProgress = { const message = { ...baseGetAudioSegmentProgress, } as GetAudioSegmentProgress; - message.mimeType = - object.mimeType !== undefined && object.mimeType !== null - ? String(object.mimeType) - : ""; - message.message = - object.message !== undefined && object.message !== null - ? String(object.message) - : ""; message.percentComplete = object.percentComplete !== undefined && object.percentComplete !== null ? Number(object.percentComplete) @@ -880,8 +897,6 @@ export const GetAudioSegmentProgress = { toJSON(message: GetAudioSegmentProgress): unknown { const obj: any = {}; - message.mimeType !== undefined && (obj.mimeType = message.mimeType); - message.message !== undefined && (obj.message = message.message); message.percentComplete !== undefined && (obj.percentComplete = message.percentComplete); message.audioData !== undefined && @@ -897,8 +912,6 @@ export const GetAudioSegmentProgress = { const message = { ...baseGetAudioSegmentProgress, } as GetAudioSegmentProgress; - message.mimeType = object.mimeType ?? ""; - message.message = object.message ?? ""; message.percentComplete = object.percentComplete ?? 0; message.audioData = object.audioData ?? new Uint8Array(); return message; diff --git a/frontend/src/generated/media_set_pb.js b/frontend/src/generated/media_set_pb.js index bde4297..7039d67 100644 --- a/frontend/src/generated/media_set_pb.js +++ b/frontend/src/generated/media_set_pb.js @@ -13,7 +13,13 @@ var jspb = require('google-protobuf'); var goog = jspb; -var global = Function('return this')(); +var global = (function() { + if (this) { return this; } + if (typeof window !== 'undefined') { return window; } + if (typeof global !== 'undefined') { return global; } + if (typeof self !== 'undefined') { return self; } + return Function('return this')(); +}.call(null)); var google_protobuf_duration_pb = require('google-protobuf/google/protobuf/duration_pb.js'); goog.object.extend(proto, google_protobuf_duration_pb); @@ -316,6 +322,9 @@ proto.media_set.MediaSet.toObject = function(includeInstance, msg) { var f, obj = { id: jspb.Message.getFieldWithDefault(msg, 1, ""), youtubeId: jspb.Message.getFieldWithDefault(msg, 2, ""), + title: jspb.Message.getFieldWithDefault(msg, 12, ""), + description: jspb.Message.getFieldWithDefault(msg, 13, ""), + author: jspb.Message.getFieldWithDefault(msg, 14, ""), audioChannels: jspb.Message.getFieldWithDefault(msg, 3, 0), audioApproxFrames: jspb.Message.getFieldWithDefault(msg, 4, 0), audioFrames: jspb.Message.getFieldWithDefault(msg, 5, 0), @@ -369,6 +378,18 @@ proto.media_set.MediaSet.deserializeBinaryFromReader = function(msg, reader) { var value = /** @type {string} */ (reader.readString()); msg.setYoutubeId(value); break; + case 12: + var value = /** @type {string} */ (reader.readString()); + msg.setTitle(value); + break; + case 13: + var value = /** @type {string} */ (reader.readString()); + msg.setDescription(value); + break; + case 14: + var value = /** @type {string} */ (reader.readString()); + msg.setAuthor(value); + break; case 3: var value = /** @type {number} */ (reader.readInt32()); msg.setAudioChannels(value); @@ -449,6 +470,27 @@ proto.media_set.MediaSet.serializeBinaryToWriter = function(message, writer) { f ); } + f = message.getTitle(); + if (f.length > 0) { + writer.writeString( + 12, + f + ); + } + f = message.getDescription(); + if (f.length > 0) { + writer.writeString( + 13, + f + ); + } + f = message.getAuthor(); + if (f.length > 0) { + writer.writeString( + 14, + f + ); + } f = message.getAudioChannels(); if (f !== 0) { writer.writeInt32( @@ -552,6 +594,60 @@ proto.media_set.MediaSet.prototype.setYoutubeId = function(value) { }; +/** + * optional string title = 12; + * @return {string} + */ +proto.media_set.MediaSet.prototype.getTitle = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 12, "")); +}; + + +/** + * @param {string} value + * @return {!proto.media_set.MediaSet} returns this + */ +proto.media_set.MediaSet.prototype.setTitle = function(value) { + return jspb.Message.setProto3StringField(this, 12, value); +}; + + +/** + * optional string description = 13; + * @return {string} + */ +proto.media_set.MediaSet.prototype.getDescription = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 13, "")); +}; + + +/** + * @param {string} value + * @return {!proto.media_set.MediaSet} returns this + */ +proto.media_set.MediaSet.prototype.setDescription = function(value) { + return jspb.Message.setProto3StringField(this, 13, value); +}; + + +/** + * optional string author = 14; + * @return {string} + */ +proto.media_set.MediaSet.prototype.getAuthor = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 14, "")); +}; + + +/** + * @param {string} value + * @return {!proto.media_set.MediaSet} returns this + */ +proto.media_set.MediaSet.prototype.setAuthor = function(value) { + return jspb.Message.setProto3StringField(this, 14, value); +}; + + /** * optional int32 audio_channels = 3; * @return {number} @@ -1871,8 +1967,6 @@ proto.media_set.GetAudioSegmentProgress.prototype.toObject = function(opt_includ */ proto.media_set.GetAudioSegmentProgress.toObject = function(includeInstance, msg) { var f, obj = { - mimeType: jspb.Message.getFieldWithDefault(msg, 1, ""), - message: jspb.Message.getFieldWithDefault(msg, 2, ""), percentComplete: jspb.Message.getFloatingPointFieldWithDefault(msg, 3, 0.0), audioData: msg.getAudioData_asB64() }; @@ -1911,14 +2005,6 @@ proto.media_set.GetAudioSegmentProgress.deserializeBinaryFromReader = function(m } var field = reader.getFieldNumber(); switch (field) { - case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setMimeType(value); - break; - case 2: - var value = /** @type {string} */ (reader.readString()); - msg.setMessage(value); - break; case 3: var value = /** @type {number} */ (reader.readFloat()); msg.setPercentComplete(value); @@ -1956,20 +2042,6 @@ proto.media_set.GetAudioSegmentProgress.prototype.serializeBinary = function() { */ proto.media_set.GetAudioSegmentProgress.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getMimeType(); - if (f.length > 0) { - writer.writeString( - 1, - f - ); - } - f = message.getMessage(); - if (f.length > 0) { - writer.writeString( - 2, - f - ); - } f = message.getPercentComplete(); if (f !== 0.0) { writer.writeFloat( @@ -1987,42 +2059,6 @@ proto.media_set.GetAudioSegmentProgress.serializeBinaryToWriter = function(messa }; -/** - * optional string mime_type = 1; - * @return {string} - */ -proto.media_set.GetAudioSegmentProgress.prototype.getMimeType = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * @param {string} value - * @return {!proto.media_set.GetAudioSegmentProgress} returns this - */ -proto.media_set.GetAudioSegmentProgress.prototype.setMimeType = function(value) { - return jspb.Message.setProto3StringField(this, 1, value); -}; - - -/** - * optional string message = 2; - * @return {string} - */ -proto.media_set.GetAudioSegmentProgress.prototype.getMessage = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); -}; - - -/** - * @param {string} value - * @return {!proto.media_set.GetAudioSegmentProgress} returns this - */ -proto.media_set.GetAudioSegmentProgress.prototype.setMessage = function(value) { - return jspb.Message.setProto3StringField(this, 2, value); -}; - - /** * optional float percent_complete = 3; * @return {number} diff --git a/proto/media_set.proto b/proto/media_set.proto index 2a425c8..75e685e 100644 --- a/proto/media_set.proto +++ b/proto/media_set.proto @@ -10,6 +10,9 @@ import "google/protobuf/duration.proto"; message MediaSet { string id = 1; string youtube_id = 2; + string title = 12; + string description = 13; + string author = 14; int32 audio_channels = 3; int64 audio_approx_frames = 4;