[cineoob] fillobj almost handled
This commit is contained in:
parent
c23352fc22
commit
3f4aa98fff
4 changed files with 81 additions and 20 deletions
|
|
@ -65,3 +65,22 @@ class ImdbBackend(BaseBackend, ICapCinema):
|
|||
|
||||
def get_person_biography(self,id):
|
||||
return self.browser.get_person_biography(id)
|
||||
|
||||
def fill_person(self, person, fields):
|
||||
if 'real_name' in fields or 'birth_place' in fields\
|
||||
or 'death_date' in fields or 'nationality' in fields\
|
||||
or 'short_biography' in fields or 'roles' in fields\
|
||||
or 'birth_date' in fields\
|
||||
or 'gender' in fields or fields == None:
|
||||
return self.get_person(person.id)
|
||||
else:
|
||||
return person
|
||||
|
||||
def fill_movie(self, movie, fields):
|
||||
if 'other_titles' in fields or 'release_date' in fields\
|
||||
or 'duration' in fields or 'description' in fields\
|
||||
or 'country' in fields or 'roles' in fields\
|
||||
or 'note' in fields or fields == None:
|
||||
return self.get_movie(movie.id)
|
||||
else:
|
||||
return movie
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@
|
|||
|
||||
|
||||
from weboob.tools.browser import BaseBrowser
|
||||
from weboob.capabilities.base import NotAvailable
|
||||
from weboob.capabilities.cinema import Movie
|
||||
from weboob.capabilities.base import NotAvailable, NotLoaded
|
||||
from weboob.capabilities.cinema import Movie, Person
|
||||
from weboob.tools.json import json
|
||||
|
||||
from .pages import MoviePage, PersonPage, MovieCrewPage, BiographyPage, FilmographyPage
|
||||
|
|
@ -49,9 +49,16 @@ class ImdbBrowser(BaseBrowser):
|
|||
for cat in ['title_popular','title_exact','title_approx']:
|
||||
if jres.has_key(cat):
|
||||
for m in jres[cat]:
|
||||
movie = self.get_movie(m['id'])
|
||||
if movie != None:
|
||||
yield movie
|
||||
#movie = self.get_movie(m['id'])
|
||||
movie = Movie(m['id'],unicode(m['title']))
|
||||
movie.other_titles = NotLoaded
|
||||
movie.release_date = NotLoaded
|
||||
movie.duration = NotLoaded
|
||||
movie.description = NotLoaded
|
||||
movie.country = NotLoaded
|
||||
movie.note = NotLoaded
|
||||
movie.roles = NotLoaded
|
||||
yield movie
|
||||
|
||||
def iter_persons(self, pattern):
|
||||
res = self.readurl('http://www.imdb.com/xml/find?json=1&nr=1&nm=on&q=%s' % pattern.encode('utf-8'))
|
||||
|
|
@ -59,7 +66,17 @@ class ImdbBrowser(BaseBrowser):
|
|||
for cat in ['name_popular','name_exact','name_approx']:
|
||||
if jres.has_key(cat):
|
||||
for p in jres[cat]:
|
||||
yield self.get_person(p['id'])
|
||||
#person = self.get_person(p['id'])
|
||||
person = Person(p['id'],p['name'])
|
||||
person.real_name = NotLoaded
|
||||
person.birth_place = NotLoaded
|
||||
person.birth_date = NotLoaded
|
||||
person.death_date = NotLoaded
|
||||
person.gender = NotLoaded
|
||||
person.nationality = NotLoaded
|
||||
person.short_biography= NotLoaded
|
||||
person.roles = NotLoaded
|
||||
yield person
|
||||
|
||||
def get_movie(self, id):
|
||||
res = self.readurl('http://imdbapi.org/?id=%s&type=json&plot=simple&episode=1&lang=en-US&aka=full&release=simple&business=0&tech=0' % id )
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from weboob.capabilities.cinema import Person
|
||||
from weboob.capabilities.cinema import Person, Movie
|
||||
from weboob.capabilities.base import NotAvailable
|
||||
from weboob.tools.browser import BasePage
|
||||
|
||||
|
|
@ -70,7 +70,10 @@ class MovieCrewPage(BasePage):
|
|||
tds = self.parser.select(table,'td.nm')
|
||||
for td in tds:
|
||||
id = td.find('a').attrib.get('href','').strip('/').split('/')[-1]
|
||||
yield self.browser.get_person(id)
|
||||
name = td.find('a').text
|
||||
#yield self.browser.get_person(id)
|
||||
person = Person(id,name)
|
||||
yield person
|
||||
|
||||
for gloss_link in self.parser.select(self.document.getroot(),'table[cellspacing=1] h5 a'):
|
||||
role = gloss_link.attrib.get('name','').rstrip('s')
|
||||
|
|
@ -81,7 +84,10 @@ class MovieCrewPage(BasePage):
|
|||
href = a.attrib.get('href','')
|
||||
if '/name/nm' in href:
|
||||
id = href.strip('/').split('/')[-1]
|
||||
yield self.browser.get_person(id)
|
||||
name = a.text
|
||||
person = Person(id,name)
|
||||
yield person
|
||||
#yield self.browser.get_person(id)
|
||||
|
||||
def iter_persons_ids(self):
|
||||
tables = self.parser.select(self.document.getroot(),'table.cast')
|
||||
|
|
@ -190,6 +196,7 @@ class FilmographyPage(BasePage):
|
|||
for a in self.parser.select(role_div,'ol > li > a'):
|
||||
id = a.attrib.get('href','').strip('/').split('/')[-1]
|
||||
if id.startswith('tt'):
|
||||
movie = self.browser.get_movie(id)
|
||||
if movie != None:
|
||||
yield movie
|
||||
title = a.text
|
||||
#movie = self.browser.get_movie(id)
|
||||
movie = Movie(id,title)
|
||||
yield movie
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue