fix bad covers, update to new doab
parent
a7650dfba6
commit
59b68f0742
|
@ -3,9 +3,30 @@ from django.core.management.base import BaseCommand
|
||||||
import re
|
import re
|
||||||
import requests
|
import requests
|
||||||
from regluit.core.models import Edition
|
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):
|
class Command(BaseCommand):
|
||||||
""" To repair covers, will need a new refresh_cover method"""
|
""" To repair covers, will need a new refresh_cover method"""
|
||||||
|
@ -24,7 +45,7 @@ class Command(BaseCommand):
|
||||||
self.fix_doab_cover(doab)
|
self.fix_doab_cover(doab)
|
||||||
|
|
||||||
def fix_doab_cover(self, 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)
|
cover_url = self.refresh_cover(doab)
|
||||||
if cover_url:
|
if cover_url:
|
||||||
|
@ -32,9 +53,9 @@ class Command(BaseCommand):
|
||||||
e.cover_image = cover_url
|
e.cover_image = cover_url
|
||||||
e.save()
|
e.save()
|
||||||
if e.cover_image_small() and e.cover_image_thumbnail():
|
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:
|
else:
|
||||||
self.stdout.write('bad thumbnails for %s' % new_doab.group(1))
|
self.stdout.write('bad thumbnails for %s' % cover_url)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
self.stdout.write('removing bad cover for %s' % doab)
|
self.stdout.write('removing bad cover for %s' % doab)
|
||||||
|
@ -53,4 +74,4 @@ class Command(BaseCommand):
|
||||||
self.stdout.write('fixed %s covers' % eds.count())
|
self.stdout.write('fixed %s covers' % eds.count())
|
||||||
|
|
||||||
def refresh_cover(self, doab):
|
def refresh_cover(self, doab):
|
||||||
return False
|
return doab_cover(doab)
|
||||||
|
|
Loading…
Reference in New Issue