filtering only today's matches
Browse files
app.py
CHANGED
|
@@ -23,7 +23,16 @@ def get_live_cricket_matches()-> list: #it's import to specify the return type
|
|
| 23 |
data = response.json()
|
| 24 |
if "data" in data:
|
| 25 |
match_info = []
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
return {"error": "Unable to fetch match data"}
|
| 28 |
|
| 29 |
@tool
|
|
|
|
| 23 |
data = response.json()
|
| 24 |
if "data" in data:
|
| 25 |
match_info = []
|
| 26 |
+
for match in data["data"]:
|
| 27 |
+
if "date" in match and match["date"].startswith(today):
|
| 28 |
+
if match.get("matchType") == "t20" or match.get("matchType") == "odi":
|
| 29 |
+
match_info.append({
|
| 30 |
+
"teams": " vs ".join(match.get('teams', [])),
|
| 31 |
+
"score": match.get("score"),
|
| 32 |
+
"status": match.get("status"),
|
| 33 |
+
"dateTimeGMT": match.get("dateTimeGMT")
|
| 34 |
+
})
|
| 35 |
+
return match_info
|
| 36 |
return {"error": "Unable to fetch match data"}
|
| 37 |
|
| 38 |
@tool
|