From 59b68f074257e13adc28d8889443919cb6754552 Mon Sep 17 00:00:00 2001 From: eric Date: Mon, 12 Apr 2021 12:21:01 -0400 Subject: [PATCH] fix bad covers, update to new doab --- core/management/commands/fix_doab_covers.py | 33 +++++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/core/management/commands/fix_doab_covers.py b/core/management/commands/fix_doab_covers.py index 5623cf68..290ac934 100644 --- a/core/management/commands/fix_doab_covers.py +++ b/core/management/commands/fix_doab_covers.py @@ -3,9 +3,30 @@ from django.core.management.base import BaseCommand import re import requests from regluit.core.models import Edition +from regluit.core.loaders.doab_utils import doab_cover -to_fix = [] - +to_fix = [ +"20.500.12854/25941", +"20.500.12854/29841", +"20.500.12854/30286", +"20.500.12854/39341", +"20.500.12854/41049", +"20.500.12854/41911", +"20.500.12854/44478", +"20.500.12854/44685", +"20.500.12854/45396", +"20.500.12854/47243", +"20.500.12854/47305", +"20.500.12854/48790", +"20.500.12854/52599", +"20.500.12854/56238", +"20.500.12854/58193", +"20.500.12854/58504", +"20.500.12854/58546", +"20.500.12854/58889", +"20.500.12854/62025", +"20.500.12854/62618" +] class Command(BaseCommand): """ To repair covers, will need a new refresh_cover method""" @@ -24,7 +45,7 @@ class Command(BaseCommand): self.fix_doab_cover(doab) def fix_doab_cover(self, doab): - eds = Edition.objects.filter(cover_image__contains='amazonaws.com/doab/%s/cover' % doab) + eds = Edition.objects.filter(cover_image__contains='amazonaws.com/doab/%s' % doab) cover_url = self.refresh_cover(doab) if cover_url: @@ -32,9 +53,9 @@ class Command(BaseCommand): e.cover_image = cover_url e.save() if e.cover_image_small() and e.cover_image_thumbnail(): - self.stdout.write('fixed %s using %s' % (doab, new_doab.group(1))) + self.stdout.write('fixed %s using %s' % (doab, cover_url)) else: - self.stdout.write('bad thumbnails for %s' % new_doab.group(1)) + self.stdout.write('bad thumbnails for %s' % cover_url) return False return True self.stdout.write('removing bad cover for %s' % doab) @@ -53,4 +74,4 @@ class Command(BaseCommand): self.stdout.write('fixed %s covers' % eds.count()) def refresh_cover(self, doab): - return False + return doab_cover(doab)