bep40 commited on
Commit
296e061
·
verified ·
1 Parent(s): 1384269

Fix yt_live.js: all streams play directly from browser, xemtv PHP fallback for missing channels

Browse files
Files changed (1) hide show
  1. static/yt_live.js +14 -14
static/yt_live.js CHANGED
@@ -1,8 +1,7 @@
1
- // === VNEWS — VTV1-VTV10 LIVE CHANNELS ===
2
- // 1. Parses M3U from 3 public IPTV sources (iptv-org, Love4vn, Ykcitus)
3
- // 2. Falls back to xemtv.net PHP endpoints for missing/geo-blocked channels
4
- // 3. fptplay CDN streams are played directly from user's browser (server IP is blocked)
5
- // Uses HLS.js with auto-failover between sources
6
 
7
  (function(){
8
  if(window._ytLiveLoaded) return;
@@ -13,21 +12,20 @@
13
  {id:'vtv2', name:'VTV2', patterns:['VTV2']},
14
  {id:'vtv3', name:'VTV3', patterns:['VTV3']},
15
  {id:'vtv4', name:'VTV4', patterns:['VTV4']},
16
- {id:'vtv5', name:'VTV5', patterns:['VTV5','VTV5HD']},
17
- {id:'vtv6', name:'VTV Cần Thơ', patterns:['VTV6']},
18
  {id:'vtv7', name:'VTV7', patterns:['VTV7']},
19
  {id:'vtv8', name:'VTV8', patterns:['VTV8']},
20
  {id:'vtv9', name:'VTV9', patterns:['VTV9']},
21
- {id:'vtv10', name:'VTV10', patterns:['VTV10','VTV Cần Thơ','VTV Can Tho','VTVCT','vtvcantho','Cần Thơ']},
22
  ];
23
 
24
  const M3U_SOURCES = [
25
  {name:'iptv-org', url:'https://raw.githubusercontent.com/iptv-org/iptv/master/streams/vn.m3u'},
26
- {name:'Love4vn', url:'https://raw.githubusercontent.com/Love4vn/Test/master/VTV.m3u'},
27
  {name:'Ykcitus', url:'https://raw.githubusercontent.com/Ykcitus/IPTV/master/vietnam.m3u'},
28
  ];
29
 
30
- // xemtv.net PHP fallback for channels that are geo-blocked in M3U
31
  const XEMTV_PHP = [
32
  'https://hd.xemtv.net/kenh/vtv1.php',
33
  'https://hd.xemtv.net/kenh/vtv2.php',
@@ -128,7 +126,7 @@
128
  const loadEl = document.getElementById('vtv-load');
129
  if(loadEl) loadEl.innerHTML = '<div class="vtv-spinner"></div>Đang tải danh sách kênh...';
130
 
131
- // Fetch all 3 M3U sources in parallel
132
  const results = await Promise.allSettled(M3U_SOURCES.map(src => fetchM3U(src.url)));
133
  CHANNELS.forEach(ch => { STREAMS[ch.id] = []; });
134
 
@@ -149,13 +147,12 @@
149
  });
150
 
151
  // For channels with no M3U URL, try xemtv.net PHP fallback
152
- const fallbackPromises = CHANNELS.map(async (ch, idx) => {
153
  if(STREAMS[ch.id].length === 0 && XEMTV_PHP[idx]){
154
  const url = await fetchXemtvPhp(XEMTV_PHP[idx]);
155
  if(url) STREAMS[ch.id].push(url);
156
  }
157
- });
158
- await Promise.allSettled(fallbackPromises);
159
 
160
  // Update UI
