use ox/ox.web/ox.django
This commit is contained in:
parent
e38385fcd8
commit
f7a9ce1364
10 changed files with 40 additions and 160 deletions
|
|
@ -3,13 +3,13 @@
|
|||
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
|
||||
from ox.cache import getUrlUnicode
|
||||
from ox import findRe
|
||||
import ox.net
|
||||
import ox.web.criterion
|
||||
import ox.web.karagarga
|
||||
import ox.web.imdb
|
||||
import ox.web.impawards
|
||||
|
||||
import models
|
||||
from oxdata.poster.models import PosterCache
|
||||
|
|
@ -20,10 +20,10 @@ def addPoster(m, url, site, site_id):
|
|||
p.save()
|
||||
|
||||
def getIds():
|
||||
for id in oxweb.impawards.getIds():
|
||||
for id in ox.web.impawards.getIds():
|
||||
if models.MovieId.objects.all().filter(impawards_id=id).count() == 0:
|
||||
print 'impawards', id
|
||||
data = oxweb.impawards.getData(id)
|
||||
data = ox.web.impawards.getData(id)
|
||||
if data and 'imdbId' in data:
|
||||
m = models.getMovieIdByImdbId(data['imdbId'])
|
||||
if not m.impawards_id:
|
||||
|
|
@ -32,10 +32,10 @@ def getIds():
|
|||
for poster in data['posters']:
|
||||
addPoster(m, poster, 'impawards.com', m.imdb_id)
|
||||
|
||||
for id in oxweb.criterion.getIds():
|
||||
for id in ox.web.criterion.getIds():
|
||||
if models.MovieId.objects.all().filter(criterion_id=id).count() == 0:
|
||||
print 'criterion', id
|
||||
data = oxweb.criterion.getData(id)
|
||||
data = ox.web.criterion.getData(id)
|
||||
if data and 'imdbId' in data:
|
||||
m = models.getMovieIdByImdbId(data['imdbId'])
|
||||
if not m.criterion_id:
|
||||
|
|
@ -47,10 +47,10 @@ def getIds():
|
|||
|
||||
#kg
|
||||
lastId = models.Karagarga.maxId()
|
||||
for id in oxweb.karagarga.getIds(lastId):
|
||||
for id in ox.web.karagarga.getIds(lastId):
|
||||
if models.Karagarga.objects.filter(karagarga_id=id).count() == 0:
|
||||
print 'kg', id
|
||||
data = oxweb.karagarga.getData(id)
|
||||
data = ox.web.karagarga.getData(id)
|
||||
if data and 'imdbId' in data:
|
||||
m = models.getMovieIdByImdbId(data['imdbId'])
|
||||
kg = models.Karagarga()
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ from django.db.models import Q, Max
|
|||
from django.contrib.auth.models import User
|
||||
from django.utils import simplejson
|
||||
|
||||
import oxweb.wikipedia
|
||||
import oxweb.imdb
|
||||
from oxlib import stripTags
|
||||
import ox.web.wikipedia
|
||||
import ox.web.imdb
|
||||
from ox import stripTags
|
||||
|
||||
|
||||
def getMovieIdByImdbId(imdb_id):
|
||||
|
|
@ -56,8 +56,8 @@ class MovieId(models.Model):
|
|||
|
||||
def updateFromWikipedia(self):
|
||||
if self.wikipedia_id:
|
||||
wikipedia_url = oxweb.wikipedia.getUrl(self.wikipedia_id)
|
||||
data = oxweb.wikipedia.getMovieData(wikipedia_url)
|
||||
wikipedia_url = ox.web.wikipedia.getUrl(self.wikipedia_id)
|
||||
data = ox.web.wikipedia.getMovieData(wikipedia_url)
|
||||
_key = {}
|
||||
for key in ('imdb_id', 'amg_id'):
|
||||
if key in data:
|
||||
|
|
@ -67,7 +67,7 @@ class MovieId(models.Model):
|
|||
|
||||
def updateFromImdb(self):
|
||||
if self.imdb_id:
|
||||
data = oxweb.imdb.getMovieInfo(self.imdb_id)
|
||||
data = ox.web.imdb.getMovieInfo(self.imdb_id)
|
||||
_key = {
|
||||
'episode title': 'episode_title',
|
||||
'series title': 'series_title',
|
||||
|
|
@ -76,12 +76,12 @@ class MovieId(models.Model):
|
|||
if key in data and data[key]:
|
||||
setattr(self, _key.get(key, key), data[key])
|
||||
directors = []
|
||||
credits = oxweb.imdb.getMovieCredits(self.imdb_id)
|
||||
credits = ox.web.imdb.getMovieCredits(self.imdb_id)
|
||||
if 'directors' in credits:
|
||||
directors = credits['directors']
|
||||
self.director = ', '.join([stripTags(d[0]) for d in directors])
|
||||
if not self.wikipedia_id:
|
||||
self.wikipedia_id = oxweb.wikipedia.getId(oxweb.wikipedia.getUrlByImdb(self.imdb_id))
|
||||
self.wikipedia_id = ox.web.wikipedia.getId(ox.web.wikipedia.getUrlByImdb(self.imdb_id))
|
||||
if not self.oxdb_id:
|
||||
self.gen_oxdb_id()
|
||||
self.save()
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ from django.db import models
|
|||
from django.db.models import Q
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from oxdata.utils.shortcuts import render_to_json_response
|
||||
from ox.django.shortcuts import render_to_json_response
|
||||
|
||||
def ids(request):
|
||||
json = {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue