Closed stonemirror closed 7 years ago
Here's a replacement for default.py which seems to work:
def grab_movies():
session.m = []
YOUR_OWN_KEY = 'YOUR_OWN_KEY'
url = requests.get('http://api.myapifilms.com/imdb/inTheaters?token={}&format=json&language=en-us'.format(YOUR_OWN_KEY))
binary = url.content
output = json.loads(binary)
#
# Get the titles of the newly-opened movies
#
movies = output["data"]["inTheaters"][0]["movies"]
for movie in movies:
session.m.append(movie["title"])
#
# Get the titles of the other movies playing in theaters
#
movies = output["data"]["inTheaters"][1]["movies"]
for movie in movies:
session.m.append(movie["title"])
session.m.sort()
return TABLE(*[TR(v) for v in session.m]).xml()
Thanks. I am revamping the course now and will add this in.
FYI, just verified that this default.py controller works as expected with the templates described in the following pages:
Updated in v 2.0 of the courses. Coming week of 12/19/2016. https://github.com/realpython/about/blob/master/changelog.csv
Beginning on p. 427, the exercise to do the "Movie Suggester" application requires a Rotten Tomatoes API key. Unfortunately, Rotten Tomatoes is not making those generally available, you have to apply for one.
From here:
The note under the example default.py suggests that one "return to the last chapter to find out how to obtain a new [API key]", however that chapter uses the myapifilms.com API, not Rotten Tomatoes'.
Since we're simply pulling the titles of the movies for analysis, the code from the prior chapter will work, but the code here needs to be revised to use the alternate API. I'll post a gist or something when I have the changes worked out.