[cineoob] [imdb] fillobj ok for person and movie

[piratebay] get_torrent return None if 404
This commit is contained in:
Julien Veyssier 2013-03-10 22:03:37 +01:00
commit b9d3719ad2
3 changed files with 26 additions and 23 deletions

View file

@ -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 = {

View file

@ -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)

View file

@ -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