X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/36a272da03363cae901a0aa0d768735da3ea5130..8ac560f9402b05f2811bf8207338110f01e2e576:/apps/cover/management/commands/refresh_covers.py diff --git a/apps/cover/management/commands/refresh_covers.py b/apps/cover/management/commands/refresh_covers.py index 540304dc..1097a754 100644 --- a/apps/cover/management/commands/refresh_covers.py +++ b/apps/cover/management/commands/refresh_covers.py @@ -21,8 +21,8 @@ class Command(BaseCommand): def handle(self, *args, **options): from_id = options.get('from_id', 1) for image in Image.objects.filter(id__gte=from_id).exclude(book=None).order_by('id'): - print image.id - if image.source_url and 'flickr.com' in image.source_url: + if image.source_url and 'flickr.com' in image.source_url and not image.download_url.endswith('_o.jpg'): + print image.id try: flickr_data = get_flickr_data(image.source_url) print flickr_data @@ -36,12 +36,12 @@ class Command(BaseCommand): print 'Download url already present in image %s' % same_url.get().id continue try: - t = URLOpener().open(flickr_data['download_url']).read() + t = URLOpener().open(flickr_url).read() except urllib.URLError: print 'Broken download url' except IOError: print 'Connection failed' else: - image.download_url = flickr_data['download_url'] + image.download_url = flickr_url image.file.save(image.file.name, ContentFile(t)) image.save()