diff --git a/config/URL_config.ini b/config/URL_config.ini
index a29751d..4972f70 100644
--- a/config/URL_config.ini
+++ b/config/URL_config.ini
@@ -1 +1 @@
-https://live.douyin.com/147650297461
\ No newline at end of file
+https://live.douyin.com/147650297461,主播: 娱乐摆摊记
diff --git a/hdmi.sh b/hdmi.sh
new file mode 100644
index 0000000..a5c240c
--- /dev/null
+++ b/hdmi.sh
@@ -0,0 +1 @@
+python -u main.py
diff --git a/index.html b/index.html
index 9e46770..354e34a 100644
--- a/index.html
+++ b/index.html
@@ -1,215 +1,113 @@
-
-
+
-
-
-
- M3U8 视频播放器
-
-
-
-
-
-
-
+
+
+M3U8/FLV + PM2 控制
+
+
+
-
-
-
-
-
-
-
-
说明
-
M3U8文件格式
-
M3U8文件是采用UTF-8编码格式的M3U文件。M3U文件本身是一个纯文本索引文件,其核心功能是记录多媒体文件链接。当用户打开此类文件时,播放软件会根据索引查找相应的音视频文件网络地址,然后进行在线播放。
-
M3U最初设计用于播放音频文件,例如MP3。但随着时间推移,更多的播放器和软件开始使用M3U来播放视频文件列表,同时也支持在线流媒体音频源的指定。目前,许多播放器和软件都兼容M3U文件格式。
-
FLV文件格式(Flash Video Format)是Adobe公司开发的一种专门用于网页视频播放的文件格式。FLV格式的视频文件通常用于播放短视频和在线流媒体,可以嵌入到网页中供用户观看。FLV视频通常由Adobe Flash Player播放器播放,而其他第三方播放器也支持此格式。
-
-
-
- document.getElementById('playButton').addEventListener('click', playVideo);
-
-
diff --git a/index2.html b/index2.html
new file mode 100644
index 0000000..9e46770
--- /dev/null
+++ b/index2.html
@@ -0,0 +1,215 @@
+
+
+
+
+
+
+
+ M3U8 视频播放器
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
说明
+
M3U8文件格式
+
M3U8文件是采用UTF-8编码格式的M3U文件。M3U文件本身是一个纯文本索引文件,其核心功能是记录多媒体文件链接。当用户打开此类文件时,播放软件会根据索引查找相应的音视频文件网络地址,然后进行在线播放。
+
M3U最初设计用于播放音频文件,例如MP3。但随着时间推移,更多的播放器和软件开始使用M3U来播放视频文件列表,同时也支持在线流媒体音频源的指定。目前,许多播放器和软件都兼容M3U文件格式。
+
FLV文件格式(Flash Video Format)是Adobe公司开发的一种专门用于网页视频播放的文件格式。FLV格式的视频文件通常用于播放短视频和在线流媒体,可以嵌入到网页中供用户观看。FLV视频通常由Adobe Flash Player播放器播放,而其他第三方播放器也支持此格式。
+
+
+
+
+
+
diff --git a/web.py b/web.py
new file mode 100644
index 0000000..ee2dcf5
--- /dev/null
+++ b/web.py
@@ -0,0 +1,71 @@
+from fastapi import FastAPI
+from fastapi.responses import FileResponse, JSONResponse
+from fastapi.staticfiles import StaticFiles
+import subprocess
+from pathlib import Path
+from fastapi.middleware.cors import CORSMiddleware
+
+app = FastAPI()
+
+# ---------------- 配置 ----------------
+BOT_NAME = "hdmi" # PM2 进程名
+BASE_DIR = Path(__file__).parent
+
+# 允许前端跨域访问
+app.add_middleware(
+ CORSMiddleware,
+ allow_origins=["*"],
+ allow_methods=["*"],
+ allow_headers=["*"],
+)
+
+# 静态文件
+app.mount("/static", StaticFiles(directory=BASE_DIR), name="static")
+
+# ---------------- PM2 控制 ----------------
+def pm2_cmd(cmd: str):
+ try:
+ out = subprocess.check_output(f"pm2 {cmd}", shell=True, stderr=subprocess.STDOUT, text=True)
+ return out
+ except subprocess.CalledProcessError as e:
+ return e.output
+
+def read_log(log_type="out", lines=50):
+ log_file = BASE_DIR.parent / f".pm2/logs/{BOT_NAME}-{log_type}.log"
+ try:
+ with open(log_file, "r", encoding="utf-8") as f:
+ content = f.readlines()[-lines:]
+ return "".join(content)
+ except FileNotFoundError:
+ return f"未找到日志文件: {log_file}"
+
+@app.get("/start")
+def start():
+ out = pm2_cmd(f"start {BOT_NAME}")
+ return JSONResponse({"action": "start", "output": out})
+
+@app.get("/stop")
+def stop():
+ out = pm2_cmd(f"stop {BOT_NAME} --no-autorestart")
+ return JSONResponse({"action": "stop", "output": out})
+
+@app.get("/restart")
+def restart():
+ out = pm2_cmd(f"restart {BOT_NAME}")
+ return JSONResponse({"action": "restart", "output": out})
+
+@app.get("/status")
+def status():
+ status = pm2_cmd(f"status {BOT_NAME}")
+ log = read_log("out", 50)
+ error_log = read_log("error", 50)
+ return JSONResponse({
+ "status": status,
+ "recent_log": log,
+ "recent_error": error_log
+ })
+
+# ---------------- HTML ----------------
+@app.get("/")
+def index():
+ return FileResponse(BASE_DIR / "index.html")