[imdb] clean, [cineoob] clean

This commit is contained in:
Julien Veyssier 2013-03-07 02:58:23 +01:00
commit fa42b82c69
4 changed files with 16 additions and 13 deletions

View file

@ -53,7 +53,6 @@ class ImdbBrowser(BaseBrowser):
short_description = u'%s %s'%(tdesc.split('<')[0].strip(', '), tdesc.split('>')[1].split('<')[0]) short_description = u'%s %s'%(tdesc.split('<')[0].strip(', '), tdesc.split('>')[1].split('<')[0])
else: else:
short_description = tdesc.strip(', ') short_description = tdesc.strip(', ')
#movie = self.get_movie(m['id'])
movie = Movie(m['id'],unicode(m['title'])) movie = Movie(m['id'],unicode(m['title']))
movie.other_titles = NotLoaded movie.other_titles = NotLoaded
movie.release_date = NotLoaded movie.release_date = NotLoaded
@ -71,9 +70,8 @@ class ImdbBrowser(BaseBrowser):
for cat in ['name_popular','name_exact','name_approx']: for cat in ['name_popular','name_exact','name_approx']:
if jres.has_key(cat): if jres.has_key(cat):
for p in jres[cat]: for p in jres[cat]:
#person = self.get_person(p['id']) person = Person(p['id'],unicode(p['name']))
person = Person(p['id'],p['name']) person.real_name = NotLoaded
person.real_name = NotLoaded
person.birth_place = NotLoaded person.birth_place = NotLoaded
person.birth_date = NotLoaded person.birth_date = NotLoaded
person.death_date = NotLoaded person.death_date = NotLoaded
@ -103,7 +101,7 @@ class ImdbBrowser(BaseBrowser):
title = unicode(jres['title'].strip()) title = unicode(jres['title'].strip())
if jres.has_key('directors'): if jres.has_key('directors'):
short_description = ', '.join(jres['directors']) short_description = unicode(', '.join(jres['directors']))
if jres.has_key('runtime'): if jres.has_key('runtime'):
dur_str = jres['runtime'][0].split(':') dur_str = jres['runtime'][0].split(':')
if len(dur_str) == 1: if len(dur_str) == 1:

View file

@ -19,7 +19,7 @@
from weboob.capabilities.cinema import Person, Movie from weboob.capabilities.cinema import Person, Movie
from weboob.capabilities.base import NotAvailable from weboob.capabilities.base import NotAvailable, NotLoaded
from weboob.tools.browser import BasePage from weboob.tools.browser import BasePage
from datetime import datetime from datetime import datetime
@ -56,9 +56,16 @@ class MovieCrewPage(BasePage):
id = td.find('a').attrib.get('href','').strip('/').split('/')[-1] id = td.find('a').attrib.get('href','').strip('/').split('/')[-1]
name = unicode(td.find('a').text) name = unicode(td.find('a').text)
char_name = unicode(self.parser.select(td.getparent(),'td.char',1).text_content()) char_name = unicode(self.parser.select(td.getparent(),'td.char',1).text_content())
#yield self.browser.get_person(id)
person = Person(id,name) person = Person(id,name)
person.short_description = char_name person.short_description = char_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 yield person
for gloss_link in self.parser.select(self.document.getroot(),'table[cellspacing=1] h5 a'): for gloss_link in self.parser.select(self.document.getroot(),'table[cellspacing=1] h5 a'):
@ -189,7 +196,7 @@ class FilmographyPage(BasePage):
for a in self.parser.select(role_div,'ol > li > a'): for a in self.parser.select(role_div,'ol > li > a'):
id = a.attrib.get('href','').strip('/').split('/')[-1] id = a.attrib.get('href','').strip('/').split('/')[-1]
if id.startswith('tt'): if id.startswith('tt'):
title = a.text title = unicode(a.text)
role_detail = NotAvailable role_detail = NotAvailable
if len(a.tail) > 0: if len(a.tail) > 0:
role_detail = unicode(' '.join(a.tail.replace('..','').split())) role_detail = unicode(' '.join(a.tail.replace('..','').split()))

View file

@ -19,8 +19,6 @@
from weboob.tools.test import BackendTest from weboob.tools.test import BackendTest
#from random import choice
class ImdbTest(BackendTest): class ImdbTest(BackendTest):
BACKEND = 'imdb' BACKEND = 'imdb'

View file

@ -23,7 +23,7 @@ import sys
from datetime import datetime from datetime import datetime
from weboob.capabilities.cinema import ICapCinema from weboob.capabilities.cinema import ICapCinema
from weboob.capabilities.base import NotAvailable, NotLoaded from weboob.capabilities.base import NotAvailable
from weboob.tools.application.repl import ReplApplication from weboob.tools.application.repl import ReplApplication
from weboob.tools.application.formatters.iformatter import IFormatter, PrettyFormatter from weboob.tools.application.formatters.iformatter import IFormatter, PrettyFormatter
@ -262,7 +262,7 @@ class Cineoob(ReplApplication):
print >>sys.stderr, 'Movie not found: %s' % id print >>sys.stderr, 'Movie not found: %s' % id
return 3 return 3
backend.fillobj(movie, ('duration')) #backend.fillobj(movie, ('duration'))
self.start_format() self.start_format()
self.format(movie) self.format(movie)
@ -287,7 +287,7 @@ class Cineoob(ReplApplication):
print >>sys.stderr, 'Person not found: %s' % id print >>sys.stderr, 'Person not found: %s' % id
return 3 return 3
backend.fillobj(person, ('birth_date','short_biography')) #backend.fillobj(person, ('birth_date','short_biography'))
self.start_format() self.start_format()
self.format(person) self.format(person)