In this article we review last week's Notification Service of Now Playing and Upcoming Movies code challenge.
This challenge we focused on TMDb's API to send html emails of movies / tv series. We decided to query 4 API endpoints: now playing movies, upcoming movies, popular TV series, and on-the-air TV series.
We used 2 shelves for caching: movie info and items sent (to avoid duplicates in the mails). We also got to play with decorators and classes. We used tmdbsimple to interface with TMDb's API.
We followed what we learned about packaging to structure our modules. Having a notifications package now makes it easier to add a Twitter bot later on for example.
The code is here and this is a screenshot of part of the notification email:
We did not have time to build a front-end to add filters. We did start a login system in Flask but ran out of time. I think this would be a nice exercise for us learning Django. To be continued ...
His script demonstrates that it's not necessary to use a API wrapper package. He uses
requests which leads to compact code like:
movies_resp = requests.get(upcoming_movies_url, params=query_params) to query TMDb's API.
You can checkout the code here. We read in the PR: "This is my first ever python code ..." - really? Good job!
This was a challenge to sink your teeth in, there were many options, lot to code. This week we try to keep it simpler making the challenge smaller, not necessarily easier. We will also change topics a bit to do something entirely different: build a simple GUI app. Stay tuned ...
By the way there is no deadline to these challenges, you can start any challenge at any time.
Just follow our instructions and start coding. Have fun!
Keep Calm and Code in Python!
-- Bob and Julian
Do you want to get 250+ concise and applicable Python tips in an ebook that will cost you less than 10 bucks (future updates included), check it out here.
"The discussions are succinct yet thorough enough to give you a solid grasp of the particular problem. I just wish I would have had this book when I started learning Python." - Daniel H
"Bob and Julian are the masters at aggregating these small snippets of code that can really make certain aspects of coding easier." - Jesse B
"This is now my favourite first Python go-to reference." - Anthony L
"Do you ever go on one of those cooking websites for a recipe and have to scroll for what feels like an eternity to get to the ingredients and the 4 steps the recipe actually takes? This is the opposite of that." - Sergio S