Coverage for marvin.views.movies : 85%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
""" marvin.views.movies ~~~~~~~~~~~~~~~~~~~
Endpoints related to movies.
""" # pylint: disable=no-self-use
""" Read interface to movies. """
""" Get the movie with the given ID. """ 'movie': movie.to_json(), }
""" R interface to all movies.
Creation is in general not done manually by users, but rather automatically through search results and the likes. Only case where you can explicitly create a movie is by entering a url, so that we can look up the necessary parameters ourselves. This will be implemented later. """
""" Get a list of id -> movie title pairs of all movies registered. """ # Import the task here since it will cause circular imports if it's done on the top
# Return results from our own db .filter(Movie.title.ilike('%' + final_search_query + '%')) .order_by(Movie.relevancy.desc()) .limit(limit)) # Good, we found something, return that, and look for more asynchronously else: # Crap, database is empty, let's look for some more stuff synchronously, so that we don't # give any empty responses _logger.info("No movies found locally for query '%s', searching external resources...", search_query) external_search(search_query) movies = movie_query.all() _logger.info("Synchronous search for '%s' resulted in %d new movies", search_query, len(movies)) else: .filter(Movie.number_of_streams >= 1) .order_by(Movie.relevancy.desc()) .limit(limit) .all())
'movies': [movie.to_json(include_streams=False) for movie in movies], } |