weixin_39911916
weixin_39911916
2020-12-01 12:10

Gilded comments

Two commits about comments. The first make get_comments part of _methods so it can be used by the Reddit object, similair to get_flair or get_banned. This change means helpers._get_section is now only used to generate non-subreddit listings as per it's docstring.

I also made get_all_comments simply give 'all' as the subreddit parameter in a call to get_comments. /comments and r/all/comments are identical and both pull from unsubscribed subreddits. But maybe we can't be sure this will always be this way and have to essentially duplicate get_comments?

The second adds gilded_only to both get_all_comments and get_comments.

该提问来源于开源项目:praw-dev/praw

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

5条回答

  • weixin_39965102 weixin_39965102 5月前

    I also made get_all_comments simply give 'all' as the subreddit parameter in a call to get_comments. /comments and r/all/comments are identical and both pull from unsubscribed subreddits. But maybe we can't be sure this will always be this way and have to essentially duplicate get_comments?

    I'm pretty sure the difference is /r/all/ includes submissions/comments from all subreddits, whereas / only includes subscribed subreddits. As such, I like the way you've implemented it, just make it such that if the subreddit argument is None that there is no /r/subname prefix on the URL (rather add the /r/subname prefix only when the subreddit is provided).

    点赞 评论 复制链接分享
  • weixin_39911916 weixin_39911916 5月前

    I'm pretty sure the difference is /r/all/ includes submissions/comments from all subreddits, whereas / only includes subscribed subreddits.

    I don't think so. If I run get_all_comments with praw 2.0.4 then I get plenty of comments from subreddits I'm not subscribed to.

     python
    import praw
    r = praw.Reddit('Test of /comments by u/_Daimon_')
    r.login()
    subscribed = list(r.get_my_reddits())
    for comment in r.get_all_comments():
        if comment.subreddit not in subscribed:
            print comment.subreddit, comment.body[:60]
    
    点赞 评论 复制链接分享
  • weixin_39965102 weixin_39965102 5月前

    In that case let's go with what you have. Please just fix the one line I suggested.

    点赞 评论 复制链接分享
  • weixin_39911916 weixin_39911916 5月前

    Force updated PR

    点赞 评论 复制链接分享
  • weixin_39965102 weixin_39965102 5月前

    Pushed 2.0.5. Thanks!

    点赞 评论 复制链接分享

相关推荐