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):
|
def find(info, guess=True):
|
||||||
q = Imdb.objects.all()
|
q = Imdb.objects.all()
|
||||||
if 'seriesTitle' in info:
|
if 'id' in info:
|
||||||
info['title'] = info['seriesTitle']
|
q = q.filter(imdb=info['id'])
|
||||||
for key in Imdb.keys:
|
else:
|
||||||
if key in info and info[key]:
|
if 'seriesTitle' in info:
|
||||||
if isinstance(info[key], basestring):
|
info['title'] = info['seriesTitle']
|
||||||
fkey = '%s__iexact'%key
|
for key in Imdb.keys:
|
||||||
else:
|
if key in info and info[key]:
|
||||||
fkey = key
|
if isinstance(info[key], basestring):
|
||||||
if isinstance(info[key], list):
|
fkey = '%s__iexact'%key
|
||||||
q = q.filter(**{fkey: '\n'.join(info[key]) + '\n'})
|
else:
|
||||||
else:
|
fkey = key
|
||||||
q = q.filter(**{fkey:info[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:
|
if q.count() == 1:
|
||||||
return q[0]
|
return q[0]
|
||||||
#For now fallback to ox.web.imdb.guess and try again
|
#For now fallback to ox.web.imdb.guess and try again
|
||||||
|
|
Loading…
Reference in a new issue