2009-07-15 16:39:28 +00:00
|
|
|
# -*- coding: UTF-8 -*-
|
|
|
|
# vi:si:et:sw=4:sts=4:ts=4
|
|
|
|
import os
|
|
|
|
|
|
|
|
from django.conf import settings
|
|
|
|
from oxlib.cache import getUrlUnicode
|
|
|
|
from oxlib import findRe
|
|
|
|
import oxlib.net
|
|
|
|
import oxweb.criterion
|
|
|
|
import oxweb.karagarga
|
|
|
|
import oxweb.imdb
|
|
|
|
import oxweb.impawards
|
|
|
|
|
|
|
|
import models
|
|
|
|
from oxdata.poster.models import PosterCache
|
|
|
|
|
|
|
|
def addPoster(m, 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()
|
|
|
|
|
|
|
|
def getIds():
|
|
|
|
for id in oxweb.impawards.getIds():
|
|
|
|
if models.MovieId.objects.all().filter(impawards_id=id).count() == 0:
|
2009-07-15 18:19:56 +00:00
|
|
|
print 'impawards', id
|
2009-07-15 16:39:28 +00:00
|
|
|
data = oxweb.impawards.getData(id)
|
2009-07-17 15:17:50 +00:00
|
|
|
if data and 'imdbId' in data:
|
2009-07-15 16:39:28 +00:00
|
|
|
m = models.getMovieIdByImdbId(data['imdbId'])
|
|
|
|
if not m.impawards_id:
|
|
|
|
m.impawards_id = id
|
|
|
|
m.save()
|
|
|
|
for poster in data['posters']:
|
|
|
|
addPoster(m, poster, 'impawards.com', m.imdb_id)
|
|
|
|
|
2009-07-17 15:17:50 +00:00
|
|
|
for id in oxweb.criterion.getIds():
|
2009-07-15 16:39:28 +00:00
|
|
|
if models.MovieId.objects.all().filter(criterion_id=id).count() == 0:
|
2009-07-15 18:19:56 +00:00
|
|
|
print 'criterion', id
|
2009-07-17 15:17:50 +00:00
|
|
|
data = oxweb.criterion.getData(id)
|
|
|
|
if data and 'imdbId' in data:
|
2009-07-15 16:39:28 +00:00
|
|
|
m = models.getMovieIdByImdbId(data['imdbId'])
|
|
|
|
if not m.criterion_id:
|
|
|
|
m.criterion_id = id
|
|
|
|
m.save()
|
|
|
|
addPoster(m, poster, 'criterion.com', m.criterion_id)
|
|
|
|
|
|
|
|
#kg
|
|
|
|
lastId = models.Karagarga.maxId()
|
2009-07-17 15:17:50 +00:00
|
|
|
for id in oxweb.karagarga.getIds(lastId):
|
|
|
|
if models.Karagarga.objects.filter(karagarga_id=id).count() == 0:
|
2009-07-15 18:19:56 +00:00
|
|
|
print 'kg', id
|
2009-07-17 15:17:50 +00:00
|
|
|
data = oxweb.karagarga.getData(id)
|
|
|
|
if data and 'imdbId' in data:
|
2009-07-15 16:39:28 +00:00
|
|
|
if 'imdbId' in data:
|
|
|
|
m = models.getMovieIdByImdbId(data['imdbId'])
|
|
|
|
kg = models.Karagarga()
|
|
|
|
kg.movie_id = m
|
2009-07-17 15:17:50 +00:00
|
|
|
kg.karagarga_id = id
|
2009-07-15 16:39:28 +00:00
|
|
|
kg.save()
|
|
|
|
#fixme, what to do else?
|
|
|
|
for poster in data['posters']:
|
2009-07-17 15:17:50 +00:00
|
|
|
addPoster(m, poster, 'karagarga.net', kg.karagarga_id)
|
2009-07-15 16:39:28 +00:00
|
|
|
|