Browse Source

Add headers to default/youtube

master
Tyler 3 years ago
parent
commit
9ae4527143
  1. 6
      default.go
  2. 3
      youtube.go

6
default.go

@ -78,6 +78,8 @@ func (api *LinkInfoApi) DefaultLinkHandler(link string) (*LinkInfo, error) {
return nil, err
}
req.Header.Set("Accept-Language", "en-US,en;q=0.9")
if api.UserAgent != "" {
req.Header.Set("User-Agent", api.UserAgent)
}
@ -155,6 +157,8 @@ func (api *LinkInfoApi) detectContentType(link, defaultType string) string {
return defaultType
}
req.Header.Set("Accept-Language", "en-US,en;q=0.9")
if api.UserAgent != "" {
req.Header.Set("User-Agent", api.UserAgent)
}
@ -195,6 +199,8 @@ func (api *LinkInfoApi) retrieveHtmlLinkTitle(i *LinkInfo, link string) error {
return err
}
req.Header.Set("Accept-Language", "en-US,en;q=0.9")
if api.UserAgent != "" {
req.Header.Set("User-Agent", api.UserAgent)
}

3
youtube.go

@ -87,6 +87,9 @@ func (i *YoutubeInfoApi) Handler(link string) (*LinkInfo, error) {
return nil, err
}
req.Header.Set("Accept-Language", "en-US,en;q=0.9")
req.Header.Set("User-Agent", "LinkInfo/1.0")
res, err := i.api.Client.Do(req)
if err != nil {

Loading…
Cancel
Save