also import impaward posters if impaward id exists
This commit is contained in:
parent
14eec9e832
commit
df6ffb7260
1 changed files with 14 additions and 10 deletions
|
@ -12,6 +12,7 @@ import oxweb.criterion
|
|||
import oxweb.movieposterdb
|
||||
import oxweb.karagarga
|
||||
import oxweb.imdb
|
||||
import oxweb.impawards
|
||||
|
||||
from oxdata.lookup.models import MovieId, Karagarga
|
||||
|
||||
|
@ -84,32 +85,35 @@ class Poster(models.Model):
|
|||
|
||||
def getPosterUrls(m):
|
||||
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.save()
|
||||
|
||||
if m.imdb_id:
|
||||
poster = oxweb.imdb.getMoviePoster(m.imdb_id)
|
||||
if poster:
|
||||
if PosterCache.objects.all().filter(url=poster).count() == 0:
|
||||
addPoster(poster, 'imdb.com', m.imdb_id)
|
||||
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)
|
||||
if m.criterion_id:
|
||||
print 'criterion', m.criterion_id
|
||||
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)
|
||||
if m.wikipedia_id:
|
||||
poster = oxweb.wikipedia.getPosterUrl(m.wikipedia_id)
|
||||
if poster:
|
||||
if PosterCache.objects.all().filter(url=poster).count() == 0:
|
||||
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):
|
||||
data = oxweb.karagarga.getData(kg.karagarga_id)
|
||||
if data:
|
||||
for poster in data['posters']:
|
||||
if PosterCache.objects.all().filter(url=poster).count() == 0:
|
||||
addPoster(poster, 'karagarga.net', kg.karagarga_id)
|
||||
else:
|
||||
kg.delete()
|
||||
|
|
Loading…
Reference in a new issue