Skip to content

Commit de4bb45

Browse files
authored
Merge pull request #20 from arekbauer/vct-updates
Add TEAM_MAP for team abbreviations and update match result formatting
2 parents 5262f71 + abd8a4e commit de4bb45

2 files changed

Lines changed: 73 additions & 6 deletions

File tree

trmnl_service/services.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import requests
22
from datetime import datetime, timedelta
33
from zoneinfo import ZoneInfo
4+
from .teams import TEAM_MAP
45

56
class VLRService:
67
MATCHES_URL = "https://vlr.orlandomm.net/api/v1/matches"
@@ -26,7 +27,7 @@ def get_vct_dashboard_data(cls):
2627
return {
2728
**results, # Contains y_res and t_res
2829
**matches, # Contains live, t_up, and tom_up
29-
"last_updated": now.strftime("%H:%M")
30+
"last_updated": now.strftime("%H:%M").lower()
3031
}
3132

3233
# --- Private Logic: Processing ---
@@ -99,15 +100,24 @@ def _normalize_item(data):
99100
time_str = ""
100101

101102
if ts:
103+
# Apply 6-hour correction and convert to London Time
102104
corrected_ts = ts + (VLRService.TIME_OFFSET_HOURS * 3600)
103-
dt_utc = datetime.fromtimestamp(corrected_ts, tz=ZoneInfo("UTC"))
104-
dt_london = dt_utc.astimezone(VLRService.LONDON_TZ)
105-
time_str = dt_london.strftime("%H:%M")
105+
dt_london = datetime.fromtimestamp(corrected_ts, tz=ZoneInfo("UTC")).astimezone(VLRService.LONDON_TZ)
106+
107+
# FORMAT: 12-hour time
108+
time_str = dt_london.strftime("%I:%M%p").lower().lstrip('0')
109+
110+
t1_full = data['teams'][0]['name']
111+
t2_full = data['teams'][1]['name']
112+
113+
# Check if abbreviation exists, otherwise use full name
114+
t1_display = TEAM_MAP.get(t1_full, t1_full)
115+
t2_display = TEAM_MAP.get(t2_full, t2_full)
106116

107117
return {
108-
"t1": data['teams'][0]['name'],
118+
"t1": t1_display,
109119
"s1": data['teams'][0].get('score'),
110-
"t2": data['teams'][1]['name'],
120+
"t2": t2_display,
111121
"s2": data['teams'][1].get('score'),
112122
"tournament": data.get('tournament'),
113123
"event": data.get('event'),

trmnl_service/teams.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
TEAM_MAP = {
2+
# --- EMEA ---
3+
"Natus Vincere": "NAVI",
4+
"Karmine Corp": "KC",
5+
"Fnatic": "FNC",
6+
"Gentle Mates": "M8",
7+
"Team Vitality": "VIT",
8+
"FUT Esports": "FUT",
9+
"BBL Esports": "BBL",
10+
"PCIFIC Esports": "PCF",
11+
"Team Heretics": "TH",
12+
"Team Liquid": "TL",
13+
"GIANTX": "GX",
14+
"ULF Esports": "ULF",
15+
16+
# --- AMERICAS ---
17+
"Evil Geniuses": "EG",
18+
"G2 Esports": "G2",
19+
"100 Thieves": "100T",
20+
"Cloud9": "C9",
21+
"FURIA": "FUR",
22+
"KRÜ Esports": "KRÜ",
23+
"Leviatán": "LEV",
24+
"LOUD": "LOUD",
25+
"MIBR": "MIBR",
26+
"NRG": "NRG",
27+
"Sentinels": "SEN",
28+
"ENVY": "ENVY",
29+
30+
# --- PACIFIC ---
31+
"DetonatioN FocusMe": "DFM",
32+
"DRX": "DRX",
33+
"Gen.G": "GEN",
34+
"Global Esports": "GE",
35+
"Paper Rex": "PRX",
36+
"Rex Regum Qeon": "RRQ",
37+
"T1": "T1",
38+
"Team Secret": "TS",
39+
"ZETA DIVISION": "ZETA",
40+
"FULL SENSE": "FS",
41+
"Nongshim RedForce": "NS",
42+
"VARREL": "VL",
43+
44+
# --- CHINA ---
45+
"All Gamers": "AG",
46+
"Bilibili Gaming": "BLG",
47+
"EDward Gaming": "EDG",
48+
"FunPlus Phoenix": "FPX",
49+
"JD Gaming": "JDG",
50+
"Nova Esports": "NOVA",
51+
"Titan Esports Club": "TEC",
52+
"Trace Esports": "TE",
53+
"TYLOO": "TYL",
54+
"Wolves Esports": "WOL",
55+
"Dragon Ranger Gaming": "DRG",
56+
"XLG Esports": "XLG"
57+
}

0 commit comments

Comments
 (0)