Skip to content

Commit

Permalink
ref(logs): 加站点统计调试日志 (#651)
Browse files Browse the repository at this point in the history
* fix(brushtask): 修复刷流任务bug

* del log

* 兼容新版M-Team,功能包括搜索、下载、刷流、订阅、站点信息统计等

* M-Team兼容调整:优化接口调用 & 修复bug

* 馒头兼容:修改站点配置,cookie不再是必填项,馒头可不填cookie

* del log

* 馒头兼容:修复不设置cookie后无法刷新站点统计的bug

* M-Team: 修复馒头订阅下载bug

* 加站点统计调试日志

---------

Co-authored-by: joneezhu <[email protected]>
  • Loading branch information
joneechua and joneezhu authored Apr 17, 2024
1 parent f93cd9a commit 0c072c6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
3 changes: 2 additions & 1 deletion app/sites/site_userinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from urllib.parse import urlparse, urlunparse

import requests
import traceback

import log
from app.helper import ChromeHelper, SubmoduleHelper, DbHelper
Expand Down Expand Up @@ -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:
Expand Down
20 changes: 12 additions & 8 deletions app/sites/siteuserinfo/mteam_torrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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={
Expand Down Expand Up @@ -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
Expand All @@ -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()
# 拉取下载信息
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 0c072c6

Please sign in to comment.