mirror of
https://github.com/d0zingcat/MoviePilot-Plugins.git
synced 2026-06-07 15:10:32 +00:00
fix SiteStatistic
This commit is contained in:
@@ -3,11 +3,12 @@
|
|||||||
"name": "站点数据统计",
|
"name": "站点数据统计",
|
||||||
"description": "站点统计数据图表。",
|
"description": "站点统计数据图表。",
|
||||||
"labels": "站点,仪表板",
|
"labels": "站点,仪表板",
|
||||||
"version": "1.7.1",
|
"version": "1.7.2",
|
||||||
"icon": "statistic.png",
|
"icon": "statistic.png",
|
||||||
"author": "lightolly,jxxghp",
|
"author": "lightolly,jxxghp",
|
||||||
"level": 2,
|
"level": 2,
|
||||||
"history": {
|
"history": {
|
||||||
|
"v1.7.2": "修复站点数据增量处理逻辑",
|
||||||
"v1.7.1": "优化内存占用",
|
"v1.7.1": "优化内存占用",
|
||||||
"v1.6": "优化了站点数据获取失败时的回退逻辑",
|
"v1.6": "优化了站点数据获取失败时的回退逻辑",
|
||||||
"v1.5": "修复了发送增量通知失败等一些问题",
|
"v1.5": "修复了发送增量通知失败等一些问题",
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class SiteStatistic(_PluginBase):
|
|||||||
# 插件图标
|
# 插件图标
|
||||||
plugin_icon = "statistic.png"
|
plugin_icon = "statistic.png"
|
||||||
# 插件版本
|
# 插件版本
|
||||||
plugin_version = "1.7.1"
|
plugin_version = "1.7.2"
|
||||||
# 插件作者
|
# 插件作者
|
||||||
plugin_author = "lightolly,jxxghp"
|
plugin_author = "lightolly,jxxghp"
|
||||||
# 作者主页
|
# 作者主页
|
||||||
@@ -229,9 +229,17 @@ class SiteStatistic(_PluginBase):
|
|||||||
download = int(today_data_dict[site].download or 0)
|
download = int(today_data_dict[site].download or 0)
|
||||||
updated_date = today_data_dict[site].updated_day
|
updated_date = today_data_dict[site].updated_day
|
||||||
|
|
||||||
if self._notify_type == "inc" and yesterday_data_dict.get(site):
|
if self._notify_type == "inc":
|
||||||
upload -= int(yesterday_data_dict[site].upload or 0)
|
# 增量数据模式:只有当有昨天数据时才计算增量
|
||||||
download -= int(yesterday_data_dict[site].download or 0)
|
if yesterday_data_dict.get(site):
|
||||||
|
upload -= int(yesterday_data_dict[site].upload or 0)
|
||||||
|
download -= int(yesterday_data_dict[site].download or 0)
|
||||||
|
# 确保增量不为负数
|
||||||
|
upload = max(0, upload)
|
||||||
|
download = max(0, download)
|
||||||
|
else:
|
||||||
|
# 没有昨天数据时,跳过该站点
|
||||||
|
continue
|
||||||
|
|
||||||
if updated_date and updated_date != today_date:
|
if updated_date and updated_date != today_date:
|
||||||
updated_date = f"({updated_date})"
|
updated_date = f"({updated_date})"
|
||||||
@@ -354,7 +362,8 @@ class SiteStatistic(_PluginBase):
|
|||||||
if not d1:
|
if not d1:
|
||||||
return {}
|
return {}
|
||||||
if not d2:
|
if not d2:
|
||||||
return d1
|
# 如果没有昨天数据,返回空字典,表示无增量数据
|
||||||
|
return {}
|
||||||
d = {k: __to_numeric(d1.get(k)) - __to_numeric(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))}
|
if k in d2 and __is_digit(d1.get(k)) and __is_digit(d2.get(k))}
|
||||||
# 把小于0的数据变成0
|
# 把小于0的数据变成0
|
||||||
@@ -658,14 +667,15 @@ class SiteStatistic(_PluginBase):
|
|||||||
# 计算增量数据集
|
# 计算增量数据集
|
||||||
inc_data = {}
|
inc_data = {}
|
||||||
for data in stattistic_data:
|
for data in stattistic_data:
|
||||||
yesterday_datas = [yd for yd in yesterday_sites_data if yd.domain == data.domain]
|
# 修复:使用name进行匹配,保持一致性
|
||||||
|
yesterday_datas = [yd for yd in yesterday_sites_data if yd.name == data.name]
|
||||||
if yesterday_datas:
|
if yesterday_datas:
|
||||||
yesterday_data = yesterday_datas[0]
|
yesterday_data = yesterday_datas[0]
|
||||||
else:
|
# 只有当有昨天数据时才计算增量
|
||||||
yesterday_data = None
|
inc = __sub_data(data.to_dict(), yesterday_data.to_dict())
|
||||||
inc = __sub_data(data.to_dict(), yesterday_data.to_dict() if yesterday_data else None)
|
if inc:
|
||||||
if inc:
|
inc_data[data.name] = inc
|
||||||
inc_data[data.name] = inc
|
# 如果没有昨天数据,不添加到inc_data中
|
||||||
# 今日上传
|
# 今日上传
|
||||||
uploads = {k: v for k, v in inc_data.items() if v.get("upload") if v.get("upload") > 0}
|
uploads = {k: v for k, v in inc_data.items() if v.get("upload") if v.get("upload") > 0}
|
||||||
# 今日上传站点
|
# 今日上传站点
|
||||||
|
|||||||
Reference in New Issue
Block a user