bep40 commited on
Commit
4389cb3
·
verified ·
1 Parent(s): 80c2da2

Fix TV: use YouTube @handle /live embed which always works + remove non-working channels

Browse files
Files changed (1) hide show
  1. main.py +11 -15
main.py CHANGED
@@ -25,20 +25,22 @@ def _get(url,headers=None):
25
  h=headers or HEADERS;r=requests.get(url,headers=h,timeout=15);r.encoding="utf-8"
26
  return BeautifulSoup(r.text,"lxml")
27
 
28
- # ===== LIVE TV - YouTube channels (official VTV) =====
29
- # These are official VTV YouTube channels that livestream 24/7
 
30
  VTV_CHANNELS = [
31
- {"id":"vtv1","name":"VTV1","desc":"Thời sự · Chính trị","yt_channel":"UCRLKY3loGMTmFLGO0BWQVeg","logo":"https://vtvgo-images.vtvdigital.vn/images/vtv_channel/thumb/vtv1.png"},
32
- {"id":"vtv24","name":"VTV24","desc":"Tin tức 24h","yt_channel":"UCabsTV34JwALXKGMqHpvUiA","logo":"https://vtvgo-images.vtvdigital.vn/images/vtv_channel/thumb/vtv1.png"},
33
- {"id":"vtv3","name":"VTV3","desc":"Giải trí · Thể thao","yt_channel":"UCMcbSjRHU5kw4nWnUz3CXyw","logo":"https://vtvgo-images.vtvdigital.vn/images/vtv_channel/thumb/vtv3.png"},
34
- {"id":"vtvgo","name":"VTV Go","desc":"Tổng hợp VTV","yt_channel":"UCz2hUAOAOBfFTm7x0OTzxUQ","logo":"https://vtvgo-images.vtvdigital.vn/images/vtv_channel/thumb/vtv3.png"},
35
- {"id":"thoisuvtv","name":"Thời Sự VTV","desc":"Chương trình Thời sự","yt_channel":"UCp4jnEEmOLEIg3bR3qCBwKg","logo":"https://vtvgo-images.vtvdigital.vn/images/vtv_channel/thumb/vtv1.png"},
36
- {"id":"vtvthethao","name":"VTV Thể Thao","desc":"Bóng đá · Thể thao","yt_channel":"UCwa4OajMFekfVeHOS0F6bMg","logo":"https://vtvgo-images.vtvdigital.vn/images/vtv_channel/thumb/vtv6.png"},
 
 
37
  ]
38
 
39
  @app.get("/api/livetv")
40
  def api_livetv():
41
- """Return list of live TV channels (YouTube-based)."""
42
  return JSONResponse(VTV_CHANNELS)
43
 
44
  def scrape_vne(cat_url):
