bep40 commited on
Commit
aa5083a
·
verified ·
1 Parent(s): 4d8e550

Fix shorts: use @baodantri7941 + @fptbongdaofficial, increase timeout to 90s, sequential fetch for reliability

Browse files
Files changed (1) hide show
  1. main.py +8 -7
main.py CHANGED
@@ -164,7 +164,7 @@ def extract_xemlaibongda_video(url):
164
  # ===== YOUTUBE SHORTS =====
165
  def _yt_channel_shorts(channel, count=15):
166
  try:
167
- result=subprocess.run(["yt-dlp","--flat-playlist","--dump-json","--no-download","--playlist-end",str(count),f"https://www.youtube.com/@{channel}/shorts"],capture_output=True,text=True,timeout=60)
168
  videos=[]
169
  for line in result.stdout.strip().split('\n'):
170
  if not line:continue
@@ -176,13 +176,14 @@ def _yt_channel_shorts(channel, count=15):
176
  return videos
177
  except:return[]
178
  def scrape_shorts():
179
- """Fetch shorts from multiple channels"""
180
  vids=[]
181
- with ThreadPoolExecutor(2) as ex:
182
- futs=[ex.submit(_yt_channel_shorts,ch,10) for ch in ["baodantri7941","baosuckhoedoisongboyte"]]
183
- for f in as_completed(futs):
184
- try:vids.extend(f.result())
185
- except:pass
 
186
  return vids[:20]
187
 
188
  # ===== LIVESCORE =====
 
164
  # ===== YOUTUBE SHORTS =====
165
  def _yt_channel_shorts(channel, count=15):
166
  try:
167
+ result=subprocess.run(["yt-dlp","--flat-playlist","--dump-json","--no-download","--playlist-end",str(count),f"https://www.youtube.com/@{channel}/shorts"],capture_output=True,text=True,timeout=90)
168
  videos=[]
169
  for line in result.stdout.strip().split('\n'):
170
  if not line:continue
 
176
  return videos
177
  except:return[]
178
  def scrape_shorts():
179
+ """Fetch shorts from @baodantri7941 and @fptbongdaofficial"""
180
  vids=[]
181
+ for ch in ["baodantri7941","fptbongdaofficial"]:
182
+ try:
183
+ r=_yt_channel_shorts(ch,10)
184
+ if r:vids.extend(r)
185
+ except:pass
186
+ if len(vids)>=15:break
187
  return vids[:20]
188
 
189
  # ===== LIVESCORE =====