def import_review(movie_id, review_count): movie = Movie() try: review = movie.reviews(movie_id) if len(review) < review_count or len(review) == 0: return None return review[review_count - 1] except TMDbException: pass
class TMDbTests(unittest.TestCase): def setUp(self): self.tmdb = TMDb() self.tmdb.api_key = os.environ['TMDB_API_KEY'] self.tmdb.language = 'en' self.tmdb.debug = True self.tmdb.wait_on_rate_limit = True self.movie = Movie() self.discover = Discover() self.tv = TV() self.person = Person() self.collection = Collection() self.company = Company() self.season = Season() def test_get_movie(self): movie = self.movie.details(111) self.assertIsNotNone(movie) self.assertEqual(movie.title, 'Scarface') self.assertEqual(movie.id, 111) self.assertTrue(hasattr(movie, 'title')) self.assertTrue(hasattr(movie, 'overview')) self.assertTrue(hasattr(movie, 'id')) def test_get_movie_reviews(self): search = self.movie.search("Mad Max") self.assertTrue(len(search) > 0) first = search[0] reviews = self.movie.reviews(first.id) self.assertTrue(len(reviews) > 0) for review in reviews: self.assertTrue(hasattr(review, 'id')) self.assertTrue(hasattr(review, 'content')) def test_get_movie_lists(self): lists = self.movie.lists(111) self.assertTrue(len(lists) > 0) self.assertTrue(hasattr(lists[0], 'description')) self.assertTrue(hasattr(lists[0], 'name')) def test_get_movie_videos(self): videos = self.movie.videos(111) self.assertTrue(len(videos) > 0) self.assertTrue(hasattr(videos[0], 'id')) def test_get_movie_recommendations(self): recs = self.movie.recommendations(111) self.assertTrue(len(recs) > 0) self.assertTrue(hasattr(recs[0], 'id')) def test_discover_movies(self): discover = self.discover.discover_movies({ 'primary_release_year': '2015', 'with_genres': '28', 'page': '1', 'vote_average.gte': '8' }) self.assertTrue(len(discover) > 0) self.assertTrue(hasattr(discover[0], 'id')) movie = discover[0] has_genre = False for genre_id in movie.genre_ids: if genre_id == 28: has_genre = True self.assertTrue(has_genre) def test_discover_tv_shows(self): discover = self.discover.discover_tv_shows({ 'with_genres': '16', 'vote_average.gte': '8', 'page': '1' }) self.assertTrue(len(discover) > 0) self.assertTrue(hasattr(discover[0], 'id')) movie = discover[0] has_genre = False for genre_id in movie.genre_ids: if genre_id == 16: has_genre = True self.assertTrue(has_genre) def test_get_latest_movie(self): videos = self.movie.latest() self.assertIsNotNone(videos) self.assertTrue(hasattr(videos, 'id')) def test_now_playing(self): now_playing = self.movie.now_playing() self.assertTrue(len(now_playing) > 0) self.assertTrue(hasattr(now_playing[0], 'id')) def test_top_rated(self): top_rated = self.movie.top_rated() self.assertTrue(len(top_rated) > 0) self.assertTrue(hasattr(top_rated[0], 'id')) def test_upcoming(self): upcoming = self.movie.upcoming() self.assertTrue(len(upcoming) > 0) self.assertTrue(hasattr(upcoming[0], 'id')) def test_popular(self): popular = self.movie.popular() self.assertTrue(len(popular) > 0) self.assertTrue(hasattr(popular[0], 'id')) def test_search(self): search = self.movie.search('Mad Max') self.assertTrue(len(search) > 0) self.assertTrue(hasattr(search[0], 'id')) def test_similar(self): similar = self.movie.similar(111) self.assertTrue(len(similar) > 0) self.assertTrue(hasattr(similar[0], 'id')) def test_get_tv_show(self): show = self.tv.details(12) self.assertIsNotNone(show) self.assertTrue(hasattr(show, 'id')) def test_get_latest_tv_show(self): latest_tv = self.tv.latest() self.assertIsNotNone(latest_tv) self.assertTrue(hasattr(latest_tv, 'id')) def test_search_tv(self): search_tv = self.tv.search('Sunny') self.assertTrue(len(search_tv) > 0) self.assertTrue(hasattr(search_tv[0], 'id')) def test_popular_shows(self): popular = self.tv.popular() self.assertTrue(len(popular) > 0) self.assertTrue(hasattr(popular[0], 'id')) def test_top_rated_shows(self): top_rated = self.tv.top_rated() self.assertTrue(len(top_rated) > 0) self.assertTrue(hasattr(top_rated[0], 'id')) def test_get_person(self): person = self.person.details(234) self.assertIsNotNone(person) self.assertTrue(hasattr(person, 'id')) def test_search_person(self): search_person = self.person.search('Bryan') self.assertTrue(len(search_person) > 0) self.assertTrue(hasattr(search_person[0], 'id')) def test_collection_details(self): c = Collection() details = c.details(10) self.assertEqual(details.name, 'Star Wars Collection') self.assertEqual(details.id, 10) self.assertTrue(hasattr(details, 'overview')) self.assertTrue(hasattr(details, 'poster_path')) def test_collection_images(self): c = Collection() images = c.images(10) self.assertTrue(hasattr(images, 'backdrops')) self.assertTrue(hasattr(images, 'posters')) def test_popular_people(self): popular = self.person.popular() self.assertTrue(len(popular) > 0) first = popular[0] self.assertTrue(hasattr(first, 'name')) self.assertTrue(hasattr(first, 'known_for')) def test_latest_person(self): latest_person = self.person.latest() self.assertIsNotNone(latest_person) self.assertTrue(hasattr(latest_person, 'name')) self.assertTrue(hasattr(latest_person, 'id')) def test_person_images(self): images = self.person.images(11) self.assertIsNotNone(images) self.assertTrue(hasattr(images, 'profiles')) self.assertTrue(hasattr(images, 'id')) def test_company_details(self): c = self.company.details(1) self.assertTrue(hasattr(c, 'name')) self.assertEqual(c.name, 'Lucasfilm') def test_company_movies(self): company = self.company.movies(1) self.assertTrue(len(company) > 0) first = company[0] self.assertTrue(hasattr(first, 'title')) self.assertTrue(hasattr(first, 'overview')) def test_config(self): config = Configuration() info = config.info() self.assertIsNotNone(info) self.assertTrue(hasattr(info, 'images')) def test_genres(self): genres = Genre() movie_genres = genres.movie_list() self.assertIsNotNone(movie_genres) tv_genres = genres.tv_list() self.assertIsNotNone(tv_genres) def test_season(self): s = self.season.details(1418, 1) self.assertIsNotNone(s) self.assertEqual(s.name, 'Season 1') self.assertEqual(s.id, 3738) self.assertTrue(hasattr(s, 'episodes')) self.assertTrue(hasattr(s, 'overview')) self.assertTrue(hasattr(s, 'id')) def test_get_season_changes(self): s = self.season.changes(1418, 1) self.assertIsNotNone(s) def test_get_season_external_ids(self): s = self.season.external_ids(1418, 1) self.assertIsNotNone(s) self.assertIsNotNone(s['tvdb_id']) def test_get_season_videos(self): s = self.season.videos(1418, 1) def test_get_season_images(self): s = self.season.images(1418, 1) for l in s: self.assertIsNotNone(l.width) self.assertIsNotNone(l.height) def test_get_season_credits(self): s = self.season.credits(1418, 1) for c in s: self.assertIsNotNone(c.name) self.assertIsNotNone(c.character) def test_get_movie_by_external_id(self): ex = self.movie.external(external_id="tt8155288", external_source="imdb_id") res = ex['movie_results'][0] self.assertTrue(res['title'] == "Happy Death Day 2U")
def main(): movie = Movie() n=idTerakhir() while n > 353000: #353000 just a limit for iteration, may be changed to 1 for all movie id m = movie.details(n) try: if m==[] or m is None or m==() or m=="": print("Data film ini tidak ditemukan") else: id_movie=n attr = getattr(m, "original_title", None) if attr is not None: judul=m.original_title budget=m.budget overview=m.overview popularity=m.popularity poster=m.poster_path tglrelease=m.release_date pendapatan=m.revenue runtime=m.runtime status = m.status voteavrg = m.vote_average votecount = m.vote_count tagline = m.tagline homepage = m.homepage negaraproduksi = m.production_countries bahasa=m.original_language revenue=m.revenue print("Mengambil Data Film "+judul) for x in range(0,len(m.genres)): insert_genre(m.genres[x]["id"],m.genres[x]["name"]) insert_film(id_movie,judul,overview,poster,homepage,popularity,revenue,runtime,tagline,voteavrg,votecount,m.genres[x]["id"],bahasa,1000000,1000000,1000000,1000000,"",budget) xtanggal = m.release_date if xtanggal!="": a,b,c = xtanggal.split("-") insert_waktu(a,b,c,xtanggal) insert_film(id_movie,judul,overview,poster,homepage,popularity,revenue,runtime,tagline,voteavrg,votecount,1000000,bahasa,xtanggal,1000000,1000000,1000000,"",budget) else: print("Belum ada release data") for z in range(0,len(m.production_companies)): insert_companies(m.production_companies[z]["id"],m.production_companies[z]["name"],m.production_companies[z]["origin_country"],m.production_companies[z]["logo_path"]) insert_film(id_movie,judul,overview,poster,homepage,popularity,revenue,runtime,tagline,voteavrg,votecount,1000000,bahasa,1000000,1000000,1000000,m.production_companies[z]["id"],"",budget) for y in range(0,len(m.production_countries)): sqlprod = "insert ignore into sma_tbl_dimnegara(id_negara,nama_negara) values(%s,%s)" args = (m.production_countries[y]["iso_3166_1"],m.production_countries[y]["name"]) cursor.execute(sqlprod, args) mydb.commit() insert_film(id_movie,judul,overview,poster,homepage,popularity,revenue,runtime,tagline,voteavrg,votecount,1000000,bahasa,1000000,m.production_countries[y]["iso_3166_1"],1000000,1000000,"",budget) r = movie.reviews(n) if r==[]: print("Tidak ada data review") else: for h in range(0,len(r.results)): dtreview = "Author: "+r.results[h]["author"]+"<br>"+r.results[h]["content"] insert_film(id_movie,judul,overview,poster,homepage,popularity,revenue,runtime,tagline,voteavrg,votecount,1000000,bahasa,1000000,1000000,1000000,1000000,dtreview,budget) c = movie.credits(n) if c==[]: print("Tidak ada data person") else: for dd in c.cast: id_person =dd["id"] nama =dd["name"] job ="Cast" with urllib.request.urlopen("https://api.themoviedb.org/3/person/"+str(id_person)+"?api_key=ee183266d8fc13c415cad996a43d03b1&language=en-US") as url: c = json.loads(url.read().decode()) popularity =c["popularity"] pob =c["place_of_birth"] foto =c["profile_path"] birthday =c["birthday"] homepage =c["homepage"] biography =c["biography"] insert_person(id_person,nama,biography,popularity,pob,foto,job,birthday,homepage) insert_film(id_movie,judul,overview,poster,homepage,popularity,revenue,runtime,tagline,voteavrg,votecount,1000000,bahasa,1000000,1000000,id_person,1000000,"",budget) c = movie.credits(n) if c==[]: print("Tidak ada data person") else: for cc in c.crew: id_person =cc["id"] nama =cc["name"] job ="Crew" with urllib.request.urlopen("https://api.themoviedb.org/3/person/"+str(id_person)+"?api_key=ee183266d8fc13c415cad996a43d03b1&language=en-US") as url: c = json.loads(url.read().decode()) popularity =c["popularity"] pob =c["place_of_birth"] foto =c["profile_path"] birthday =c["birthday"] homepage =c["homepage"] biography =c["biography"] insert_person(id_person,nama,biography,popularity,pob,foto,job,birthday,homepage) insert_film(id_movie,judul,overview,poster,homepage,popularity,revenue,runtime,tagline,voteavrg,votecount,1000000,bahasa,1000000,1000000,id_person,1000000,"",budget)
class TMDbTests(unittest.TestCase): def setUp(self): self.tmdb = TMDb() self.tmdb.api_key = os.environ["TMDB_API_KEY"] self.tmdb.language = "en" self.tmdb.debug = True self.tmdb.wait_on_rate_limit = True self.movie = Movie() self.discover = Discover() self.tv = TV() self.person = Person() self.collection = Collection() self.company = Company() self.season = Season() self.list = List() def test_get_tv_keywords(self): keywords = self.tv.keywords(1396) self.assertGreater(len(keywords), 0) def test_get_tv_reviews(self): reviews = self.tv.reviews(1396) self.assertGreater(len(reviews), 0) def test_get_movie_repr(self): search = self.movie.search("Mad Max") for results in search: print(results) def test_get_tv_show_repr(self): search_tv = self.tv.search("Breaking Bad") for results in search_tv: print(results) def test_get_movie(self): movie = self.movie.details(111) self.assertIsNotNone(movie) self.assertEqual(movie.title, "Scarface") self.assertEqual(movie.id, 111) self.assertTrue(hasattr(movie, "title")) self.assertTrue(hasattr(movie, "overview")) self.assertTrue(hasattr(movie, "id")) def test_get_movie_reviews(self): search = self.movie.search("Mad Max") self.assertTrue(len(search) > 0) first = search[0] reviews = self.movie.reviews(first.id) self.assertTrue(len(reviews) > 0) for review in reviews: self.assertTrue(hasattr(review, "id")) self.assertTrue(hasattr(review, "content")) def test_get_movie_lists(self): lists = self.movie.lists(111) self.assertTrue(len(lists) > 0) self.assertTrue(hasattr(lists[0], "description")) self.assertTrue(hasattr(lists[0], "name")) def test_get_movie_credits(self): credits = self.movie.credits(111) print(credits) self.assertIsNotNone(credits) def test_get_movie_images(self): images = self.movie.images(111) print(images) self.assertIsNotNone(images) def test_get_movie_videos(self): videos = self.movie.videos(111) self.assertTrue(len(videos) > 0) self.assertTrue(hasattr(videos[0], "id")) def test_get_movie_recommendations(self): recs = self.movie.recommendations(111) self.assertTrue(len(recs) > 0) self.assertTrue(hasattr(recs[0], "id")) def test_discover_movies(self): discover = self.discover.discover_movies({ "primary_release_year": "2015", "with_genres": "28", "page": "1", "vote_average.gte": "8", }) self.assertTrue(len(discover) > 0) self.assertTrue(hasattr(discover[0], "id")) movie = discover[0] has_genre = False for genre_id in movie.genre_ids: if genre_id == 28: has_genre = True self.assertTrue(has_genre) def test_discover_tv_shows(self): discover = self.discover.discover_tv_shows({ "with_genres": "16", "vote_average.gte": "8", "page": "1" }) self.assertTrue(len(discover) > 0) self.assertTrue(hasattr(discover[0], "id")) movie = discover[0] has_genre = False for genre_id in movie.genre_ids: if genre_id == 16: has_genre = True self.assertTrue(has_genre) def test_get_latest_movie(self): videos = self.movie.latest() self.assertIsNotNone(videos) self.assertTrue(hasattr(videos, "id")) def test_now_playing(self): now_playing = self.movie.now_playing() self.assertTrue(len(now_playing) > 0) self.assertTrue(hasattr(now_playing[0], "id")) def test_top_rated(self): top_rated = self.movie.top_rated() self.assertTrue(len(top_rated) > 0) self.assertTrue(hasattr(top_rated[0], "id")) def test_upcoming(self): upcoming = self.movie.upcoming() self.assertTrue(len(upcoming) > 0) self.assertTrue(hasattr(upcoming[0], "id")) def test_popular(self): popular = self.movie.popular() self.assertTrue(len(popular) > 0) self.assertTrue(hasattr(popular[0], "id")) def test_search(self): search = self.movie.search("Mad Max") self.assertTrue(len(search) > 0) self.assertTrue(hasattr(search[0], "id")) def test_similar(self): similar = self.movie.similar(111) self.assertTrue(len(similar) > 0) self.assertTrue(hasattr(similar[0], "id")) def test_get_tv_show(self): show = self.tv.details(12) self.assertIsNotNone(show) self.assertTrue(hasattr(show, "id")) def test_on_the_air(self): show = self.tv.on_the_air() self.assertTrue(len(show) > 0) def test_airing_today(self): show = self.tv.on_the_air() self.assertTrue(len(show) > 0) def test_tv_videos(self): show = self.tv.videos(1396) self.assertTrue(len(show) > 0) def test_tv_recommendations(self): show = self.tv.recommendations(1396) self.assertTrue(len(show) > 0) def test_external_ids(self): show = self.tv.external_ids(1776) self.assertEqual(show["imdb_id"], "tt0488262") def test_get_latest_tv_show(self): latest_tv = self.tv.latest() self.assertIsNotNone(latest_tv) self.assertTrue(hasattr(latest_tv, "id")) def test_search_tv(self): search_tv = self.tv.search("Sunny") self.assertTrue(len(search_tv) > 0) self.assertTrue(hasattr(search_tv[0], "id")) def test_popular_shows(self): popular = self.tv.popular() self.assertTrue(len(popular) > 0) self.assertTrue(hasattr(popular[0], "id")) def test_top_rated_shows(self): top_rated = self.tv.top_rated() self.assertTrue(len(top_rated) > 0) self.assertTrue(hasattr(top_rated[0], "id")) def test_get_person(self): person = self.person.details(234) self.assertIsNotNone(person) self.assertTrue(hasattr(person, "id")) def test_search_person(self): search_person = self.person.search("Bryan") self.assertTrue(len(search_person) > 0) self.assertTrue(hasattr(search_person[0], "id")) def test_collection_details(self): c = Collection() details = c.details(10) self.assertEqual(details.name, "Star Wars Collection") self.assertEqual(details.id, 10) self.assertTrue(hasattr(details, "overview")) self.assertTrue(hasattr(details, "poster_path")) def test_collection_images(self): c = Collection() images = c.images(10) self.assertTrue(hasattr(images, "backdrops")) self.assertTrue(hasattr(images, "posters")) def test_popular_people(self): popular = self.person.popular() self.assertTrue(len(popular) > 0) first = popular[0] self.assertTrue(hasattr(first, "name")) self.assertTrue(hasattr(first, "known_for")) def test_latest_person(self): latest_person = self.person.latest() self.assertIsNotNone(latest_person) self.assertTrue(hasattr(latest_person, "name")) self.assertTrue(hasattr(latest_person, "id")) def test_person_images(self): images = self.person.images(11) self.assertIsNotNone(images) self.assertTrue(hasattr(images, "profiles")) self.assertTrue(hasattr(images, "id")) def test_company_details(self): c = self.company.details(1) self.assertTrue(hasattr(c, "name")) self.assertEqual(c.name, "Lucasfilm Ltd.") def test_company_movies(self): company = self.company.movies(1) self.assertTrue(len(company) > 0) first = company[0] self.assertTrue(hasattr(first, "title")) self.assertTrue(hasattr(first, "overview")) def test_config(self): config = Configuration() info = config.info() self.assertIsNotNone(info) self.assertTrue(hasattr(info, "images")) def test_genres(self): genres = Genre() movie_genres = genres.movie_list() self.assertIsNotNone(movie_genres) tv_genres = genres.tv_list() self.assertIsNotNone(tv_genres) def test_season(self): s = self.season.details(1418, 1) self.assertIsNotNone(s) self.assertEqual(s.name, "Season 1") self.assertEqual(s.id, 3738) self.assertTrue(hasattr(s, "episodes")) self.assertTrue(hasattr(s, "overview")) self.assertTrue(hasattr(s, "id")) def test_get_season_changes(self): s = self.season.changes(1418) self.assertIsNotNone(s) def test_get_season_external_ids(self): s = self.season.external_ids(1418, 1) self.assertIsNotNone(s) self.assertIsNotNone(s["tvdb_id"]) def test_get_season_videos(self): s = self.season.videos(1418, 1) def test_get_season_images(self): s = self.season.images(1418, 1) for l in s: self.assertIsNotNone(l.width) self.assertIsNotNone(l.height) def test_get_season_credits(self): s = self.season.credits(1418, 1) for c in s: self.assertIsNotNone(c.name) self.assertIsNotNone(c.character) def test_get_movie_by_external_id(self): ex = self.movie.external(external_id="tt8155288", external_source="imdb_id") res = ex["movie_results"][0] self.assertTrue(res["title"] == "Happy Death Day 2U") def test_get_list(self): list = self.list.details(list_id="112870") self.assertTrue(len(list) > 10) self.assertTrue(hasattr(list[0], "id")) self.assertTrue(hasattr(list[0], "title")) def test_get_certifications(self): certifications = Certification() movie_certifications = certifications.movie_list() self.assertIsNotNone(movie_certifications) tv_certifications = certifications.tv_list() self.assertIsNotNone(tv_certifications)
class TMDbTests(unittest.TestCase): def setUp(self): self.tmdb = TMDb() self.tmdb.api_key = os.environ['TMDB_API_KEY'] self.tmdb.language = 'en' self.tmdb.debug = True self.tmdb.wait_on_rate_limit = True self.movie = Movie() self.discover = Discover() self.tv = TV() self.person = Person() self.collection = Collection() self.company = Company() self.season = Season() self.list = List() def test_get_tv_keywords(self): keywords = self.tv.keywords(1396) self.assertGreater(len(keywords), 0) def test_get_tv_reviews(self): reviews = self.tv.reviews(1396) self.assertGreater(len(reviews), 0) def test_get_movie_repr(self): search = self.movie.search("Mad Max") for results in search: print(results) def test_get_tv_show_repr(self): search_tv = self.tv.search('Breaking Bad') for results in search_tv: print(results) def test_get_movie(self): movie = self.movie.details(111) self.assertIsNotNone(movie) self.assertEqual(movie['title'], 'Scarface') self.assertEqual(movie['id'], 111) self.assertTrue('title' in movie) self.assertTrue('overview' in movie) self.assertTrue('id' in movie) def test_get_movie_reviews(self): search = self.movie.search("Mad Max") self.assertTrue(len(search) > 0) first = search[0] reviews = self.movie.reviews(first.id) self.assertTrue(len(reviews) > 0) for review in reviews: self.assertTrue('id' in review)) self.assertTrue('content' in review)) def test_get_movie_lists(self): lists = self.movie.lists(111) self.assertTrue(len(lists) > 0) self.assertTrue(hasattr(lists[0], 'description')) self.assertTrue(hasattr(lists[0], 'name')) def test_get_movie_credits(self): credits = self.movie.credits(111) print(credits) self.assertIsNotNone(credits) def test_get_movie_images(self): images = self.movie.images(111) print(images) self.assertIsNotNone(images) def test_get_movie_videos(self): videos = self.movie.videos(111) self.assertTrue(len(videos) > 0) self.assertTrue(hasattr(videos[0], 'id')) def test_get_movie_recommendations(self): recs = self.movie.recommendations(111) self.assertTrue(len(recs) > 0) self.assertTrue(hasattr(recs[0], 'id')) def test_discover_movies(self): discover = self.discover.discover_movies({ 'primary_release_year': '2015', 'with_genres': '28', 'page': '1', 'vote_average.gte': '8' })
class MovieTests(unittest.TestCase): def setUp(self): self.tmdb = TMDb() self.tmdb.api_key = os.environ['TMDB_API_KEY'] self.tmdb.language = "en" self.tmdb.debug = True self.tmdb.wait_on_rate_limit = True self.tmdb.cache = False self.movie = Movie() def test_get_movie_repr(self): search = self.movie.search("Mad Max") self.assertGreater(len(search), 0) for result in search: self.assertNotEqual(str(result), "TMDB Obj") def test_get_movie_details(self): movie = self.movie.details(111) self.assertIsNotNone(movie) self.assertEqual(movie.id, 111) self.assertTrue(hasattr(movie, 'title')) self.assertTrue(hasattr(movie, 'overview')) self.assertTrue(hasattr(movie, 'release_dates')) def test_get_movie_alternative_titles(self): alternative_titles = self.movie.alternative_titles(111) self.assertEqual(alternative_titles.id, 111) self.assertGreater(len(alternative_titles.titles), 0) for title in alternative_titles.titles: self.assertIn('iso_3166_1', title) self.assertIn('title', title) self.assertIn('type', title) def test_get_movie_changes(self): changes = self.movie.changes(111, start_date="2016-08-29", end_date="2016-09-10") self.assertIsNotNone(changes) changes = self.movie.changes(111, start_date="2016-08-29") self.assertIsNotNone(changes) changes = self.movie.changes(111, end_date="2016-09-10") self.assertIsNotNone(changes) changes = self.movie.changes(111, page=2) self.assertIsNotNone(changes) def test_get_movie_credits(self): credits = self.movie.credits(111) self.assertEqual(credits.id, 111) self.assertTrue(hasattr(credits, "cast")) self.assertTrue(hasattr(credits, "crew")) def test_get_movie_external_ids(self): external_ids = self.movie.external_ids(111) self.assertIn("imdb_id", external_ids) self.assertIn("facebook_id", external_ids) self.assertIn("instagram_id", external_ids) self.assertIn("twitter_id", external_ids) self.assertIn("id", external_ids) def test_get_movie_images(self): images = self.movie.images(111, include_image_language="en,null") self.assertEqual(images.id, 111) self.assertGreater(len(images.backdrops), 0) self.assertGreater(len(images.posters), 0) for image in images.backdrops: self.assertIn("file_path", image) for image in images.posters: self.assertIn("file_path", image) def test_get_movie_keywords(self): keywords = self.movie.keywords(111) for keyword in keywords.keywords: self.assertIn("id", keyword) self.assertIn("name", keyword) def test_get_movie_lists(self): lists = self.movie.lists(111) self.assertGreater(len(lists), 0) for list in lists: self.assertTrue(hasattr(list, "description")) self.assertTrue(hasattr(list, "name")) def test_get_movie_recommendations(self): recommendations = self.movie.recommendations(111) self.assertGreater(len(recommendations), 0) for movie in recommendations: self.assertTrue(hasattr(movie, "id")) def test_get_movie_release_dates(self): release_dates = self.movie.release_dates(111) self.assertIsNotNone(release_dates) self.assertEqual(release_dates.id, 111) def test_get_movie_reviews(self): reviews = self.movie.reviews(111) self.assertGreater(len(reviews), 0) for review in reviews: self.assertTrue(hasattr(review, "id")) self.assertTrue(hasattr(review, "content")) def test_get_movie_videos(self): videos = self.movie.videos(111) self.assertGreater(len(videos), 0) for video in videos: self.assertTrue(hasattr(video, "id")) def test_get_movie_latest(self): latest = self.movie.latest() self.assertIsNotNone(latest) self.assertTrue(hasattr(latest, "id")) def test_get_movie_now_playing(self): now_playing = self.movie.now_playing() self.assertGreater(len(now_playing), 0) for movie in now_playing: self.assertTrue(hasattr(movie, "id")) def test_get_movie_top_rated(self): top_rated = self.movie.top_rated() self.assertGreater(len(top_rated), 0) for movie in top_rated: self.assertTrue(hasattr(movie, "id")) def test_get_movie_upcoming(self): upcoming = self.movie.upcoming() self.assertGreater(len(upcoming), 0) for movie in upcoming: self.assertTrue(hasattr(movie, "id")) def test_get_movie_popular(self): popular = self.movie.popular() self.assertGreater(len(popular), 0) for movie in popular: self.assertTrue(hasattr(movie, "id")) def test_get_movie_search(self): search = self.movie.search("Mad Max") self.assertGreater(len(search), 0) for movie in search: self.assertTrue(hasattr(movie, "id")) def test_get_movie_similar(self): similar = self.movie.similar(111) self.assertGreater(len(similar), 0) for movie in similar: self.assertTrue(hasattr(movie, "id")) def test_get_movie_external(self): external = self.movie.external(external_id="tt8155288", external_source="imdb_id") self.assertGreater(len(external), 0) for movie in external["movie_results"]: self.assertIn("id", movie) external_ids = self.movie.external_ids(movie["id"]) self.assertEqual(external_ids["imdb_id"], "tt8155288")
tabela02 = [] for a in recomendacao: tbl = [ a.id, a.original_language, a.original_title, a.overview, a.title, a.release_date, a.popularity, a.vote_average, a.vote_count ] tabela02.append(tbl) MovieRecomendacao = pd.DataFrame(tabela02, columns=[ 'ID', 'IdiomaOriginal', 'TituloOriginal', 'Resumo', 'Titulo', 'DataLancamento', 'Popularidade', 'MediaVotos', 'QtdVotos' ]) # review de Movies review = movie.reviews(movie_id=11) tabela03 = [] for r in review: tbl = [ r.author, r.author_details.name, r.author_details.username, r.author_details.avatar_path, r.author_details.rating, r.content, r.created_at, r.updated_at ] tabela03.append(tbl) MovieReview = pd.DataFrame(tabela03, columns=[ 'Autor', 'DetalheAutor', 'Ussername', 'Avatar', 'Rating', 'content', 'created_at', 'updated_at' ]) # series de TV Popular