From b9d3719ad2372c3759a9c02901305b4eb371071e Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Sun, 10 Mar 2013 22:03:37 +0100 Subject: [PATCH] [cineoob] [imdb] fillobj ok for person and movie [piratebay] get_torrent return None if 404 --- modules/imdb/backend.py | 24 ++++++++++++++++++++---- modules/piratebay/browser.py | 6 ++++-- weboob/applications/cineoob/cineoob.py | 19 ++----------------- 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/modules/imdb/backend.py b/modules/imdb/backend.py index 49a4e27d..1862951a 100644 --- a/modules/imdb/backend.py +++ b/modules/imdb/backend.py @@ -75,7 +75,16 @@ class ImdbBackend(BaseBackend, ICapCinema): 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) + per = self.get_person(person.id) + person.real_name = per.real_name + person.birth_date = per.birth_date + person.death_date = per.death_date + person.birth_place = per.birth_place + person.gender = per.gender + person.nationality = per.nationality + person.short_biography = per.short_biography + person.short_description = per.short_description + person.roles = per.roles if 'biography' in fields: person.biography = self.get_person_biography(person.id) @@ -85,9 +94,16 @@ class ImdbBackend(BaseBackend, ICapCinema): def fill_movie(self, movie, fields): if 'other_titles' in fields or 'release_date' in fields\ or 'duration' in fields or 'country' in fields\ - or 'roles' in fields or 'note' in fields\ - or fields == None: - return self.get_movie(movie.id) + or 'roles' in fields or 'note' in fields: + mov = self.get_movie(movie.id) + movie.other_titles = mov.other_titles + movie.release_date = mov.release_date + movie.duration = mov.duration + movie.pitch = mov.pitch + movie.country = mov.country + movie.note = mov.note + movie.roles = mov.roles + movie.short_description= mov.short_description return movie OBJECTS = { diff --git a/modules/piratebay/browser.py b/modules/piratebay/browser.py index fa88f121..8914f992 100644 --- a/modules/piratebay/browser.py +++ b/modules/piratebay/browser.py @@ -49,7 +49,9 @@ class PiratebayBrowser(BaseBrowser): return self.page.iter_torrents() def get_torrent(self, id): - self.location('https://thepiratebay.se/torrent/%s/' % id) - + try: + self.location('https://thepiratebay.se/torrent/%s/' % id) + except: + return None assert self.is_on_page(TorrentPage) return self.page.get_torrent(id) diff --git a/weboob/applications/cineoob/cineoob.py b/weboob/applications/cineoob/cineoob.py index f185ec9f..184b9b6e 100644 --- a/weboob/applications/cineoob/cineoob.py +++ b/weboob/applications/cineoob/cineoob.py @@ -291,15 +291,7 @@ class Cineoob(ReplApplication): Get information about a movie. """ - # TODO understand core to get a call to Backend.fill_movie when get_object is called - # then the following paragraph can be replace by the following commented line - #movie = self.get_object(id, 'get_movie',['duration']) - 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',('duration','release_date')) if not movie: print >>sys.stderr, 'Movie not found: %s' % id @@ -317,14 +309,7 @@ class Cineoob(ReplApplication): Get information about a person. """ - # TODO understand core to get a call to Backend.fill_person when get_object is called - #person = self.get_object(id, 'get_person') - person = None - _id, backend = self.parse_id(id) - for _backend, result in self.do('get_person', _id, backends=backend, caps=ICapCinema): - if result: - backend = _backend - person = result + person = self.get_object(id, 'get_person',('birth_date','birth_place')) if not person: print >>sys.stderr, 'Person not found: %s' % id