- flickr_url = flickr_data['download_url']
- if flickr_url != image.download_url:
- same_url = Image.objects.filter(download_url=flickr_url)
- if same_url:
- print 'Download url already present in image %s' % same_url.get().id
- continue
- try:
- t = URLOpener().open(flickr_url).read()
- except urllib.URLError:
- print 'Broken download url'
- except IOError:
- print 'Connection failed'
- else:
- image.download_url = flickr_url
- image.file.save(image.file.name, ContentFile(t))
- image.save()
+ image.download_url = flickr_url
+ image.file.save(image.file.name, ContentFile(t))
+ image.save()