From ffbfce3ebbd0623f539649a7c0e98fda475a875f Mon Sep 17 00:00:00 2001 From: Daniel Tam Date: Thu, 11 Jun 2020 11:20:15 -0500 Subject: [PATCH] set subreddit image search to also filter by known image domains --- images.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/images.go b/images.go index a9acbb9..b3b864c 100644 --- a/images.go +++ b/images.go @@ -250,8 +250,11 @@ func get_subreddit_image(sub string) <-chan string { // check the post hint to see what type of post it is hint, _ := jsonparser.GetString(out, "data", "children", "[" + strconv.Itoa(random_img) + "]", "data", "post_hint") + // get the domain to also check againist + domain, _ := jsonparser.GetString(out, "data", "children", "[" + strconv.Itoa(random_img) + "]", "data", "domain") + // make sure that it is an image, or at least a gif - if hint == "image" || hint == "link" || hint == "rich:video" { + if hint == "image" || hint == "link" || hint == "rich:video" || domain == "i.redd.it" || domain == "i.imgur.com" { image, _ := jsonparser.GetString(out, "data", "children", "[" + strconv.Itoa(random_img) + "]", "data", "url") ret <- image return