[reddit:user] implement 'only' option (#8228)
This commit is contained in:
@@ -317,8 +317,23 @@ class RedditUserExtractor(RedditExtractor):
|
||||
|
||||
submissions = self.api.submissions_user(
|
||||
user["name"], text.parse_query(qs))
|
||||
if self.config("only", True):
|
||||
submissions = self._only(submissions, user)
|
||||
return submissions
|
||||
|
||||
def _only(self, submissions, user):
|
||||
uid = "t2_" + user["id"]
|
||||
for submission, comments in submissions:
|
||||
if submission and submission.get("author_fullname") != uid:
|
||||
submission = None
|
||||
comments = [
|
||||
comment
|
||||
for comment in (comments or ())
|
||||
if comment.get("author_fullname") == uid
|
||||
]
|
||||
if submission or comments:
|
||||
yield submission, comments
|
||||
|
||||
|
||||
class RedditSubmissionExtractor(RedditExtractor):
|
||||
"""Extractor for URLs from a submission on reddit.com"""
|
||||
|
||||
Reference in New Issue
Block a user