[reddit:user] implement 'only' option (#8228)

This commit is contained in:
Mike Fährmann
2026-02-07 19:38:50 +01:00
parent c16892a150
commit 935bdb6229
3 changed files with 30 additions and 1 deletions

View File

@@ -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"""