feat:max_channels limit
This commit is contained in:
parent
3bf0b45a3b
commit
e3887b9ec8
@ -8,6 +8,7 @@
|
||||
- 更新使用说明,关于可能导致工作流资源滥用的情况说明(Updated usage instructions, explanation about situations that may lead to workflow resource abuse)
|
||||
- 增加.gitignore 文件,忽略用户配置、接口更新结果、日志文件等上传,非代码逻辑修改请不要发起 Pull requests,避免影响他人使用(Added .gitignore file to ignore uploads of user configurations, interface update results, log files, etc. Please do not initiate pull requests for non-code logic modifications to avoid affecting others' use)
|
||||
- 调整更新频率,每日 8:00 执行一次(Adjusted update frequency, executes once daily at 8:00)
|
||||
- 调整更新频道数量上限(200 个)(Adjusted the maximum limit for updating channel numbers (200))
|
||||
|
||||
## v1.0.3
|
||||
|
||||
|
@ -31,7 +31,7 @@ When you click to confirm and create in step one, you will be automatically redi
|
||||
|
||||
1. Create file
|
||||
2. Name the template file user_demo.txt
|
||||
3. The template file needs to be written in the format of (channel category, #genre#), (channel name, channel interface), note that it is an English comma.
|
||||
3. The template file needs to be written in the format of (channel category, #genre#), (channel name, channel interface), note that it is an English comma. The maximum number of channels is 200, any excess will not be updated.
|
||||
4. Click Commit changes... to save.
|
||||
|
||||
## Step 3: Modify the Configuration
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
1. 创建文件
|
||||
2. 模板文件命名为 user_demo.txt
|
||||
3. 模板文件需要按照(频道分类,#genre#),(频道名称,频道接口)进行编写,注意是英文逗号
|
||||
3. 模板文件需要按照(频道分类,#genre#),(频道名称,频道接口)进行编写,注意是英文逗号。频道总数上限为 200 个,超出部分将无法更新。
|
||||
4. 点击 Commit changes...进行保存
|
||||
|
||||
## 步骤三:修改配置
|
||||
|
19
utils.py
19
utils.py
@ -12,8 +12,6 @@ import urllib.parse
|
||||
import ipaddress
|
||||
from urllib.parse import urlparse
|
||||
|
||||
# 在这里使用 some_config_variable
|
||||
|
||||
|
||||
def getChannelItems():
|
||||
"""
|
||||
@ -30,23 +28,28 @@ def getChannelItems():
|
||||
|
||||
# Create a dictionary to store the channels.
|
||||
channels = {}
|
||||
current_channel = ""
|
||||
current_category = ""
|
||||
pattern = r"^(.*?),(?!#genre#)(.*?)$"
|
||||
total_channels = 0
|
||||
max_channels = 200
|
||||
|
||||
for line in lines:
|
||||
if total_channels >= max_channels:
|
||||
break
|
||||
line = line.strip()
|
||||
if "#genre#" in line:
|
||||
# This is a new channel, create a new key in the dictionary.
|
||||
current_channel = line.split(",")[0]
|
||||
channels[current_channel] = {}
|
||||
current_category = line.split(",")[0]
|
||||
channels[current_category] = {}
|
||||
else:
|
||||
# This is a url, add it to the list of urls for the current channel.
|
||||
match = re.search(pattern, line)
|
||||
if match:
|
||||
if match.group(1) not in channels[current_channel]:
|
||||
channels[current_channel][match.group(1)] = [match.group(2)]
|
||||
if match.group(1) not in channels[current_category]:
|
||||
channels[current_category][match.group(1)] = [match.group(2)]
|
||||
total_channels += 1
|
||||
else:
|
||||
channels[current_channel][match.group(1)].append(match.group(2))
|
||||
channels[current_category][match.group(1)].append(match.group(2))
|
||||
return channels
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user