The bet365.utils module provides utility functions for common data transformation tasks when working with Bet365 data, including odds conversion, datetime formatting, and list manipulation.
14-character timestamp string in format YYYYMMDDHHMMSS
Returns:str - Formatted datetime string in format DD/MM/YYYY HH:MM:SSExample:
from bet365.utils import format_datetime# Format a timestamptimestamp = "20260306143000"formatted = format_datetime(timestamp)print(formatted) # Output: 06/03/2026 14:30:00# Another exampletimestamp2 = "20251225120000"formatted2 = format_datetime(timestamp2)print(formatted2) # Output: 25/12/2025 12:00:00# Handle edge casesempty = format_datetime("")print(empty) # Output: ""short = format_datetime("2026")print(short) # Output: 2026
Timestamp format breakdown:
Positions 0-3: Year (YYYY)
Positions 4-5: Month (MM)
Positions 6-7: Day (DD)
Positions 8-9: Hour (HH)
Positions 10-11: Minute (MM)
Positions 12-13: Second (SS)
Usage example:
for idx, section in parser.find_sections("EV", include_part_index=True): event_time = section.get_property("TU") if event_time: readable_time = format_datetime(event_time) event_name = section.get_property("NA") print(f"{event_name} starts at {readable_time}") # Output: Manchester United vs Liverpool starts at 15/03/2026 17:30:00
from bet365 import Bet365AndroidSessionfrom bet365.message_parser import get_parsersfrom bet365.utils import parse_odds, format_datetime, split_list_by_delimitersession = Bet365AndroidSession( api_url="https://api.example.com/generate", api_key="your-api-key")session.go_homepage()# Get match dataresponse = session.protected_get( f"https://{session.host}/splashcontentapi/getsplashpods", params={"lid": "1", "pd": "#AS#B1#"}, headers={"X-b365App-ID": "8.0.36.00-row"})# Parse responseparsers = get_parsers(response.text)for parser in parsers: # Find match groups for idx, section in parser.find_sections("MG", include_part_index=True): match_name = section.get_property("NA") # Format match time if available match_time = section.get_property("TU") if match_time: formatted_time = format_datetime(match_time) print(f"\n{match_name} - {formatted_time}") else: print(f"\n{match_name}") # Find participant odds for odds_idx, odds_section in parser.find_sections("PA", include_part_index=True): team = odds_section.get_property("FD") fractional = odds_section.get_property("OD") if fractional: decimal = parse_odds(fractional) print(f" {team}: {fractional} ({decimal:.2f})")# Example output:# Manchester United vs Liverpool - 15/03/2026 17:30:00# Manchester United: 5/2 (3.50)# Draw: 9/4 (3.25)# Liverpool: 6/5 (2.20)