bep40 commited on
Commit
89eefee
·
verified ·
1 Parent(s): aa0dcfd

fix: swap xemtivitop primary, remove Dantri/SKDS shorts from vtv_api.py

Browse files
Files changed (1) hide show
  1. vtv_api.py +25 -21
vtv_api.py CHANGED
@@ -1,8 +1,7 @@
1
  """
2
  VTV Channels API - Backend endpoints for VTV1-VTV10 + VTVPrime
3
- Fetches stream URLs from xemtv.us PHP endpoints (primary)
4
- Alternative: xemtivitop.com (backup)
5
- Fallback: FPTPlay CDN → VTVGo CDN → xemtv.net (legacy)
6
  EPG data scraped from https://vtv.vn/lich-phat-song.htm
7
  """
8
  import re, time, threading
@@ -21,7 +20,21 @@ UA = {
21
  "Accept-Language": "vi-VN,vi;q=0.9",
22
  }
23
 
24
- # ===== PRIMARY: xemtv.us (new domain, works 2025-2026) =====
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  XEMTV_US_ENDPOINTS = {
26
  "vtv1": "https://xemtv.us/tv/vtv1.php",
27
  "vtv2": "https://xemtv.us/tv/vtv2.php",
@@ -36,20 +49,6 @@ XEMTV_US_ENDPOINTS = {
36
  "vtvprime": "https://xemtv.us/tv/vtvprime.php",
37
  }
38
 
39
- # ===== ALTERNATIVE: xemtivitop.com (backup source) =====
40
- XEMTIVITOP_ENDPOINTS = {
41
- "vtv1": "https://www.xemtivitop.com/2018/10/vtv1-online.html?m=1",
42
- "vtv2": "https://www.xemtivitop.com/2018/10/vtv2-online.html?m=1",
43
- "vtv3": "https://www.xemtivitop.com/2018/10/vtv3-online.html?m=1",
44
- "vtv4": "https://www.xemtivitop.com/2018/10/vtv4-online.html?m=1",
45
- "vtv5": "https://www.xemtivitop.com/2018/10/vtv5-online.html?m=1",
46
- "vtv6": "https://www.xemtivitop.com/2018/10/vtv6-online.html?m=1",
47
- "vtv7": "https://www.xemtivitop.com/2018/10/vtv7-online.html?m=1",
48
- "vtv8": "https://www.xemtivitop.com/2018/10/vtv8-online.html?m=1",
49
- "vtv9": "https://www.xemtivitop.com/2018/10/vtv9-online.html?m=1",
50
- "vtv10": "https://www.xemtivitop.com/2020/05/vtv10-can-tho-online.html?m=1",
51
- }
52
-
53
  # ===== LEGACY: xemtv.net (may return 403, keep as last resort) =====
54
  XEMTV_LEGACY_ENDPOINTS = {
55
  "vtv1": "https://hd.xemtv.net/kenh/vtv1.php",
@@ -257,34 +256,39 @@ def fetch_vtv_stream(channel_id):
257
  return cached
258
 
259
  if channel_id == 'vtvprime':
260
- url = fetch_xemtv_us_stream('vtvprime') or fetch_xemtivitop_stream('vtvprime') or fetch_xemtv_legacy_stream('vtvprime')
261
  if url:
262
  url = normalize_fptplay_url(url)
263
  _set_cache(channel_id, url)
264
  return url
265
 
266
- url = fetch_xemtv_us_stream(channel_id)
 
267
  if url:
268
  url = normalize_fptplay_url(url)
269
  _set_cache(channel_id, url)
270
  return url
271
 
272
- url = fetch_xemtivitop_stream(channel_id)
 
273
  if url:
274
  url = normalize_fptplay_url(url)
275
  _set_cache(channel_id, url)
276
  return url
277
 
 
278
  url = fetch_fptplay_stream(channel_id)
279
  if url:
280
  _set_cache(channel_id, url)
281
  return url
282
 
 
283
  url = fetch_vtvgo_stream(channel_id)
284
  if url:
285
  _set_cache(channel_id, url)
286
  return url
287
 
 
288
  url = fetch_xemtv_legacy_stream(channel_id)
289
  if url:
290
  url = normalize_fptplay_url(url)
 
1
  """
2
  VTV Channels API - Backend endpoints for VTV1-VTV10 + VTVPrime
3
+ Fetches stream URLs from xemtivitop.com (primary)
4
+ Backup: xemtv.us → FPTPlay CDN → VTVGo CDN → xemtv.net (legacy)
 
5
  EPG data scraped from https://vtv.vn/lich-phat-song.htm
6
  """
7
  import re, time, threading
 
20
  "Accept-Language": "vi-VN,vi;q=0.9",
21
  }
22
 
23
+ # ===== PRIMARY: xemtivitop.com (blogspot/pages) =====
24
+ XEMTIVITOP_ENDPOINTS = {
25
+ "vtv1": "https://www.xemtivitop.com/2018/10/vtv1-online.html?m=1",
26
+ "vtv2": "https://www.xemtivitop.com/2018/10/vtv2-online.html?m=1",
27
+ "vtv3": "https://www.xemtivitop.com/2018/10/vtv3-online.html?m=1",
28
+ "vtv4": "https://www.xemtivitop.com/2018/10/vtv4-online.html?m=1",
29
+ "vtv5": "https://www.xemtivitop.com/2018/10/vtv5-online.html?m=1",
30
+ "vtv6": "https://www.xemtivitop.com/2018/10/vtv6-online.html?m=1",
31
+ "vtv7": "https://www.xemtivitop.com/2018/10/vtv7-online.html?m=1",
32
+ "vtv8": "https://www.xemtivitop.com/2018/10/vtv8-online.html?m=1",
33
+ "vtv9": "https://www.xemtivitop.com/2018/10/vtv9-online.html?m=1",
34
+ "vtv10": "https://www.xemtivitop.com/2020/05/vtv10-can-tho-online.html?m=1",
35
+ }
36
+
37
+ # ===== BACKUP: xemtv.us =====
38
  XEMTV_US_ENDPOINTS = {
39
  "vtv1": "https://xemtv.us/tv/vtv1.php",
40
  "vtv2": "https://xemtv.us/tv/vtv2.php",
 
49
  "vtvprime": "https://xemtv.us/tv/vtvprime.php",
50
  }
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  # ===== LEGACY: xemtv.net (may return 403, keep as last resort) =====
53
  XEMTV_LEGACY_ENDPOINTS = {
54
  "vtv1": "https://hd.xemtv.net/kenh/vtv1.php",
 
256
  return cached
257
 
258
  if channel_id == 'vtvprime':
259
+ url = fetch_xemtivitop_stream('vtvprime') or fetch_xemtv_us_stream('vtvprime') or fetch_xemtv_legacy_stream('vtvprime')
260
  if url:
261
  url = normalize_fptplay_url(url)
262
  _set_cache(channel_id, url)
263
  return url
264
 
265
+ # 1. Primary: xemtivitop.com (blogspot pages - FPTPlay CDN m3u8 embedded)
266
+ url = fetch_xemtivitop_stream(channel_id)
267
  if url:
268
  url = normalize_fptplay_url(url)
269
  _set_cache(channel_id, url)
270
  return url
271
 
272
+ # 2. Backup: xemtv.us (PHP endpoints)
273
+ url = fetch_xemtv_us_stream(channel_id)
274
  if url:
275
  url = normalize_fptplay_url(url)
276
  _set_cache(channel_id, url)
277
  return url
278
 
279
+ # 3. Fallback: FPTPlay CDN direct
280
  url = fetch_fptplay_stream(channel_id)
281
  if url:
282
  _set_cache(channel_id, url)
283
  return url
284
 
285
+ # 4. Fallback: VTVGo CDN
286
  url = fetch_vtvgo_stream(channel_id)
287
  if url:
288
  _set_cache(channel_id, url)
289
  return url
290
 
291
+ # 5. Last resort: xemtv.net legacy
292
  url = fetch_xemtv_legacy_stream(channel_id)
293
  if url:
294
  url = normalize_fptplay_url(url)