add archive.org link

This commit is contained in:
j 2012-01-13 19:22:33 +05:30
parent 2f1e6a7d66
commit f9f39dff4a

View file

@ -43,6 +43,7 @@ class MovieId(models.Model):
imdb_id = models.CharField(max_length=7, unique=True, blank=True, null=True, default=None) imdb_id = models.CharField(max_length=7, unique=True, blank=True, null=True, default=None)
amg_id = models.IntegerField(unique=True, blank=True, null=True, default=None) amg_id = models.IntegerField(unique=True, blank=True, null=True, default=None)
archiveorg_id = models.IntegerField(unique=True, blank=True, null=True, default=None)
wikipedia_id = models.CharField(unique=True, max_length=255, blank=True, null=True, default=None) wikipedia_id = models.CharField(unique=True, max_length=255, blank=True, null=True, default=None)
criterion_id = models.IntegerField(unique=True, blank=True, null=True, default=None) criterion_id = models.IntegerField(unique=True, blank=True, null=True, default=None)
impawards_id = models.CharField(max_length=255, unique=True, blank=True, null=True, default=None) impawards_id = models.CharField(max_length=255, unique=True, blank=True, null=True, default=None)
@ -63,7 +64,7 @@ class MovieId(models.Model):
wikipedia_url = ox.web.wikipedia.getUrl(self.wikipedia_id) wikipedia_url = ox.web.wikipedia.getUrl(self.wikipedia_id)
data = ox.web.wikipedia.getMovieData(wikipedia_url) data = ox.web.wikipedia.getMovieData(wikipedia_url)
_key = {} _key = {}
for key in ('imdb_id', 'amg_id'): for key in ('imdb_id', 'amg_id', 'archiveorg_id'):
if key in data: if key in data:
if data[key] and not getattr(self, _key.get(key, key)): if data[key] and not getattr(self, _key.get(key, key)):
setattr(self, _key.get(key, key), data[key]) setattr(self, _key.get(key, key), data[key])
@ -131,6 +132,9 @@ class MovieId(models.Model):
if self.criterion_id: if self.criterion_id:
links.append({'source': 'Criterion', links.append({'source': 'Criterion',
'url': ox.web.criterion.getUrl(self.criterion_id)}) 'url': ox.web.criterion.getUrl(self.criterion_id)})
if self.archiveorg_id:
links.append({'source': 'Wikipedia',
'url': ox.web.archive.getUrl(self.archiveorg_id)})
links.append({'source': 'Google', links.append({'source': 'Google',
'url': 'http://google.com/search?q=%s' % quote('"%s (%s)"'%(self.title, self.year))}) 'url': 'http://google.com/search?q=%s' % quote('"%s (%s)"'%(self.title, self.year))})
return links return links