support id in query
This commit is contained in:
parent
778639def8
commit
767176fa09
1 changed files with 15 additions and 12 deletions
|
@ -9,18 +9,21 @@ import ox
|
|||
|
||||
def find(info, guess=True):
|
||||
q = Imdb.objects.all()
|
||||
if 'seriesTitle' in info:
|
||||
info['title'] = info['seriesTitle']
|
||||
for key in Imdb.keys:
|
||||
if key in info and info[key]:
|
||||
if isinstance(info[key], basestring):
|
||||
fkey = '%s__iexact'%key
|
||||
else:
|
||||
fkey = key
|
||||
if isinstance(info[key], list):
|
||||
q = q.filter(**{fkey: '\n'.join(info[key]) + '\n'})
|
||||
else:
|
||||
q = q.filter(**{fkey:info[key]})
|
||||
if 'id' in info:
|
||||
q = q.filter(imdb=info['id'])
|
||||
else:
|
||||
if 'seriesTitle' in info:
|
||||
info['title'] = info['seriesTitle']
|
||||
for key in Imdb.keys:
|
||||
if key in info and info[key]:
|
||||
if isinstance(info[key], basestring):
|
||||
fkey = '%s__iexact'%key
|
||||
else:
|
||||
fkey = key
|
||||
if isinstance(info[key], list):
|
||||
q = q.filter(**{fkey: '\n'.join(info[key]) + '\n'})
|
||||
else:
|
||||
q = q.filter(**{fkey:info[key]})
|
||||
if q.count() == 1:
|
||||
return q[0]
|
||||
#For now fallback to ox.web.imdb.guess and try again
|
||||
|
|
Loading…
Reference in a new issue