From 53b2d9c07b21d6af7a6bb2ea07f5400d45de80c2 Mon Sep 17 00:00:00 2001 From: Alexandre Tuleu Date: Sun, 17 Jan 2016 20:50:58 +0100 Subject: [PATCH] Silently avoid empty description and note --- album_description_cache.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/album_description_cache.go b/album_description_cache.go index b19791e..72d8073 100644 --- a/album_description_cache.go +++ b/album_description_cache.go @@ -134,10 +134,14 @@ func (c *AlbumDescriptionCache) fetchAndCache(ID AlbumID) (*AlbumDescription, er waitSize++ go func() { description := principal.Find(".bandeau-info p.auto-height span") - if description.Size() != 1 { + if description.Size() > 1 { errors <- fmt.Errorf("Could not find a single description, found %d", description.Size()) return } + if description.Size() == 0 { + errors <- nil + return + } res.Description = description.Text() errors <- nil }() @@ -150,7 +154,10 @@ func (c *AlbumDescriptionCache) fetchAndCache(ID AlbumID) (*AlbumDescription, er } m := noteRx.FindStringSubmatch(note.Text()) if m == nil { - errors <- fmt.Errorf("Could not parse note with regexp %s", noteRx) + res.Note = -1.0 + // we simply ignore because there is most likely no note + errors <- nil + //errors <- fmt.Errorf("Could not parse note with regexp %s", noteRx) return } noteTmp, err := strconv.ParseFloat(m[1], 64)