fix bad covers, update to new doab

pull/94/head
eric 2021-04-12 12:21:01 -04:00
parent a7650dfba6
commit 59b68f0742
1 changed files with 27 additions and 6 deletions

View File

@ -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)