Update proto structure

This commit is contained in:
Rob Watson 2021-11-01 20:33:45 +01:00
parent 7c5b22a407
commit 49099b12d6
3 changed files with 24 additions and 26 deletions

View File

@ -156,24 +156,21 @@ func (s *MediaSetService) findMediaSet(ctx context.Context, youtubeID string) (*
return nil, fmt.Errorf("error getting existing media set: %v", err) return nil, fmt.Errorf("error getting existing media set: %v", err)
} }
var frames int64
if mediaSet.AudioFramesRaw.Valid {
frames = mediaSet.AudioFramesRaw.Int64
}
return &MediaSet{ return &MediaSet{
Audio: Audio{ Audio: Audio{
YoutubeItag: int(mediaSet.AudioYoutubeItag), YoutubeItag: int(mediaSet.AudioYoutubeItag),
Bytes: 0, // DEPRECATED Bytes: 0, // DEPRECATED
Channels: int(mediaSet.AudioChannels), Channels: int(mediaSet.AudioChannels),
ApproxFrames: int64(mediaSet.AudioFramesApprox), ApproxFrames: int64(mediaSet.AudioFramesApprox),
Frames: frames, Frames: mediaSet.AudioFramesRaw.Int64,
SampleRate: int(mediaSet.AudioSampleRateRaw), SampleRate: int(mediaSet.AudioSampleRateRaw),
MimeType: mediaSet.AudioMimeTypeEncoded,
}, },
Video: Video{ Video: Video{
YoutubeItag: int(mediaSet.VideoYoutubeItag), YoutubeItag: int(mediaSet.VideoYoutubeItag),
Bytes: 0, // DEPRECATED? Bytes: 0, // DEPRECATED?
Duration: time.Duration(mediaSet.VideoDurationNanos), Duration: time.Duration(mediaSet.VideoDurationNanos),
MimeType: mediaSet.VideoMimeType,
ThumbnailWidth: 0, // ?? ThumbnailWidth: 0, // ??
ThumbnailHeight: 0, // ?? ThumbnailHeight: 0, // ??
}, },

View File

@ -67,16 +67,17 @@ func (c *mediaSetServiceController) Get(ctx context.Context, request *pbMediaSet
result := pbMediaSet.MediaSet{ result := pbMediaSet.MediaSet{
Id: mediaSet.YoutubeID, Id: mediaSet.YoutubeID,
Audio: &pbMediaSet.MediaSet_Audio{ Audio: &pbMediaSet.MediaSet_Audio{
Bytes: mediaSet.Audio.Bytes,
Channels: int32(mediaSet.Audio.Channels), Channels: int32(mediaSet.Audio.Channels),
Frames: mediaSet.Audio.Frames, Frames: mediaSet.Audio.Frames,
ApproxFrames: mediaSet.Audio.ApproxFrames,
SampleRate: int32(mediaSet.Audio.SampleRate), SampleRate: int32(mediaSet.Audio.SampleRate),
YoutubeItag: int32(mediaSet.Audio.YoutubeItag),
MimeType: mediaSet.Audio.MimeType,
}, },
Video: &pbMediaSet.MediaSet_Video{ Video: &pbMediaSet.MediaSet_Video{
Bytes: mediaSet.Video.Bytes,
Duration: durationpb.New(mediaSet.Video.Duration), Duration: durationpb.New(mediaSet.Video.Duration),
ThumbnailWidth: int32(mediaSet.Video.ThumbnailWidth), YoutubeItag: int32(mediaSet.Video.YoutubeItag),
ThumbnailHeight: int32(mediaSet.Video.ThumbnailHeight), MimeType: mediaSet.Video.MimeType,
}, },
} }

View File

@ -7,24 +7,24 @@ import "google/protobuf/duration.proto";
message MediaSet { message MediaSet {
message Audio { message Audio {
int64 bytes = 1; int32 channels = 1;
int32 channels = 2; int64 approx_frames = 2;
int64 approx_frames = 3; int64 frames = 3;
int64 frames = 4; int32 sample_rate = 4;
int32 sample_rate = 5; int32 youtube_itag = 5;
string mime_type = 6;
}; };
message Video { message Video {
int64 bytes = 1; google.protobuf.Duration duration = 1;
google.protobuf.Duration duration = 2; int32 youtube_itag = 2;
int32 thumbnail_width = 3; string mime_type = 3;
int32 thumbnail_height = 4;
}; };
string id = 1; string id = 1;
Audio audio = 2; string youtube_id = 2;
Video video = 3; Audio audio = 3;
bool loaded = 4; Video video = 4;
}; };
message GetAudioProgress { message GetAudioProgress {