instagram: no crashear con posts sin captions
This commit is contained in:
parent
0bc5717443
commit
ff6009916b
1 changed files with 5 additions and 1 deletions
|
@ -63,9 +63,13 @@ func (r *Instagram) lookup(urlSrc string) (lookupResponse, error) {
|
|||
if response.Data.ShortcodeMedia.Type != "GraphVideo" {
|
||||
return lookupResponse{}, errors.New("Esto no es un video.")
|
||||
}
|
||||
var text string
|
||||
if len(response.Data.ShortcodeMedia.EdgeMediaToCaption.Edges) > 0 {
|
||||
text = response.Data.ShortcodeMedia.EdgeMediaToCaption.Edges[0].Node.Text
|
||||
}
|
||||
return lookupResponse{
|
||||
VideoUrl: response.Data.ShortcodeMedia.VideoUrl,
|
||||
Author: response.Data.ShortcodeMedia.Owner.Username,
|
||||
Text: response.Data.ShortcodeMedia.EdgeMediaToCaption.Edges[0].Node.Text,
|
||||
Text: text,
|
||||
}, nil
|
||||
}
|
||||
|
|
Reference in a new issue