diff --git a/psaw/PushshiftAPI.py b/psaw/PushshiftAPI.py index 19ddb0b..f72f11f 100644 --- a/psaw/PushshiftAPI.py +++ b/psaw/PushshiftAPI.py @@ -1,4 +1,4 @@ -from collections import namedtuple, deque +from collections import namedtuple, deque, Counter import copy import json import requests @@ -243,6 +243,13 @@ class PushshiftAPI(PushshiftAPIMinimal): def search_submissions(self, **kwargs): return self._search_func(kind='submission', **kwargs) + def redditor_subreddit_activity(self, author, **kwargs): + outv = {} + for k in ('comment', 'submission'): + agg = next(self._search(kind=k, author=author, aggs='subreddit', **kwargs)) + outv[k] = Counter({rec['key']:rec['doc_count'] for rec in agg['subreddit']}) + return outv + def _get_submission_comment_ids(self, submission_id, **kwargs): self.payload = copy.deepcopy(kwargs) endpoint = 'reddit/submission/comment_ids/{}'.format(submission_id)