161
  CHANNELS.forEach(ch => {
@@ -245,6 +242,8 @@
245
  const src = urls[idx];
246
  const sourceLabel = ' (' + (idx+1) + '/' + urls.length + ')';
247
  loadEl.innerHTML = '<div class="vtv-spinner"></div>Đang kết nối ' + name + sourceLabel + '...';
 
 
248
  if(typeof Hls !== 'undefined' && Hls.isSupported()){
249
  const hls = new Hls({
250
  enableWorker: true,
@@ -269,6 +268,7 @@
269
  });
270
  hls.on(Hls.Events.ERROR, (ev, data) => {
271
  if(data.fatal){
 
272
  if(data.type === Hls.ErrorTypes.NETWORK_ERROR){
273
  setTimeout(() => {
274
  hls.destroy();
 
1
+ // === VNEWS — VTV LIVE CHANNELS ===
2
+ // All streams played directly from user's browser (server IP is blocked by fptplay CDN)
3
+ // Sources: iptv-org M3U, Ykcitus M3U, xemtv.net PHP fallback
4
+ // Uses HLS.js with auto-failover
 
5
 
6
  (function(){
7
  if(window._ytLiveLoaded) return;
 
12
  {id:'vtv2', name:'VTV2', patterns:['VTV2']},
13
  {id:'vtv3', name:'VTV3', patterns:['VTV3']},
14
  {id:'vtv4', name:'VTV4', patterns:['VTV4']},
15
+ {id:'vtv5', name:'VTV5', patterns:['VTV5']},
16
+ {id:'vtv6', name:'VTV6', patterns:['VTV6']},
17
  {id:'vtv7', name:'VTV7', patterns:['VTV7']},
18
  {id:'vtv8', name:'VTV8', patterns:['VTV8']},
19
  {id:'vtv9', name:'VTV9', patterns:['VTV9']},
20
+ {id:'vtv10', name:'VTV Cần Thơ', patterns:['VTV10','VTV Cần Thơ','VTV Can Tho','VTVCT','vtvcantho','Cần Thơ','vtv can tho']},
21
  ];
22
 
23
  const M3U_SOURCES = [
24
  {name:'iptv-org', url:'https://raw.githubusercontent.com/iptv-org/iptv/master/streams/vn.m3u'},
 
25
  {name:'Ykcitus', url:'https://raw.githubusercontent.com/Ykcitus/IPTV/master/vietnam.m3u'},
26
  ];
27
 
28
+ // xemtv.net PHP fallback for channels not found in M3U
29
  const XEMTV_PHP = [
30
  'https://hd.xemtv.net/kenh/vtv1.php',
31
  'https://hd.xemtv.net/kenh/vtv2.php',
 
126
  const loadEl = document.getElementById('vtv-load');
127
  if(loadEl) loadEl.innerHTML = '<div class="vtv-spinner"></div>Đang tải danh sách kênh...';
128
 
129
+ // Fetch all M3U sources in parallel
130
  const results = await Promise.allSettled(M3U_SOURCES.map(src => fetchM3U(src.url)));
131
  CHANNELS.forEach(ch => { STREAMS[ch.id] = []; });
132
 
 
147
  });
148
 
149
  // For channels with no M3U URL, try xemtv.net PHP fallback
150
+ await Promise.allSettled(CHANNELS.map(async (ch, idx) => {
151
  if(STREAMS[ch.id].length === 0 && XEMTV_PHP[idx]){
152
  const url = await fetchXemtvPhp(XEMTV_PHP[idx]);
153
  if(url) STREAMS[ch.id].push(url);
154
  }
155
+ }));
 
156
 
157
  // Update UI
158
  CHANNELS.forEach(ch => {
 
242
  const src = urls[idx];
243
  const sourceLabel = ' (' + (idx+1) + '/' + urls.length + ')';
244
  loadEl.innerHTML = '<div class="vtv-spinner"></div>Đang kết nối ' + name + sourceLabel + '...';
245
+
246
+ // All streams played directly from browser (server IP blocked by fptplay CDN)
247
  if(typeof Hls !== 'undefined' && Hls.isSupported()){
248
  const hls = new Hls({
249
  enableWorker: true,
 
268
  });
269
  hls.on(Hls.Events.ERROR, (ev, data) => {
270
  if(data.fatal){
271
+ console.warn(`VLS: ${name} source ${idx+1} fatal error:`, data.type, data.details);
272
  if(data.type === Hls.ErrorTypes.NETWORK_ERROR){
273
  setTimeout(() => {
274
  hls.destroy();