Ejemplo n.º 1
0
 def convert_to_movie(api_movie_obj):
     """
     Generic method to parse movie objects from tmdb_api return
     objects. Works for getting single item detail as parsing
     movies that come back in a list
     """
     # Sometimes the api passes back null movies.  Weird, I know. - Matt M
     if api_movie_obj is None:
         logger.warn("Blank movie encountered")
         return Movie()
     logger.info("Converting to movie: %s (%s)" % (api_movie_obj["title"], api_movie_obj["id"]))
     movie = Movie()
     movie.m_id = api_movie_obj["id"]
     movie.title = api_movie_obj["title"]
     if "poster_path" in api_movie_obj.keys() and api_movie_obj["poster_path"]:
         # w185 indicates api request for the 185px-width image
         movie.poster_path = "%sw185%s" % (tmdb.get_base_url(), api_movie_obj["poster_path"])
     else:
         movie.poster_path = "/static/img/placeholder-poster.jpg"
     movie_keys = api_movie_obj.keys()
     movie.release_date = api_movie_obj["release_date"] if ("id" in movie_keys) else None
     movie.overview = api_movie_obj["overview"] if ("overview" in movie_keys) else None
     movie.budget = api_movie_obj["budget"] if ("budget" in movie_keys) else None
     movie.revenue = api_movie_obj["revenue"] if ("revenue" in movie_keys) else None
     logger.info("Conversion successful")
     return movie
Ejemplo n.º 2
0
 def convert_to_movie(api_movie_obj):
     """
     Generic method to parse movie objects from tmdb_api return
     objects. Works for getting single item detail as parsing
     movies that come back in a list
     """
     # Sometimes the api passes back null movies.  Weird, I know. - Matt M
     if api_movie_obj is None:
         logger.warn('Blank movie encountered')
         return Movie()
     logger.info('Converting to movie: %s (%s)' % (api_movie_obj['title'], api_movie_obj['id']))
     movie = Movie()
     movie.m_id = api_movie_obj['id']
     movie.title = api_movie_obj['title']
     if 'poster_path' in api_movie_obj.keys() and api_movie_obj['poster_path']:
         # w185 indicates api request for the 185px-width image
         movie.poster_path = '%sw185%s' % (tmdb.get_base_url(), api_movie_obj['poster_path'])
     else:
         movie.poster_path = '/static/img/placeholder-poster.jpg'
     movie_keys = api_movie_obj.keys()
     movie.release_date = api_movie_obj['release_date'] if ('id' in movie_keys) else None
     movie.overview = api_movie_obj['overview'] if ('overview' in movie_keys) else None
     movie.budget = api_movie_obj['budget'] if ('budget' in movie_keys) else None
     movie.revenue = api_movie_obj['revenue'] if ('revenue' in movie_keys) else None
     logger.info('Conversion successful')
     return movie
Ejemplo n.º 3
0
 def test_get_base_url(self):
     base_url = tmdb.get_base_url()
     self.assertTrue(base_url)
Ejemplo n.º 4
0
 def test_get_base_url(self):
     base_url = tmdb.get_base_url()
     self.assertTrue(base_url)