Add headers to default/youtube
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Tyler 2019-10-16 20:03:46 -04:00
parent 3cecfb8c8b
commit 9ae4527143
2 changed files with 9 additions and 0 deletions

View File

@ -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)
}

View File

@ -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 {