diff --git a/Dockerfile b/Dockerfile index 3469c00487..78fa90462b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,9 +16,11 @@ FROM python:3.13-slim ARG APP_WORKDIR=/iptv-api ARG LITE=False +ARG APP_PORT=8000 ENV APP_WORKDIR=$APP_WORKDIR ENV LITE=$LITE +ENV APP_PORT=$APP_PORT ENV PATH="/.venv/bin:$PATH" WORKDIR $APP_WORKDIR @@ -47,7 +49,7 @@ RUN (crontab -l ; \ echo "0 22 * * * cd $APP_WORKDIR && /.venv/bin/python main.py"; \ echo "0 10 * * * cd $APP_WORKDIR && /.venv/bin/python main.py") | crontab - -EXPOSE 8000 +EXPOSE $APP_PORT COPY entrypoint.sh /iptv-api-entrypoint.sh diff --git a/README.md b/README.md index 087d933752..66cfa21615 100644 --- a/README.md +++ b/README.md @@ -215,6 +215,12 @@ docker run -v /etc/docker/config:/iptv-api/config -v /etc/docker/output:/iptv-ap docker run -v /etc/docker/config:/iptv-api-lite/config -v /etc/docker/output:/iptv-api-lite/output -d -p 8000:8000 guovern/iptv-api:lite ``` +端口环境变量: + +```bash +-e APP_PORT=8000 +``` + 3. 更新结果: - 接口地址:ip:8000 diff --git a/README_en.md b/README_en.md index 1d6e70bdd5..f4897dd75b 100644 --- a/README_en.md +++ b/README_en.md @@ -222,6 +222,12 @@ docker run -v /etc/docker/config:/iptv-api/config -v /etc/docker/output:/iptv-ap docker run -v /etc/docker/config:/iptv-api-lite/config -v /etc/docker/output:/iptv-api-lite/output -d -p 8000:8000 guovern/iptv-api:lite ``` +Port environment variables: + +```bash +-e APP_PORT=8000 +``` + 3. Update results: - API address: ip:8000 diff --git a/config/whitelist.txt b/config/whitelist.txt index d11d6c4495..bfb8695cfe 100644 --- a/config/whitelist.txt +++ b/config/whitelist.txt @@ -1,4 +1,4 @@ # 这是接口或订阅源的白名单,白名单内的接口或订阅源获取的接口将不会参与测速,优先排序至结果最前。 # 填写频道名称会直接保留该记录至最终结果,如:CCTV-1,接口地址,只填写接口地址则对所有频道生效,多条记录换行输入。 # This is the whitelist of the interface or subscription source. The interface in the whitelist or the interface obtained by the subscription source will not participate in the speed measurement and will be prioritized in the result. -# Filling in the channel name will directly retain the record to the final result, such as: CCTV-1, interface address, only fill in the interface address will be effective for all channels, multiple records newline input. +# Filling in the channel name will directly retain the record to the final result, such as: CCTV-1,url, only fill in the interface address will be effective for all channels, multiple records newline input. diff --git a/docs/tutorial.md b/docs/tutorial.md index 1ee117287d..540c0f7eb3 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -59,8 +59,10 @@ 1. 创建文件 2. 模板文件命名为 user_demo.txt 3. + 模板文件需要按照(频道分类,#genre#),(频道名称,频道接口)进行编写,注意是英文逗号。如果需要将该接口设为白名单(不测速、保留在结果最前),可在地址后添加$!即可,例如http://xxx$! 。后面也可以添加额外说明信息,如:http://xxx$!白名单接口 + 4. 点击 Commit changes...进行保存 ![创建user_demo.txt](./images/edit-user-demo.png '创建user_demo.txt') @@ -263,6 +265,12 @@ docker run -v /etc/docker/config:/iptv-api/config -v /etc/docker/output:/iptv-ap docker run -v /etc/docker/config:/iptv-api-lite/config -v /etc/docker/output:/iptv-api-lite/output -d -p 8000:8000 guovern/iptv-api:lite ``` +端口环境变量: + +```bash +-e APP_PORT=8000 +``` + 3. 更新结果: - 接口地址:ip:8000 diff --git a/docs/tutorial_en.md b/docs/tutorial_en.md index e31df28e90..162691471d 100644 --- a/docs/tutorial_en.md +++ b/docs/tutorial_en.md @@ -285,6 +285,12 @@ docker run -v /etc/docker/config:/iptv-api/config -v /etc/docker/output:/iptv-ap docker run -v /etc/docker/config:/iptv-api-lite/config -v /etc/docker/output:/iptv-api-lite/output -d -p 8000:8000 guovern/iptv-api:lite ``` +Port environment variables: + +```bash +-e APP_PORT=8000 +``` + 3. Update results: - API address: ip:8000 diff --git a/entrypoint.sh b/entrypoint.sh index 9431678b95..c930201374 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -14,4 +14,4 @@ service cron start & python $APP_WORKDIR/main.py & -python -m gunicorn service.app:app -b 0.0.0.0:8000 --timeout=1000 \ No newline at end of file +python -m gunicorn service.app:app -b 0.0.0.0:$APP_PORT --timeout=1000 \ No newline at end of file diff --git a/service/app.py b/service/app.py index 13674d189c..7a8dd3616f 100644 --- a/service/app.py +++ b/service/app.py @@ -52,7 +52,7 @@ def run_service(): print(f"🚀 M3u api: {ip_address}/m3u") print(f"🚀 Txt api: {ip_address}/txt") print(f"✅ You can use this url to watch IPTV 📺: {ip_address}") - app.run(host="0.0.0.0", port=8000) + app.run(host="0.0.0.0", port=os.environ.get("APP_PORT") or 8000) except Exception as e: print(f"❌ Service start failed: {e}") diff --git a/utils/channel.py b/utils/channel.py index 9fe3602beb..1ff5e7f4c5 100644 --- a/utils/channel.py +++ b/utils/channel.py @@ -600,7 +600,7 @@ def write_channel_to_file(data, ipv6=False, callback=None): open_empty_category = config.open_empty_category ipv_type_prefer = list(config.ipv_type_prefer) if any(pref in ipv_type_prefer for pref in ["自动", "auto"]) or not ipv_type_prefer: - ipv_type_prefer = ["ipv6", "ipv4"] if (ipv6 or (not os.environ.get("GITHUB_ACTIONS"))) else ["ipv4", "ipv6"] + ipv_type_prefer = ["ipv6", "ipv4"] if (ipv6 or os.environ.get("GITHUB_ACTIONS")) else ["ipv4", "ipv6"] origin_type_prefer = config.origin_type_prefer for cate, channel_obj in data.items(): print(f"\n{cate}:", end=" ") diff --git a/utils/tools.py b/utils/tools.py index 7e20da2c93..260c84b781 100644 --- a/utils/tools.py +++ b/utils/tools.py @@ -356,7 +356,7 @@ def get_ip_address(): IP = "127.0.0.1" finally: s.close() - return f"http://{IP}:8000" + return f"http://{IP}:{os.environ.get("APP_PORT") or 8000}" def convert_to_m3u():