mirror of
https://github.com/d0zingcat/MoviePilot-Plugins.git
synced 2026-05-18 07:26:46 +00:00
Merge pull request #446 from InfinityPacer/main
This commit is contained in:
@@ -163,11 +163,12 @@
|
||||
"name": "自定义Hosts",
|
||||
"description": "修改系统hosts文件,加速网络访问。",
|
||||
"labels": "网络",
|
||||
"version": "1.1",
|
||||
"version": "1.2",
|
||||
"icon": "hosts.png",
|
||||
"author": "thsrite",
|
||||
"level": 1,
|
||||
"history": {
|
||||
"v1.2": "支持写入注释",
|
||||
"v1.1": "关闭插件时自动恢复系统hosts"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -18,7 +18,7 @@ class CustomHosts(_PluginBase):
|
||||
# 插件图标
|
||||
plugin_icon = "hosts.png"
|
||||
# 插件版本
|
||||
plugin_version = "1.1"
|
||||
plugin_version = "1.2"
|
||||
# 插件作者
|
||||
plugin_author = "thsrite"
|
||||
# 作者主页
|
||||
@@ -235,6 +235,12 @@ class CustomHosts(_PluginBase):
|
||||
for host in hosts:
|
||||
if not host:
|
||||
continue
|
||||
host = host.strip()
|
||||
if host.startswith('#'): # 检查是否为注释行
|
||||
host_entry = HostsEntry(entry_type='comment', comment=host)
|
||||
new_entrys.append(host_entry)
|
||||
continue
|
||||
|
||||
host_arr = str(host).split()
|
||||
try:
|
||||
host_entry = HostsEntry(entry_type='ipv4' if IpUtils.is_ipv4(str(host_arr[0])) else 'ipv6',
|
||||
|
||||
Reference in New Issue
Block a user