use ox.web.imdb.getMovieId but check result

This commit is contained in:
j 2011-10-14 15:50:18 +02:00
parent 1d38283276
commit b826a13125
2 changed files with 10 additions and 1 deletions

View file

@ -7,7 +7,7 @@ from django.db import models
import ox
def find(info):
def find(info, guess=True):
q = Imdb.objects.all()
for key in Imdb.keys:
if key in info and info[key]:
@ -21,6 +21,14 @@ def find(info):
q = q.filter(**{fkey:info[key]})
if q.count() == 1:
return q[0]
#For now fallback to ox.web.imdb.guess and try again
if guess:
id = ox.web.imdb.getMovieId(info['title'])
if id:
i, created = Imdb.objects.get_or_create(imdb=id)
if created:
i.update()
return find(info, False)
return None
class Imdb(models.Model):

View file

@ -0,0 +1 @@
500 error