diff --git a/response_data.go b/response_data.go index 34d091c..519172b 100644 --- a/response_data.go +++ b/response_data.go @@ -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 { diff --git a/video.go b/video.go index 4bb7019..f80749b 100644 --- a/video.go +++ b/video.go @@ -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" @@ -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 }