import datetime import uuid # Define the location and coordinates from the prompt location = "Hartsig Park, 2701 Martin Rd, Warren" geo = "42.501;-83.076" osm_link = "https://www.openstreetmap.org/?zoom=18&mlat=42.501&mlon=-83.076" # Date mappings provided by user (Year 2026 based on previous prompts) dates = { 1: "20260712", 2: "20260719", 3: "20260726", 4: "20260802", 5: "20260809", 6: "20260816", } # DTSTAMP to reflect the current date: July 15, 2026 dtstamp = "20260715T164700Z" # Original Game list games = [ # Week 1 { "week": 1, "team": "Cstop" , "opp": "Michael Scott Paper Co" , "time": "09:00" , "field": "Field 2" , "home_away": "home" }, { "week": 1, "team": "FunInSun" , "opp": "Blank Space FC" , "time": "10:00" , "field": "Field 1" , "home_away": "home" }, # Week 2 { "week": 2, "team": "Cstop" , "opp": "White Claws" , "time": "10:00" , "field": "Field 2" , "home_away": "away" }, { "week": 2, "team": "FunInSun" , "opp": "The Big Kids" , "time": "11:00" , "field": "Field 2" , "home_away": "away" }, # Week 3 { "week": 3, "team": "Cstop" , "opp": "The Big Kids" , "time": "11:00" , "field": "Field 2" , "home_away": "away" }, { "week": 3, "team": "FunInSun" , "opp": "Michael Scott Paper Co" , "time": "12:00" , "field": "Field 1" , "home_away": "home" }, # Week 4 { "week": 4, "team": "Cstop" , "opp": "#BackHeelz" , "time": "11:00" , "field": "Field 2" , "home_away": "home" }, { "week": 4, "team": "FunInSun" , "opp": "The Lions" , "time": "12:00" , "field": "Field 1" , "home_away": "home" }, # Week 5 { "week": 5, "team": "FunInSun" , "opp": "Goal Diggers" , "time": "09:00" , "field": "Field 1" , "home_away": "home" }, { "week": 5, "team": "Cstop" , "opp": "Los Viejos" , "time": "10:00" , "field": "Field 2" , "home_away": "away" }, # Week 6 { "week": 6, "team": "FunInSun" , "opp": None , "time": None , "field": None , "home_away": None }, { "week": 6, "team": "Cstop" , "opp": None , "time": None , "field": None , "home_away": None }, ] def make_ics( filtered_games, calendar_name, team_filter=None ): prodid = "Sunday Soccer 2026 July" ics_lines = [ "BEGIN:VCALENDAR", "VERSION:2.0", f"PRODID:-//SPSC Detroit//{ prodid }//EN", "CALSCALE:GREGORIAN", "METHOD:PUBLISH", f"X-WR-CALNAME:{ calendar_name }" ] # Sort chronological sorted_games = sorted( filtered_games, key = lambda g: ( g["week"], g["time"] ) ) for g in sorted_games: # Generate new, unique UUIDs using a new namespace seed for version update uid_base = f"sunday-soccer-2026-w{ g['week'] }-{ g['team'].lower().replace( ' ', '' ) }" uid = str( uuid.uuid5( uuid.NAMESPACE_DNS, uid_base ) ) date_str = dates[ g["week"] ] time_str = g["time"].replace( ":", "" ) start_dt = f"{ date_str }T{ time_str }00" # End time (1 hour later) hour = int( g["time"].split( ":" )[0] ) end_hour = f"{ hour + 1 :02d }" end_dt = f"{ date_str }T{ end_hour }0000" # Format Summary if team_filter is None: # Both teams view if g["home_away"] == "home": summary = f"⚽, w{g['week']}, {g['team']} vs {g['opp']}" else: summary = f"⚽, w{g['week']}, {g['opp']} vs {g['team']}" else: # Single team view if g["home_away"] == "home": summary = f"⚽, w{g['week']}, vs {g['opp']}" else: summary = f"⚽, w{g['week']}, @ {g['opp']}" # Enhanced Description including field info and Map Link desc = f"{ g['field'] }\\n\\nMap: { osm_link }" ics_lines.extend([ "BEGIN:VEVENT", f"UID:{ uid }", f"DTSTAMP:{ dtstamp }", f"DTSTART;TZID=America/New_York:{ start_dt }", f"DTEND;TZID=America/New_York:{ end_dt }", f"SUMMARY:{ summary }", f"LOCATION:{ location }", f"DESCRIPTION:{ desc }", f"GEO:{ geo }", "BEGIN:VALARM", "TRIGGER:-PT60M", "ACTION:DISPLAY", "DESCRIPTION:Reminder: Sunday Soccer Match starting in 1 hour!", "END:VALARM", "END:VEVENT" ]) # Append a tentative/TBD placeholder for Week 6 if team_filter is not None: # Single team placeholder w6_uid_base = f"sunday-soccer-2026-v2-w6-{team_filter.lower().replace(' ', '')}" w6_uid = str(uuid.uuid5(uuid.NAMESPACE_DNS, w6_uid_base)) ics_lines.extend([ "BEGIN:VEVENT", f"UID:{ w6_uid }", f"DTSTAMP:{ dtstamp }", f"DTSTART;TZID=America/New_York:20260816T090000", f"DTEND;TZID=America/New_York:20260816T130000", f"SUMMARY:⚽, w6, TBD Postseason/Playoff Match", f"LOCATION:{ location }", f"DESCRIPTION:Week 6 Match details (time/field/opponent) are still TBD. Keep this block cleared.\\n\\nMap: { osm_link }", f"GEO:{ geo }", "END:VEVENT" ]) else: # Both teams placeholder w6_uid_fun = str( uuid.uuid5( uuid.NAMESPACE_DNS, "sunday-soccer-2026-v2-w6-funinsun" ) ) w6_uid_cstop = str( uuid.uuid5( uuid.NAMESPACE_DNS, "sunday-soccer-2026-v2-w6-cstop" ) ) # FunInSun TBD ics_lines.extend([ "BEGIN:VEVENT", f"UID:{ w6_uid_fun }", f"DTSTAMP:{ dtstamp }", f"DTSTART;TZID=America/New_York:20260816T090000", f"DTEND;TZID=America/New_York:20260816T130000", f"SUMMARY:⚽, w6, FunInSun - TBD Playoff Match", f"LOCATION:{ location }", f"DESCRIPTION:Week 6 Playoff Match details for FunInSun are TBD.\\n\\nMap: { osm_link }", f"GEO:{ geo }", "END:VEVENT", "BEGIN:VEVENT", f"UID:{ w6_uid_cstop }", f"DTSTAMP:{ dtstamp }", f"DTSTART;TZID=America/New_York:20260816T090000", f"DTEND;TZID=America/New_York:20260816T130000", f"SUMMARY:⚽, w6, Cstop - TBD Playoff Match", f"LOCATION:{ location }", f"DESCRIPTION:Week 6 Playoff Match details for Cstop are TBD.\\n\\nMap: { osm_link }", f"GEO:{ geo }", "END:VEVENT" ]) ics_lines.append("END:VCALENDAR") return "\n".join(ics_lines) both_ics = make_ics(games, "Sunday Soccer 2026 - FunInSun & Cstop") fun_ics = make_ics([g for g in games if g["team"] == "FunInSun"], "Sunday Soccer 2026 - FunInSun", "FunInSun") cstop_ics = make_ics([g for g in games if g["team"] == "Cstop"], "Sunday Soccer 2026 - Cstop", "Cstop") # Write to files with open("sunday_soccer_both_v2.ics", "w", encoding="utf-8") as f: f.write(both_ics) with open("sunday_soccer_funinsun_v2.ics", "w", encoding="utf-8") as f: f.write(fun_ics) with open("sunday_soccer_cstop_v2.ics", "w", encoding="utf-8") as f: f.write(cstop_ics) print("Files generated successfully with version suffix.")