def get_memes(self, num):
""" Get memes from Reddit /r/meme subreddit
"""
if self._no_cache() or self._cache_expired():
self._build_cache()
else:
self._update_with_cache()
if self._cache_size >= num:
return self._pop_memes(num)
else:
# Haven't found a way to get memes
# in a specific range using PRAW
results = self._reddit.subreddit('memes').hot(limit=num)
meme_results = []
for submission in results:
# Get required properties for the memes
ctitle = submission.title
curl = submission.url
cmeme = Meme(curl, datetime.datetime.now(),
title=ctitle,
origin=Origins.REDDITMEMES)
meme_results.append(cmeme)
return meme_results
评论列表
文章目录