Spaces:
Running
Running
Fix shorts: --no-check-certificates for SSL fix, 15 per channel
Browse files
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=90)
|
| 168 |
videos=[]
|
| 169 |
for line in result.stdout.strip().split('\n'):
|
| 170 |
if not line:continue
|
|
@@ -179,13 +179,12 @@ def scrape_shorts():
|
|
| 179 |
"""Fetch shorts from @baodantri7941 + @baosuckhoedoisongboyte, sorted newest first"""
|
| 180 |
vids=[]
|
| 181 |
with ThreadPoolExecutor(2) as ex:
|
| 182 |
-
futs=[ex.submit(_yt_channel_shorts,ch,
|
| 183 |
for f in as_completed(futs):
|
| 184 |
try:
|
| 185 |
r=f.result()
|
| 186 |
if r:vids.extend(r)
|
| 187 |
except:pass
|
| 188 |
-
# yt-dlp returns newest first per channel; interleave to keep chronological
|
| 189 |
vids.sort(key=lambda x:x.get("id",""),reverse=True)
|
| 190 |
return vids[:20]
|
| 191 |
|
|
|
|
| 164 |
# ===== YOUTUBE SHORTS =====
|
| 165 |
def _yt_channel_shorts(channel, count=15):
|
| 166 |
try:
|
| 167 |
+
result=subprocess.run(["yt-dlp","--no-check-certificates","--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
|
|
|
|
| 179 |
"""Fetch shorts from @baodantri7941 + @baosuckhoedoisongboyte, sorted newest first"""
|
| 180 |
vids=[]
|
| 181 |
with ThreadPoolExecutor(2) as ex:
|
| 182 |
+
futs=[ex.submit(_yt_channel_shorts,ch,15) for ch in ["baodantri7941","baosuckhoedoisongboyte"]]
|
| 183 |
for f in as_completed(futs):
|
| 184 |
try:
|
| 185 |
r=f.result()
|
| 186 |
if r:vids.extend(r)
|
| 187 |
except:pass
|
|
|
|
| 188 |
vids.sort(key=lambda x:x.get("id",""),reverse=True)
|
| 189 |
return vids[:20]
|
| 190 |
|