[cineoob] new command movies_in_common

This commit is contained in:
Julien Veyssier 2013-03-04 15:52:57 +01:00
commit a6430c96b3
5 changed files with 67 additions and 3 deletions

View file

@ -157,7 +157,8 @@ class Cineoob(ReplApplication):
'search_person': 'person_list',
'info_person': 'person_info',
'casting': 'person_list',
'filmography': 'movie_list'
'filmography': 'movie_list',
'movies_in_common':'movie_list'
}
def complete_info(self, text, line, *ignored):
@ -165,6 +166,41 @@ class Cineoob(ReplApplication):
if len(args) == 2:
return self._complete_object()
def do_movies_in_common(self, line):
"""
movies_in_common person_ID person_ID
Get the list of common movies between two persons.
"""
id1, id2 = self.parse_command_args(line, 2, 1)
person1 = self.get_object(id1, 'get_person')
if not person1:
print >>sys.stderr, 'Person not found: %s' % id1
return 3
person2 = self.get_object(id2, 'get_person')
if not person2:
print >>sys.stderr, 'Person not found: %s' % id2
return 3
initial_count = self.options.count
self.options.count = None
lid1 = []
for backend, id in self.do('iter_person_movies_ids', person1.id):
lid1.append(id)
self.flush()
lid2 = []
for backend, id in self.do('iter_person_movies_ids', person2.id):
lid2.append(id)
self.flush()
self.options.count = initial_count
inter = list(set(lid1) & set(lid2))
for common in inter:
movie = self.get_object(common, 'get_movie')
self.cached_format(movie)
self.flush()
def do_info_movie(self, id):
"""
info_movie movie_ID