Spaces:
Running
Running
Fix: update vtv_api.py - EPG timezone, World Cup display, page load
Browse files- vtv_api.py +7 -3
vtv_api.py
CHANGED
|
@@ -351,7 +351,7 @@ def proxy_vtv_segment(url: str = Query(...)):
|
|
| 351 |
|
| 352 |
_epg_cache = {}
|
| 353 |
_epg_cache_time = 0
|
| 354 |
-
_EPG_CACHE_TTL =
|
| 355 |
|
| 356 |
VTV_CHANNEL_MAP = {
|
| 357 |
"vtv1": "vtv1", "vtv2": "vtv2", "vtv3": "vtv3", "vtv4": "vtv4",
|
|
@@ -430,6 +430,7 @@ def _fetch_epg_from_vtv():
|
|
| 430 |
return epg_data
|
| 431 |
|
| 432 |
def _parse_time(time_str):
|
|
|
|
| 433 |
if not time_str:
|
| 434 |
return None
|
| 435 |
time_str = time_str.strip().replace("h", ":").replace("H", ":")
|
|
@@ -437,8 +438,11 @@ def _parse_time(time_str):
|
|
| 437 |
if m:
|
| 438 |
try:
|
| 439 |
hour, minute = int(m.group(1)), int(m.group(2))
|
| 440 |
-
|
| 441 |
-
|
|
|
|
|
|
|
|
|
|
| 442 |
except:
|
| 443 |
pass
|
| 444 |
return None
|
|
|
|
| 351 |
|
| 352 |
_epg_cache = {}
|
| 353 |
_epg_cache_time = 0
|
| 354 |
+
_EPG_CACHE_TTL = 600 # Giảm từ 30 phút xuống 10 phút, đảm bảo dữ liệu mới
|
| 355 |
|
| 356 |
VTV_CHANNEL_MAP = {
|
| 357 |
"vtv1": "vtv1", "vtv2": "vtv2", "vtv3": "vtv3", "vtv4": "vtv4",
|
|
|
|
| 430 |
return epg_data
|
| 431 |
|
| 432 |
def _parse_time(time_str):
|
| 433 |
+
"""Parse giờ từ lịch phát sóng VTV (đã là giờ VN UTC+7) sang datetime."""
|
| 434 |
if not time_str:
|
| 435 |
return None
|
| 436 |
time_str = time_str.strip().replace("h", ":").replace("H", ":")
|
|
|
|
| 438 |
if m:
|
| 439 |
try:
|
| 440 |
hour, minute = int(m.group(1)), int(m.group(2))
|
| 441 |
+
# Lấy ngày hiện tại theo giờ VN (UTC+7)
|
| 442 |
+
now_vn = datetime.now(VN_TZ)
|
| 443 |
+
# Tạo datetime với giờ từ lịch, cùng ngày hiện tại theo VN
|
| 444 |
+
result = now_vn.replace(hour=hour, minute=minute, second=0, microsecond=0)
|
| 445 |
+
return result
|
| 446 |
except:
|
| 447 |
pass
|
| 448 |
return None
|