You've already forked favicon-api-async
1. API外部接口可配置
2. 失败的url保存到文件中
This commit is contained in:
@@ -332,18 +332,14 @@ async def get_icon_async(entity: Favicon, _cached: bytes = None) -> Optional[byt
|
||||
strategies = [
|
||||
# 0. 从原始网页标签链接中获取
|
||||
lambda: (icon_url, "原始网页标签") if icon_url else (None, None),
|
||||
# 从 gstatic.cn 接口获取
|
||||
lambda: (
|
||||
f'https://t3.gstatic.cn/faviconV2?client=SOCIAL&fallback_opts=TYPE,SIZE,URL&type=FAVICON&size=128&url={entity.get_base_url()}',
|
||||
"gstatic接口"),
|
||||
# 从网站默认位置获取
|
||||
lambda: ('', "网站默认位置/favicon.ico"),
|
||||
# 从其他api接口获取
|
||||
lambda: (f'https://favicon.is/{entity.domain}', "第三方API"),
|
||||
lambda: (f'https://ico.kucat.cn/get.php?url={entity.get_base_url()}', "第三方API"),
|
||||
# 99. 最后的尝试,cloudflare workers
|
||||
# lambda: (f'https://favicon.cary.cc/?url={entity.get_base_url()}', "cloudflare"),
|
||||
]
|
||||
|
||||
# 2. 从配置文件加载其他图标获取接口
|
||||
for _template, _name in setting.FAVICON_APIS:
|
||||
strategies.append(
|
||||
lambda template=_template, name=_name:
|
||||
(template.format(domain=entity.domain, base_url=entity.get_base_url()), name)
|
||||
)
|
||||
|
||||
for strategy in strategies:
|
||||
if icon_content:
|
||||
|
||||
Reference in New Issue
Block a user