def _search(self, query, context=None): """Search for a movie matching *query*""" results = Movie.search(query) movie = self._filter_results(query, results) movie._get() # fetch remainder of data from trakt if movie is not None: return self._apply_mapping(movie) return self.context
def get_trakt_info(self, eiga_movie): logging.debug('search trakt for movie %s', eiga_movie['title_jp']) original_title = eiga_movie['movie_data'].get('原題'.decode('utf8'), None) year = eiga_movie['movie_data'].get('製作年'.decode('utf8'), None) logging.debug('search trakt for movie [%s](%s)', original_title, year) if original_title is None: logging.warning('original title does not exist, skip get trakt info') return None else: if year is not None: year = year[:4] try: result = Movie.search(original_title, year) if len(result) > 0: return result[0] else: return None except TypeError as e: logging.error('the movie title only contains non-ascii character, ' 'PyTrakt can not handle this: %s' % title) return None
def test_movie_search(): results = Movie.search('batman') assert isinstance(results, list) assert all(isinstance(m, Movie) for m in results)
def test_movie_search(): results = Movie.search('batman') assert isinstance(results, list) assert all(isinstance(m, Movie) for m in results)