This commit is contained in:
jinql
2025-09-08 22:51:15 +08:00
parent f5f1c4e0b0
commit 24df67a6a2
7 changed files with 9 additions and 34 deletions

View File

@@ -40,12 +40,8 @@ class FaviconService:
self.url_count = 0
self.request_icon_count = 0
self.request_cache_count = 0
self.domain_list: List[str] = list()
# 初始化队列
# 实时处理的任务数量
# self.icon_queue = Queue()
# 所有正在处理的任务数量
self.total_queue = Queue()
# # 队列阈值常量配置
@@ -238,7 +234,7 @@ class FaviconService:
self._get_link_rel(html_links, entity, ''))
if icon_url:
logger.info(f"-> 从HTML获取图标URL: {icon_url}")
logger.debug(f"-> 从HTML获取图标URL: {icon_url}")
return icon_url
except Exception as e:
@@ -270,12 +266,6 @@ class FaviconService:
icon_content = None
try:
if entity.domain in self.domain_list:
self._queue_pull(True, self.total_queue)
return _cached or setting.default_icon_file
else:
self.domain_list.append(entity.domain)
# 尝试从网站获取HTML内容
html_content = entity.req_get()
if html_content:
@@ -305,7 +295,7 @@ class FaviconService:
strategy_url, strategy_name = strategy()
if strategy_url is not None:
logger.info(f"-> 尝试从 {strategy_name} 获取图标")
logger.debug(f"-> 尝试从 {strategy_name} 获取图标")
icon_content, icon_type = entity.get_icon_file(strategy_url, strategy_url == '')
# 图标获取失败,或图标不是支持的图片格式,写入默认图标
@@ -335,8 +325,6 @@ class FaviconService:
logger.error(f"获取图标时发生错误 {entity.domain}: {e}")
return _cached or setting.default_icon_file
finally:
if entity.domain in self.domain_list:
self.domain_list.remove(entity.domain)
# 任务完成,从两个队列中移出元素
self._queue_pull(True, self.total_queue)
@@ -347,7 +335,6 @@ class FaviconService:
'request_icon_count': self.request_icon_count,
'request_cache_count': self.request_cache_count,
'queue_size': self.total_queue.qsize(),
'domain_list': len(self.domain_list),
}
def get_favicon_handler(