Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add captions url to video #283

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions response_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,34 @@ type playerResponseData struct {
IsUnpluggedCorpus bool `json:"isUnpluggedCorpus"`
IsLiveContent bool `json:"isLiveContent"`
} `json:"videoDetails"`
Captions struct {
PlayerCaptionsRenderer struct {
BaseURL string `json:"baseUrl"`
Visibility string `json:"visibility"`
} `json:"playerCaptionsRenderer"`
PlayerCaptionsTracklistRenderer struct {
CaptionTracks []struct {
BaseURL string `json:"baseUrl"`
Name struct {
SimpleText string `json:"simpleText"`
} `json:"name"`
VssID string `json:"vssId"`
LanguageCode string `json:"languageCode"`
Kind string `json:"kind"`
IsTranslatable bool `json:"isTranslatable"`
} `json:"captionTracks"`
AudioTracks []struct {
CaptionTrackIndices []int `json:"captionTrackIndices"`
} `json:"audioTracks"`
TranslationLanguages []struct {
LanguageCode string `json:"languageCode"`
LanguageName struct {
SimpleText string `json:"simpleText"`
} `json:"languageName"`
} `json:"translationLanguages"`
DefaultAudioTrackIndex int `json:"defaultAudioTrackIndex"`
} `json:"playerCaptionsTracklistRenderer"`
} `json:"captions"`
Microformat struct {
PlayerMicroformatRenderer struct {
Thumbnail struct {
Expand Down
4 changes: 4 additions & 0 deletions video.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type Video struct {
Thumbnails Thumbnails
DASHManifestURL string // URI of the DASH manifest file
HLSManifestURL string // URI of the HLS manifest file
CaptionsURL string // URI of the captions file
}

const dateFormat = "2006-01-02"
Expand Down Expand Up @@ -122,6 +123,9 @@ func (v *Video) extractDataFromPlayerResponse(prData playerResponseData) error {

v.HLSManifestURL = prData.StreamingData.HlsManifestURL
v.DASHManifestURL = prData.StreamingData.DashManifestURL
if len(prData.Captions.PlayerCaptionsTracklistRenderer.CaptionTracks) > 0 {
v.CaptionsURL = prData.Captions.PlayerCaptionsTracklistRenderer.CaptionTracks[0].BaseURL
}

return nil
}
Expand Down