From 896a5f3441c2a1d944ffba5dcaa2d5495f60fa7a Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 20 Dec 2011 19:55:07 +0530 Subject: [PATCH] add google link --- oxdata/lookup/models.py | 3 +++ oxdata/movie/models.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/oxdata/lookup/models.py b/oxdata/lookup/models.py index 9b45f78..05aeccd 100644 --- a/oxdata/lookup/models.py +++ b/oxdata/lookup/models.py @@ -2,6 +2,7 @@ # vi:si:et:sw=4:sts=4:ts=4 import os import hashlib +from urllib import quote from django.db import models from django.db.models import Q, Max @@ -130,6 +131,8 @@ class MovieId(models.Model): if self.criterion_id: links.append({'source': 'Criterion', 'url': ox.web.criterion.getUrl(self.criterion_id)}) + links.append({'source': 'Google', + 'url': 'http://google.com/search?q=%s' % quote('"%s (%s)"'%(self.title, self.year))}) return links def json(self): diff --git a/oxdata/movie/models.py b/oxdata/movie/models.py index 6d8f0c3..5560d2e 100644 --- a/oxdata/movie/models.py +++ b/oxdata/movie/models.py @@ -11,6 +11,10 @@ def find(info, guess=True): q = Imdb.objects.all() if 'id' in info: q = q.filter(imdb=info['id']) + if q.count() == 0 and len(info['id']) == 7: + i = Imdb(imdb=info['id']) + i.save() + q = Imdb.objects.filter(imdb=info['id']) else: if 'seriesTitle' in info: info['title'] = info['seriesTitle']