Add option to download user comments (#258)

* Add option to download user comments

* Update README
This commit is contained in:
Serene
2021-04-09 23:15:45 +10:00
committed by Ali Parlakci
parent 37ca413424
commit 34c8a9a5d0
5 changed files with 26 additions and 0 deletions

View File

@@ -4,6 +4,7 @@
import json
import logging
import re
from typing import Iterator
import dict2xml
import praw.models
@@ -41,6 +42,14 @@ class Archiver(RedditDownloader):
supplied_submissions.append(self.reddit_instance.submission(url=sub_id))
return [supplied_submissions]
def _get_user_data(self) -> list[Iterator]:
results = super(Archiver, self)._get_user_data()
if self.args.user and self.args.all_comments:
sort = self._determine_sort_function()
logger.debug(f'Retrieving comments of user {self.args.user}')
results.append(sort(self.reddit_instance.redditor(self.args.user).comments, limit=self.args.limit))
return results
@staticmethod
def _pull_lever_entry_factory(praw_item: (praw.models.Submission, praw.models.Comment)) -> BaseArchiveEntry:
if isinstance(praw_item, praw.models.Submission):