From 0c072c62be179c45285744afe22ed814df8b21e3 Mon Sep 17 00:00:00 2001 From: joneechua <156154680+joneechua@users.noreply.github.com> Date: Wed, 17 Apr 2024 16:02:15 +0800 Subject: [PATCH] =?UTF-8?q?ref(logs):=20=E5=8A=A0=E7=AB=99=E7=82=B9?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E8=B0=83=E8=AF=95=E6=97=A5=E5=BF=97=20(#651)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(brushtask): 修复刷流任务bug * del log * 兼容新版M-Team,功能包括搜索、下载、刷流、订阅、站点信息统计等 * M-Team兼容调整:优化接口调用 & 修复bug * 馒头兼容:修改站点配置,cookie不再是必填项,馒头可不填cookie * del log * 馒头兼容:修复不设置cookie后无法刷新站点统计的bug * M-Team: 修复馒头订阅下载bug * 加站点统计调试日志 --------- Co-authored-by: joneezhu --- app/sites/site_userinfo.py | 3 ++- app/sites/siteuserinfo/mteam_torrent.py | 20 ++++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/app/sites/site_userinfo.py b/app/sites/site_userinfo.py index 646171ec..ca219029 100644 --- a/app/sites/site_userinfo.py +++ b/app/sites/site_userinfo.py @@ -7,6 +7,7 @@ from urllib.parse import urlparse, urlunparse import requests +import traceback import log from app.helper import ChromeHelper, SubmoduleHelper, DbHelper @@ -240,7 +241,7 @@ def __refresh_site_data(self, site_info): except Exception as e: ExceptionUtils.exception_traceback(e) - log.error(f"【Sites】站点 {site_name} 获取流量数据失败:{str(e)}") + log.error(f"【Sites】站点 {site_name} 获取流量数据失败:{str(e)} - {traceback.format_exc()}") def __notify_unread_msg(self, site_name, site_user_info, unread_msg_notify): if site_user_info.message_unread <= 0: diff --git a/app/sites/siteuserinfo/mteam_torrent.py b/app/sites/siteuserinfo/mteam_torrent.py index ff1ab9aa..7c389d0d 100644 --- a/app/sites/siteuserinfo/mteam_torrent.py +++ b/app/sites/siteuserinfo/mteam_torrent.py @@ -51,7 +51,7 @@ def _mt_get_sys_roles(self): if not self._apikey: self.err_msg = "未设置站点Api-Key" log.warn(f"【MTeamUserInfo】 获取馒头系统角色失败, 未设置站点Api-Key") - return None + return site_url = "%s/api/member/sysRoleList" % self._base_url res = RequestUtils( headers={ @@ -126,6 +126,8 @@ def _mt_getprofile(self): def _mt_get_user_level(self, roleid): global g_sys_role_list + if roleid is None: + return "" for sysrole in g_sys_role_list: if sysrole._id == roleid: return sysrole._nameEng @@ -138,19 +140,21 @@ def _parse_user_base_info(self, html_text): self._user_detail_page = "" self._mt_get_sys_roles() user_data = self._mt_getprofile() + if user_data is None: + return memberCount = user_data.get("memberCount", {}) # 用户等级 self.user_level = self._mt_get_user_level(user_data.get("role")) # 加入日期 - self.join_at = user_data.get("createdDate") + self.join_at = user_data.get("createdDate", "") # 分享率 - self.ratio = memberCount.get("shareRate") + self.ratio = memberCount.get("shareRate", 0) # 积分 - self.bonus = memberCount.get("bonus") + self.bonus = memberCount.get("bonus", 0) # 上传 - self.upload = int(memberCount.get("uploaded")) + self.upload = int(memberCount.get("uploaded", 0)) # 下载 - self.download = int(memberCount.get("downloaded")) + self.download = int(memberCount.get("downloaded", 0)) # 拉取做种信息 self._mt_get_seeding_info() # 拉取下载信息 @@ -172,7 +176,7 @@ def _mt_get_seeding_info(self, page_num=1, page_size=100): if not self._apikey: self.err_msg = "未设置站点Api-Key" log.warn(f"【MTeamUserInfo】 获取做种信息失败, 未设置站点Api-Key") - return None + return site_url = "%s/api/member/getUserTorrentList" % self._base_url params = { "userid":self.userid, @@ -222,7 +226,7 @@ def _mt_get_leeching_info(self, page_num=1, page_size=100): if not self._apikey: self.err_msg = "未设置站点Api-Key" log.warn(f"【MTeamUserInfo】 获取下载信息失败, 未设置站点Api-Key") - return None + return site_url = "%s/api/member/getUserTorrentList" % self._base_url params = { "userid":self.userid,