From 6566afd92f289ec0266453d110e9bd8c997e1f70 Mon Sep 17 00:00:00 2001 From: eric Date: Wed, 29 Jul 2020 13:34:11 -0400 Subject: [PATCH] support single ebook harvest --- core/management/commands/harvest_online_ebooks.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/management/commands/harvest_online_ebooks.py b/core/management/commands/harvest_online_ebooks.py index 42a18bfc..d2f3f353 100644 --- a/core/management/commands/harvest_online_ebooks.py +++ b/core/management/commands/harvest_online_ebooks.py @@ -9,11 +9,15 @@ class Command(BaseCommand): def add_arguments(self, parser): parser.add_argument('limit', nargs='?', type=int, default=0, help="max to harvest") + parser.add_argument('--ebook', nargs='?', type=int, default=0, help="ebook to harvest") def handle(self, limit=0, **options): limit = int(limit) if limit else 0 rl = RateLimiter() - onlines = Ebook.objects.filter(format='online') + if options.get('ebook'): + onlines = Ebook.objects.filter(id=options.get('ebook')) + else: + onlines = Ebook.objects.filter(format='online') done = 0 for online in onlines: new_ebf, new = dl_online(online, limiter=rl.delay)