1- import requests # Import the 'requests' library for making HTTP requests.
2-
1+ import requests # Import the 'requests' library for making HTTP requests.
32
43def main ():
5- r = requests .get (
4+ menu_detail = dict ( requests .get (
65 "http://themealdb.com/api/json/v1/1/random.php"
7- ) # Fetch a random meal data from the API.
8- meal_detail = dict (r .json ())["meals" ][
6+ ).json ())["meals" ][
97 0
10- ] # Extract the details of the first meal from the API response.
8+ ] # Extract the details of the first meal from the API response.
119
1210 # TODO: Get information from the menu
13- menu_name = meal_detail [
11+ menu_name = menu_detail [
1412 "strMeal"
15- ] # Extract the name of the meal from the meal detail.
16- menu_category = meal_detail [
13+ ] # Extract the name of the meal from the meal detail.
14+ menu_category = menu_detail [
1715 "strCategory"
18- ] # Extract the category of the meal from the meal detail.
19- menu_tags = meal_detail [
16+ ] # Extract the category of the meal from the meal detail.
17+ menu_tags = menu_detail [
2018 "strTags"
21- ] # Extract the tags (if available) of the meal from the meal detail.
22- menu_country = meal_detail [
19+ ] # Extract the tags (if available) of the meal from the meal detail.
20+ menu_country = menu_detail [
2321 "strArea"
24- ] # Extract the country of the meal from the meal detail.
25- menu_instruction = meal_detail [
22+ ] # Extract the country of the meal from the meal detail.
23+ menu_instruction = menu_detail [
2624 "strInstructions"
27- ] # Extract the cooking instructions of the meal.
28- menu_video = meal_detail [
25+ ] # Extract the cooking instructions of the meal.
26+ menu_video = menu_detail [
2927 "strYoutube"
30- ] # Extract the YouTube video link for the meal (if available).
28+ ] # Extract the YouTube video link for the meal (if available).
3129
3230 # TODO: Define color codes for printing colored output.
3331 class bcolors :
@@ -52,4 +50,4 @@ class bcolors:
5250
5351
5452if __name__ == "__main__" :
55- main () # Call the main function when the script is executed as the main program.
53+ main () # Call the main function when the script is executed as the main program.
0 commit comments