Merge pull request #570 from zhi1ong/main

This commit is contained in:
jxxghp
2024-11-22 15:38:03 +08:00
committed by GitHub
2 changed files with 16 additions and 3 deletions

View File

@@ -3,11 +3,12 @@
"name": "站点数据统计",
"description": "站点统计数据图表。",
"labels": "站点,仪表板",
"version": "1.1",
"version": "1.2",
"icon": "statistic.png",
"author": "lightolly,jxxghp",
"level": 2,
"history": {
"v1.2": "继续修复增量数据统计问题",
"v1.1": "修复增量数据统计问题",
"v1.0": "MoviePilot V2 版本站点数据统计插件"
}

View File

@@ -32,7 +32,7 @@ class SiteStatistic(_PluginBase):
# 插件图标
plugin_icon = "statistic.png"
# 插件版本
plugin_version = "1.1"
plugin_version = "1.2"
# 插件作者
plugin_author = "lightolly,jxxghp"
# 作者主页
@@ -246,6 +246,18 @@ class SiteStatistic(_PluginBase):
return value.isdigit()
return False
def __to_numeric(value: any) -> int:
"""
将值转换为整数
"""
if isinstance(value, str):
return int(float(value))
elif isinstance(value, float) or isinstance(value, int):
return int(value)
else:
logger.error(f'数据类型转换错误 ({value})')
return 0
def __sub_data(d1: dict, d2: dict) -> dict:
"""
计算两个字典相同Key值的差值如果值为数字返回新字典
@@ -254,7 +266,7 @@ class SiteStatistic(_PluginBase):
return {}
if not d2:
return d1
d = {k: d1.get(k) - d2.get(k) for k in d1
d = {k: __to_numeric(d1.get(k)) - __to_numeric(d2.get(k)) for k in d1
if k in d2 and __is_digit(d1.get(k)) and __is_digit(d2.get(k))}
# 把小于0的数据变成0
for k, v in d.items():