Meme_Api
Meme_Api copied to clipboard
Pls Add a feature to get a random post from Top/hot/rising/new sorting
Using your Butter Smooth API for my discord bot.. Really a big help! But the problem is its showing same posts for 2-3 times (specially for specified subreddit). It would be really good if it can be specified that by which sorting method a random meme will be generated like sort by Hot/new/Rising/Top/Gilded etc..
would be a a great feature!
I think you can achieve this by passing the category ( top/hot/rising/new ) to the URL
https://github.com/D3vd/Meme_Api/blob/f5233692907d23042422d2a805a0121f3244d308/libraries/reddit/utils.go#L55-L58
like:
func GetSubredditAPIURL(subreddit string, limit int, category string) (url string) {
url = "https://oauth.reddit.com/r/" + subreddit + "/"+category+"?limit=" + strconv.Itoa(limit)
return
}
and you also need to add this new information to the cache
https://github.com/D3vd/Meme_Api/blob/f5233692907d23042422d2a805a0121f3244d308/api/gimme/one_random_meme.go#L23
https://github.com/D3vd/Meme_Api/blob/f5233692907d23042422d2a805a0121f3244d308/api/gimme/one_random_meme.go#L41-L43
like:
memes := redis.GetPostsFromCache(sub+category)
if err := redis.WritePostsToCache(sub+category, freshMemes); err != nil {
sentry.CaptureException(err)
}