also import impaward posters if impaward id exists

This commit is contained in:
j 2009-07-21 16:38:55 +02:00
parent 14eec9e832
commit df6ffb7260

View file

@ -12,6 +12,7 @@ import oxweb.criterion
import oxweb.movieposterdb import oxweb.movieposterdb
import oxweb.karagarga import oxweb.karagarga
import oxweb.imdb import oxweb.imdb
import oxweb.impawards
from oxdata.lookup.models import MovieId, Karagarga from oxdata.lookup.models import MovieId, Karagarga
@ -84,32 +85,35 @@ class Poster(models.Model):
def getPosterUrls(m): def getPosterUrls(m):
def addPoster(url, site, site_id): def addPoster(url, site, site_id):
if PosterCache.objects.all().filter(url=url).count() == 0:
p = PosterCache(url=url, site=site, site_id=site_id, movie_id=m) p = PosterCache(url=url, site=site, site_id=site_id, movie_id=m)
p.save() p.save()
if m.imdb_id: if m.imdb_id:
poster = oxweb.imdb.getMoviePoster(m.imdb_id) poster = oxweb.imdb.getMoviePoster(m.imdb_id)
if poster: if poster:
if PosterCache.objects.all().filter(url=poster).count() == 0:
addPoster(poster, 'imdb.com', m.imdb_id) addPoster(poster, 'imdb.com', m.imdb_id)
for poster in oxweb.movieposterdb.getData(m.imdb_id)['posters']: for poster in oxweb.movieposterdb.getData(m.imdb_id)['posters']:
if PosterCache.objects.all().filter(url=poster).count() == 0:
addPoster(poster, 'movieposterdb.com', m.imdb_id) addPoster(poster, 'movieposterdb.com', m.imdb_id)
if m.criterion_id: if m.criterion_id:
print 'criterion', m.criterion_id print 'criterion', m.criterion_id
for poster in oxweb.criterion.getData(m.criterion_id)['posters']: for poster in oxweb.criterion.getData(m.criterion_id)['posters']:
if PosterCache.objects.all().filter(url=poster).count() == 0:
addPoster(poster, 'criterion.com', m.criterion_id) addPoster(poster, 'criterion.com', m.criterion_id)
if m.wikipedia_id: if m.wikipedia_id:
poster = oxweb.wikipedia.getPosterUrl(m.wikipedia_id) poster = oxweb.wikipedia.getPosterUrl(m.wikipedia_id)
if poster: if poster:
if PosterCache.objects.all().filter(url=poster).count() == 0: if PosterCache.objects.all().filter(url=poster).count() == 0:
addPoster(poster, 'wikipedia.org', m.wikipedia_id) addPoster(poster, 'wikipedia.org', m.wikipedia_id)
if m.impawards_id:
data = oxweb.impawards.getData(m.impawards_id)
if data and 'imdbId' in data:
for poster in data['posters']:
addPoster(poster, 'impawards.com', m.imdb_id)
for kg in Karagarga.objects.all().filter(movie_id=m): for kg in Karagarga.objects.all().filter(movie_id=m):
data = oxweb.karagarga.getData(kg.karagarga_id) data = oxweb.karagarga.getData(kg.karagarga_id)
if data: if data:
for poster in data['posters']: for poster in data['posters']:
if PosterCache.objects.all().filter(url=poster).count() == 0:
addPoster(poster, 'karagarga.net', kg.karagarga_id) addPoster(poster, 'karagarga.net', kg.karagarga_id)
else: else:
kg.delete() kg.delete()