Add search functionality

This commit is contained in:
Serene-Arc
2021-02-11 16:31:28 +10:00
committed by Ali Parlakci
parent a7f1db14e5
commit 91ae9924c3

View File

@@ -90,6 +90,9 @@ class RedditDownloader:
def _get_subreddits(self, args: argparse.Namespace) -> list[praw.models.ListingGenerator]: def _get_subreddits(self, args: argparse.Namespace) -> list[praw.models.ListingGenerator]:
if args.subreddit: if args.subreddit:
subreddits = [self.reddit_instance.subreddit(chosen_subreddit) for chosen_subreddit in args.subreddit] subreddits = [self.reddit_instance.subreddit(chosen_subreddit) for chosen_subreddit in args.subreddit]
if args.search:
return [reddit.search(args.search, sort=self.sort_filter.name.lower()) for reddit in subreddits]
else:
if self.sort_filter is RedditTypes.SortType.NEW: if self.sort_filter is RedditTypes.SortType.NEW:
sort_function = praw.models.Subreddit.new sort_function = praw.models.Subreddit.new
elif self.sort_filter is RedditTypes.SortType.RISING: elif self.sort_filter is RedditTypes.SortType.RISING: