Skip to content

Commit

Permalink
extract Format and AdaptiveFormat
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian-Chu authored and corny committed Aug 13, 2020
1 parent 8d8aa2a commit 064f30b
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 46 deletions.
49 changes: 3 additions & 46 deletions response_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,52 +8,9 @@ type PlayerResponseData struct {
ContextParams string `json:"contextParams"`
} `json:"playabilityStatus"`
StreamingData struct {
ExpiresInSeconds string `json:"expiresInSeconds"`
Formats []struct {
Stream
Bitrate int `json:"bitrate"`
Width int `json:"width"`
Height int `json:"height"`
LastModified string `json:"lastModified"`
ContentLength string `json:"contentLength,omitempty"`
QualityLabel string `json:"qualityLabel"`
ProjectionType string `json:"projectionType"`
AverageBitrate int `json:"averageBitrate,omitempty"`
AudioQuality string `json:"audioQuality"`
ApproxDurationMs string `json:"approxDurationMs"`
AudioSampleRate string `json:"audioSampleRate"`
AudioChannels int `json:"audioChannels"`
} `json:"formats"`
AdaptiveFormats []struct {
Stream
Bitrate int `json:"bitrate"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
InitRange struct {
Start string `json:"start"`
End string `json:"end"`
} `json:"initRange"`
IndexRange struct {
Start string `json:"start"`
End string `json:"end"`
} `json:"indexRange"`
LastModified string `json:"lastModified"`
ContentLength string `json:"contentLength"`
Fps int `json:"fps,omitempty"`
QualityLabel string `json:"qualityLabel,omitempty"`
ProjectionType string `json:"projectionType"`
AverageBitrate int `json:"averageBitrate"`
ApproxDurationMs string `json:"approxDurationMs"`
ColorInfo struct {
Primaries string `json:"primaries"`
TransferCharacteristics string `json:"transferCharacteristics"`
MatrixCoefficients string `json:"matrixCoefficients"`
} `json:"colorInfo,omitempty"`
HighReplication bool `json:"highReplication,omitempty"`
AudioQuality string `json:"audioQuality,omitempty"`
AudioSampleRate string `json:"audioSampleRate,omitempty"`
AudioChannels int `json:"audioChannels,omitempty"`
} `json:"adaptiveFormats"`
ExpiresInSeconds string `json:"expiresInSeconds"`
Formats []Format `json:"formats"`
AdaptiveFormats []AdaptiveFormat `json:"adaptiveFormats"`
} `json:"streamingData"`
Captions struct {
PlayerCaptionsRenderer struct {
Expand Down
47 changes: 47 additions & 0 deletions video.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,53 @@ type Stream struct {
Cipher string `json:"signatureCipher"`
}

type Format struct {
Stream
Bitrate int `json:"bitrate"`
Width int `json:"width"`
Height int `json:"height"`
LastModified string `json:"lastModified"`
ContentLength string `json:"contentLength,omitempty"`
QualityLabel string `json:"qualityLabel"`
ProjectionType string `json:"projectionType"`
AverageBitrate int `json:"averageBitrate,omitempty"`
AudioQuality string `json:"audioQuality"`
ApproxDurationMs string `json:"approxDurationMs"`
AudioSampleRate string `json:"audioSampleRate"`
AudioChannels int `json:"audioChannels"`
}

type AdaptiveFormat struct {
Stream
Bitrate int `json:"bitrate"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
InitRange struct {
Start string `json:"start"`
End string `json:"end"`
} `json:"initRange"`
IndexRange struct {
Start string `json:"start"`
End string `json:"end"`
} `json:"indexRange"`
LastModified string `json:"lastModified"`
ContentLength string `json:"contentLength"`
Fps int `json:"fps,omitempty"`
QualityLabel string `json:"qualityLabel,omitempty"`
ProjectionType string `json:"projectionType"`
AverageBitrate int `json:"averageBitrate"`
ApproxDurationMs string `json:"approxDurationMs"`
ColorInfo struct {
Primaries string `json:"primaries"`
TransferCharacteristics string `json:"transferCharacteristics"`
MatrixCoefficients string `json:"matrixCoefficients"`
} `json:"colorInfo,omitempty"`
HighReplication bool `json:"highReplication,omitempty"`
AudioQuality string `json:"audioQuality,omitempty"`
AudioSampleRate string `json:"audioSampleRate,omitempty"`
AudioChannels int `json:"audioChannels,omitempty"`
}

func (v *Video) FindStreamByQuality(quality string) *Stream {
for i := range v.Streams {
if v.Streams[i].Quality == quality {
Expand Down

0 comments on commit 064f30b

Please sign in to comment.