From c3c05618871d2d3e1aa774fbfd1d52cf0d967ea3 Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Sun, 10 Mar 2013 22:52:28 +0100 Subject: [PATCH] [cineoob] get_object cleaning --- modules/imdb/backend.py | 4 ++++ modules/imdb/browser.py | 2 ++ modules/imdb/pages.py | 11 +++++++--- weboob/applications/cineoob/cineoob.py | 29 ++++---------------------- 4 files changed, 18 insertions(+), 28 deletions(-) diff --git a/modules/imdb/backend.py b/modules/imdb/backend.py index 1862951a..ed344e9f 100644 --- a/modules/imdb/backend.py +++ b/modules/imdb/backend.py @@ -104,6 +104,10 @@ class ImdbBackend(BaseBackend, ICapCinema): movie.note = mov.note movie.roles = mov.roles movie.short_description= mov.short_description + + if 'all_release_dates' in fields: + movie.all_release_dates = self.get_movie_releases(movie.id) + return movie OBJECTS = { diff --git a/modules/imdb/browser.py b/modules/imdb/browser.py index 3d9bf2c6..156c6ed8 100644 --- a/modules/imdb/browser.py +++ b/modules/imdb/browser.py @@ -63,6 +63,7 @@ class ImdbBrowser(BaseBrowser): movie.country = NotLoaded movie.note = NotLoaded movie.roles = NotLoaded + movie.all_release_dates= NotLoaded yield movie def iter_persons(self, pattern): @@ -149,6 +150,7 @@ class ImdbBrowser(BaseBrowser): movie.note = note movie.roles = roles movie.short_description= short_description + movie.all_release_dates= NotLoaded return movie def get_person(self, id): diff --git a/modules/imdb/pages.py b/modules/imdb/pages.py index 9d4f3290..9121420f 100644 --- a/modules/imdb/pages.py +++ b/modules/imdb/pages.py @@ -41,12 +41,17 @@ class ReleasePage(BasePage): country = a.text td_date = self.parser.select(a.getparent().getparent().getparent(),'td')[1] date_links = self.parser.select(td_date,'a') - date = date_links[1].attrib.get('href','').strip('/').split('/')[-1] - date += '-'+date_links[0].attrib.get('href','').strip('/').split('/')[-1] + if len(date_links) > 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) if result == u'': result = NotAvailable - return result.strip() + else: + result = result.strip() + return result class BiographyPage(BasePage): diff --git a/weboob/applications/cineoob/cineoob.py b/weboob/applications/cineoob/cineoob.py index 184b9b6e..a4b38798 100644 --- a/weboob/applications/cineoob/cineoob.py +++ b/weboob/applications/cineoob/cineoob.py @@ -391,21 +391,11 @@ class Cineoob(ReplApplication): 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 ! - # 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 + person = self.get_object(person_id,'get_person',('name','biography')) if not person: - print >>sys.stderr, 'Person not found: %s' % _id + print >>sys.stderr, 'Person not found: %s' % person_id return 3 - backend.fillobj(person,('biography')) self.start_format() self.format(person) self.flush() @@ -424,13 +414,7 @@ class Cineoob(ReplApplication): """ id, country = self.parse_command_args(line, 2, 1) - movie = None - _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 - + movie = self.get_object(id,'get_movie',('original_title')) if not movie: print >>sys.stderr, 'Movie not found: %s' % id return 3 @@ -538,12 +522,7 @@ class Cineoob(ReplApplication): Search torrents of movie_ID. """ - movie = None - _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 + movie = self.get_object(id, 'get_movie', ('original_title')) if not movie: print >>sys.stderr, 'Movie not found: %s' % id return 3