[cineoob] get_object cleaning

This commit is contained in:
Julien Veyssier 2013-03-10 22:52:28 +01:00
commit c3c0561887
4 changed files with 18 additions and 28 deletions

View file

@ -104,6 +104,10 @@ class ImdbBackend(BaseBackend, ICapCinema):
movie.note = mov.note movie.note = mov.note
movie.roles = mov.roles movie.roles = mov.roles
movie.short_description= mov.short_description movie.short_description= mov.short_description
if 'all_release_dates' in fields:
movie.all_release_dates = self.get_movie_releases(movie.id)
return movie return movie
OBJECTS = { OBJECTS = {

View file

@ -63,6 +63,7 @@ class ImdbBrowser(BaseBrowser):
movie.country = NotLoaded movie.country = NotLoaded
movie.note = NotLoaded movie.note = NotLoaded
movie.roles = NotLoaded movie.roles = NotLoaded
movie.all_release_dates= NotLoaded
yield movie yield movie
def iter_persons(self, pattern): def iter_persons(self, pattern):
@ -149,6 +150,7 @@ class ImdbBrowser(BaseBrowser):
movie.note = note movie.note = note
movie.roles = roles movie.roles = roles
movie.short_description= short_description movie.short_description= short_description
movie.all_release_dates= NotLoaded
return movie return movie
def get_person(self, id): def get_person(self, id):

View file

@ -41,12 +41,17 @@ class ReleasePage(BasePage):
country = a.text country = a.text
td_date = self.parser.select(a.getparent().getparent().getparent(),'td')[1] td_date = self.parser.select(a.getparent().getparent().getparent(),'td')[1]
date_links = self.parser.select(td_date,'a') date_links = self.parser.select(td_date,'a')
date = date_links[1].attrib.get('href','').strip('/').split('/')[-1] if len(date_links) > 1:
date += '-'+date_links[0].attrib.get('href','').strip('/').split('/')[-1] date = date_links[1].attrib.get('href','').strip('/').split('/')[-1]
date += '-'+date_links[0].attrib.get('href','').strip('/').split('/')[-1]
else:
date = unicode(self.parser.select(a.getparent().getparent().getparent(),'td')[1].text_content())
result += '%s : %s\n' % (country,date) result += '%s : %s\n' % (country,date)
if result == u'': if result == u'':
result = NotAvailable result = NotAvailable
return result.strip() else:
result = result.strip()
return result
class BiographyPage(BasePage): class BiographyPage(BasePage):

View file

@ -391,21 +391,11 @@ class Cineoob(ReplApplication):
Show the complete biography of a person. Show the complete biography of a person.
""" """
# TODO understand how to handle short id trying to be get by wrong backends and validate this line ! person = self.get_object(person_id,'get_person',('name','biography'))
# in other words, find a way to select CAP when 'get_object' to avoid useless errors and clarify the following code
#person = self.get_object(person_id,'get_person',('name','biography'))
person = None
_id, backend = self.parse_id(person_id)
for _backend, result in self.do('get_person', _id, backends=backend, caps=ICapCinema):
if result:
backend = _backend
person = result
if not person: if not person:
print >>sys.stderr, 'Person not found: %s' % _id print >>sys.stderr, 'Person not found: %s' % person_id
return 3 return 3
backend.fillobj(person,('biography'))
self.start_format() self.start_format()
self.format(person) self.format(person)
self.flush() self.flush()
@ -424,13 +414,7 @@ class Cineoob(ReplApplication):
""" """
id, country = self.parse_command_args(line, 2, 1) id, country = self.parse_command_args(line, 2, 1)
movie = None movie = self.get_object(id,'get_movie',('original_title'))
_id, backend = self.parse_id(id)
for _backend, result in self.do('get_movie', _id, backends=backend, caps=ICapCinema):
if result:
backend = _backend
movie = result
if not movie: if not movie:
print >>sys.stderr, 'Movie not found: %s' % id print >>sys.stderr, 'Movie not found: %s' % id
return 3 return 3
@ -538,12 +522,7 @@ class Cineoob(ReplApplication):
Search torrents of movie_ID. Search torrents of movie_ID.
""" """
movie = None movie = self.get_object(id, 'get_movie', ('original_title'))
_id, backend = self.parse_id(id)
for _backend, result in self.do('get_movie', _id, backends=backend, caps=ICapCinema):
if result:
backend = _backend
movie = result
if not movie: if not movie:
print >>sys.stderr, 'Movie not found: %s' % id print >>sys.stderr, 'Movie not found: %s' % id
return 3 return 3