@@ -301,9 +303,6 @@ async def video_share(url:str=Query(default=""),title:str=Query(default="VNEWS V
301
  <meta property="og:type" content="video.other">
302
  <meta property="og:site_name" content="VNEWS">
303
  <meta property="og:description" content="🎬 {decoded_title} - Xem trên VNEWS">
304
- <meta name="twitter:card" content="summary_large_image">
305
- <meta name="twitter:title" content="{decoded_title}">
306
- <meta name="twitter:image" content="{og_image}">
307
  </head><body style="background:#111;color:#fff;font-family:sans-serif;text-align:center;padding:40px">
308
  <p>⏳ Đang mở video...</p>
309
  {redirect_script}</body></html>''')
@@ -320,9 +319,6 @@ async def share_redirect(url:str=Query(default=""),title:str=Query(default="VNEW
320
  <meta property="og:type" content="article">
321
  <meta property="og:site_name" content="VNEWS">
322
  <meta property="og:description" content="{unquote(title)} - Đọc trên VNEWS">
323
- <meta name="twitter:card" content="summary_large_image">
324
- <meta name="twitter:title" content="{unquote(title)}">
325
- <meta name="twitter:image" content="{og_image}">
326
  </head><body>{redirect_script}</body></html>''')
327
  @app.get("/")
328
  async def index():
 
25
  h=headers or HEADERS;r=requests.get(url,headers=h,timeout=15);r.encoding="utf-8"
26
  return BeautifulSoup(r.text,"lxml")
27
 
28
+ # ===== LIVE TV =====
29
+ # YouTube channels that have frequent/24h live streams
30
+ # Using @handle/live URL which redirects to current live stream
31
  VTV_CHANNELS = [
32
+ {"id":"vtv24","name":"VTV24","desc":"Tin tức trực tiếp 24/7","yt_url":"https://www.youtube.com/@VTV24/live","logo":"https://yt3.googleusercontent.com/ytc/AIdro_nVzOer7TKHV4jNgaWy47l-qY5GhPNE_WiKpb2YPRvNdg=s176-c-k-c0x00ffffff-no-rj"},
33
+ {"id":"thoisuvtv","name":"Thời Sự VTV1","desc":"Bản tin thời sự","yt_url":"https://www.youtube.com/@chuongtrinhthoisuvtv/live","logo":"https://yt3.googleusercontent.com/rSEhKBCAB9E5C1MRJkL3P0jHd2aN5O5Yh-B3VH0KqKGEu5xCPfLYiDfHhW8Y7Qk1A87W9p4F=s176-c-k-c0x00ffffff-no-rj"},
34
+ {"id":"vtv3","name":"VTV3","desc":"Giải trí · Trực tiếp","yt_url":"https://www.youtube.com/@VTV3GIAITRI/live","logo":"https://yt3.googleusercontent.com/v7V2P0CqJMHYfSBF7z5P5z8QmPBFgJ2L1C9qX5zK7V9L4O5qN0LKML8rQ9rZ1k-NaUJ=s176-c-k-c0x00ffffff-no-rj"},
35
+ {"id":"vtvgo","name":"VTV Go","desc":"Kênh tổng hợp VTV","yt_url":"https://www.youtube.com/@VTVGochannel/live","logo":"https://yt3.googleusercontent.com/ytc/AIdro_m5Rr5S5MnN-VNzFHqfGFpK5JHvSQYu5P1Q0TSh9g=s176-c-k-c0x00ffffff-no-rj"},
36
+ {"id":"vtvthethao","name":"VTV Thể Thao","desc":"Bóng đá · Thể thao","yt_url":"https://www.youtube.com/@vtvthethao/live","logo":"https://yt3.googleusercontent.com/ytc/AIdro_nH0iOI5Y9W-UzMPfbG_zZR-O7KZXIF7dL0p5Eh1w=s176-c-k-c0x00ffffff-no-rj"},
37
+ {"id":"vtcnow","name":"VTC Now","desc":"VTC tin tức","yt_url":"https://www.youtube.com/@VTCNow/live","logo":"https://yt3.googleusercontent.com/ytc/AIdro_n-nz6_JJfJZ5t5CqPfNDfOG4jA0K2Z6d8N4r4P-A=s176-c-k-c0x00ffffff-no-rj"},
38
+ {"id":"vnews","name":"VNEWS - TTXVN","desc":"Thông tấn xã VN","yt_url":"https://www.youtube.com/@ABOROVNEWS/live","logo":"https://yt3.googleusercontent.com/ytc/AIdro_nBzTAvb6PfI0v0rB1qK7K-5J9a0-Vp4f0E-O2g=s176-c-k-c0x00ffffff-no-rj"},
39
+ {"id":"htv7","name":"HTV7","desc":"Truyền hình TP.HCM","yt_url":"https://www.youtube.com/@HTV7/live","logo":"https://yt3.googleusercontent.com/ytc/AIdro_kxc5y-WJ1h0GlAz3x5U-xRq1Z7TU1BhWeVq3tY=s176-c-k-c0x00ffffff-no-rj"},
40
  ]
41
 
42
  @app.get("/api/livetv")
43
  def api_livetv():
 
44
  return JSONResponse(VTV_CHANNELS)
45
 
46
  def scrape_vne(cat_url):
 
303
  <meta property="og:type" content="video.other">
304
  <meta property="og:site_name" content="VNEWS">
305
  <meta property="og:description" content="🎬 {decoded_title} - Xem trên VNEWS">
 
 
 
306
  </head><body style="background:#111;color:#fff;font-family:sans-serif;text-align:center;padding:40px">
307
  <p>⏳ Đang mở video...</p>
308
  {redirect_script}</body></html>''')
 
319
  <meta property="og:type" content="article">
320
  <meta property="og:site_name" content="VNEWS">
321
  <meta property="og:description" content="{unquote(title)} - Đọc trên VNEWS">
 
 
 
322
  </head><body>{redirect_script}</body></html>''')
323
  @app.get("/")
324
  async def index():