This commit is contained in:
j 2012-07-05 15:49:00 +02:00
parent 752242e40c
commit e3ffa98d92

View file

@ -11,6 +11,7 @@ from django.db.models import Q
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.core.files.base import ContentFile from django.core.files.base import ContentFile
import ox
import ox.web.criterion import ox.web.criterion
import ox.web.movieposterdb import ox.web.movieposterdb
import ox.web.imdb import ox.web.imdb
@ -76,6 +77,7 @@ class PosterCache(models.Model):
try: try:
data = ox.net.readUrl(url) data = ox.net.readUrl(url)
self.image.name = poster_path(self.url, 'image.jpg') self.image.name = poster_path(self.url, 'image.jpg')
ox.makedirs(os.path.dirname(self.image.path))
with open(self.image.path, 'w') as f: with open(self.image.path, 'w') as f:
f.write(data) f.write(data)
self.save() self.save()