bep40 commited on
Commit
970bc2d
·
verified ·
1 Parent(s): 8f78638

Hướng dẫn khôi phục main.py từ commit 5b6000c

Browse files
Files changed (1) hide show
  1. RESTORE_FROM_5B6000C.md +44 -0
RESTORE_FROM_5B6000C.md ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # KHÔI PHỤC VNEWS — main.py bị ghi đè thành PLACEHOLDER
2
+
3
+ **Tình trạng:** `main.py` trên branch `main` đang là `PLACEHOLDER` (11 bytes)
4
+ → Space không boot được (`_run.py → app_v2_entry.py → import main` crash).
5
+ **Tất cả nguồn khôi phục còn nguyên vẹn** (đã xác minh bằng list file):
6
+ commit `5b6000c58f89723b3d228afb06c891ce909ac488`, tag
7
+ `backup-main-before-restore-5b6000c`, branch `restore-5b6000c-withfix`
8
+ (96 files, `main.py` = 64.2KB, khớp 100%).
9
+
10
+ ## Cách A — Nhanh nhất (web UI, không cần code, ~1 phút)
11
+ 1. `https://huggingface.co/settings/branches/bep40/VNEWS`
12
+ 2. Đổi **Default branch** → `restore-5b6000c-withfix`
13
+ 3. Space tự build lại từ code lành → site online.
14
+ 4. (Tùy chọn) Trên trang repo dùng **"Compare & pull request"** để merge
15
+ `restore-5b6000c-withfix` vào `main` qua UI (server-side, không vướng lỗi
16
+ PR của tool).
17
+
18
+ ## Cách B — Script python (cần môi trường có HF_TOKEN, ~30 giây)
19
+ ```bash
20
+ pip install -q huggingface_hub
21
+ python - <<'PY'
22
+ from huggingface_hub import hf_hub_download, upload_file
23
+ import os
24
+ REPO="bep40/VNEWS"; REV="5b6000c58f89723b3d228afb06c891ce909ac488"
25
+ p = hf_hub_download(repo_id=REPO, filename="main.py", revision=REV, repo_type="space")
26
+ assert os.path.getsize(p) > 50000
27
+ c = open(p, encoding="utf-8").read()
28
+ assert "proxy_m3u_hls" in c and '"VNEWS' in c
29
+ upload_file(path_or_fileobj=c.encode("utf-8"), path_in_repo="main.py",
30
+ repo_id=REPO, repo_type="space",
31
+ commit_message="Khoi phuc main.py tu commit 5b6000c (xoa PLACEHOLDER)")
32
+ print("OK", len(c))
33
+ PY
34
+ ```
35
+
36
+ ## Sau khi Space online — fix HLS (kênh MPEG-TS/Stalker stall sau ~8s)
37
+ Trong `main.py`, block `# Raw MPEG-TS / Stalker stream: emit a live HLS wrapper
38
+ playlist.` (endpoint `/api/proxy/m3u_hls`):
39
+ - Tăng `#EXTINF:8.0` lặp từ 3 → **8 segment** (giữ cùng `_seg` URL)
40
+ - Thêm `#EXT-X-DISCONTINUITY-SEQUENCE:0` sau `#EXT-X-MEDIA-SEQUENCE:0`
41
+ - Giữ `#EXT-X-VERSION:6`, `#EXT-X-TARGETDURATION:8`, `#EXT-X-START:...`,
42
+ KHÔNG thêm `#EXT-X-ENDLIST`, KHÔNG có `#EXT-X-DISCONTINUITY` cuối.
43
+ Frontend `static/vtv_init.js` (`playNativeHLS`): `new Hls({ enableWorker: false,
44
+ liveDurationInfinity: true, liveSyncDurationCount: 5, maxBufferLength: 60 })`.