Posts: 4
Threads: 2
Joined: Sep 2019
Sep-28-2019, 05:52 AM
(This post was last modified: Sep-28-2019, 06:04 AM by buran.)
Hi , i need help to get this coding filed but i have no idea how to deal with cumulative worldwide gross ?
from imdb import IMDb
ia = IMDb()
def get_cumulative_worldwide_gross(movie):
# How would you get the "Cumulative Worldwide Gross"?
# Hint: It's inside the movie object "movie['box office']".
return "0.0"
def gather_movie_info(movie):
id = movie.movieID
title = movie['title']
worldwide_gross = get_cumulative_worldwide_gross(movie)
return [
id, title, worldwide_gross
]
# What information can we get about a movie?
for id in ['4154796', '4633694', '3498820', '5095030', '0317705', '3949660', '0094074', '0290747', '3480822', '9114286']:
movie = ia.get_movie(id)
info = gather_movie_info(movie)
print(", ".join(info)
Posts: 8,160
Threads: 160
Joined: Sep 2016
Sep-28-2019, 06:29 AM
(This post was last modified: Sep-28-2019, 06:30 AM by buran.)
(Sep-28-2019, 05:52 AM)anh3phecan Wrote: i have no idea how to deal with cumulative worldwide gross and we don't have idea how you expect to deal with cumulative worldwide gross... There is comment how you need to deal with it/where to find it...
provide more information what is expected, what problem do you have and if you get error - post full traceback you get in error tags.
For obvious reasons I move this thread to Homework section
Posts: 1
Threads: 0
Joined: Sep 2019
Sep-28-2019, 01:53 PM
(This post was last modified: Sep-28-2019, 02:01 PM by zipit.)
Hi,
(Sep-28-2019, 06:29 AM)buran Wrote: and we don't have idea how you expect to deal with cumulative worldwide gross...
That is a bit harsh, isn't it? Not knowing how an external module works in detail, certainly is not an uncommon thing to happen. This seems especially true for IMDbPY and its rather basic documentation.
(Sep-28-2019, 05:52 AM)anh3phecan Wrote: i have no idea how to deal with cumulative worldwide gross
You probably are having problems because the data set for the key "box office" is not retrieved by default by all IMDbPY methods that provide a movie data set. So you might have to retrieve your data for that move id again.
movie = ia.get_movie(movie.movieID) This however will retrieve all data in the standard set. Your teacher probably also wants you to do this a performant way. Also note that in the "box office" data set will not always contain a value for a CWG. You will have to deal with that too.
Cheers
zipit
Posts: 4
Threads: 2
Joined: Sep 2019
i am sorry for any unclear info but i have no ideal how to calculate Cumulative Worldwide Gross by using ibdmpy package. Even there is hint for that i'm still stuck
Posts: 8,160
Threads: 160
Joined: Sep 2016
As hint says - it's a key in a movie['box office'] dict
from imdb import IMDb
client = IMDb()
movie = client.get_movie('4154796')
print(movie['box office'])
print(movie['box office']['Cumulative Worldwide Gross']) Output: {'Budget': '$356,000,000 (estimated)', 'Opening Weekend United States': '$357,115,007, 28 Apr 2019', 'Cumulative Worldwide Gross': '$2,796,274,401, 12 Sep 2019'}
$2,796,274,401, 12 Sep 2019
Posts: 4
Threads: 2
Joined: Sep 2019
Sep-28-2019, 09:24 PM
(This post was last modified: Sep-28-2019, 09:29 PM by anh3phecan.)
Yeah , that works sir . But how can i apply this code into my full one. Sorry again cause i totally new with that
here is the output without your code
Output: 4154796, Avengers: Endgame, 0.0
4633694, Spider-Man: Into the Spider-Verse, 0.0
3498820, Captain America: Civil War, 0.0
5095030, Ant-Man and the Wasp, 0.0
0317705, The Incredibles, 0.0
3949660, Teenage Mutant Ninja Turtles: Out of the Shadows, 0.0
0094074, Superman IV: The Quest for Peace, 0.0
0290747, Man-Thing, 0.0
3480822, Black Widow, 0.0
9114286, Black Panther II, 0.0
so i think 0.0 is supposed to be the gross profit, how can i edit your code to get that . Thanks
Posts: 8,160
Threads: 160
Joined: Sep 2016
I would suggest you on your own try to incorporate [parts] of my code into your get_cumulative_worldwide_gros function
|