From 10584ebdac05ff38c949fd42d434cc5c3c376c51 Mon Sep 17 00:00:00 2001 From: Jens Breitbart Date: Thu, 31 Mar 2016 21:21:38 +0200 Subject: [PATCH] Retry if gallery image query for i.imgur.com fails. --- fromURL.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fromURL.go b/fromURL.go index 2b04586..b13d7b3 100644 --- a/fromURL.go +++ b/fromURL.go @@ -30,8 +30,14 @@ func (client *Client) GetInfoFromURL(url string) (*GenericInfo, int, error) { } id := url[start:end] client.Log.Debugf("Detected imgur image ID %v. Was going down the i.imgur.com/ path.", id) - ii, status, err := client.GetGalleryImageInfo(id) - ret.GImage = ii + gii, status, err := client.GetGalleryImageInfo(id) + if status < 400 { + ret.GImage = gii + } else { + var ii *ImageInfo + ii, status, err = client.GetImageInfo(id) + ret.Image = ii + } return &ret, status, err }