mirror of
https://github.com/d0zingcat/MoviePilot-Plugins.git
synced 2026-05-13 23:16:47 +00:00
fix(站点数据统计): 修复YemaPT站点数据统计
This commit is contained in:
@@ -31,11 +31,12 @@
|
||||
"name": "站点数据统计",
|
||||
"description": "自动统计和展示站点数据。",
|
||||
"labels": "站点,仪表板",
|
||||
"version": "3.8",
|
||||
"version": "3.9",
|
||||
"icon": "statistic.png",
|
||||
"author": "lightolly",
|
||||
"level": 2,
|
||||
"history": {
|
||||
"v3.9": "修复YemaPT站点数据统计",
|
||||
"v3.8": "适配m-team Api地址变化",
|
||||
"v3.7": "修复观众做种数据统计",
|
||||
"v3.6": "支持站点数据统计刷新后触发插件事件",
|
||||
|
||||
@@ -43,7 +43,7 @@ class SiteStatistic(_PluginBase):
|
||||
# 插件图标
|
||||
plugin_icon = "statistic.png"
|
||||
# 插件版本
|
||||
plugin_version = "3.8"
|
||||
plugin_version = "3.9"
|
||||
# 插件作者
|
||||
plugin_author = "lightolly"
|
||||
# 作者主页
|
||||
@@ -1199,19 +1199,21 @@ class SiteStatistic(_PluginBase):
|
||||
|
||||
# 兼容假首页情况,假首页通常没有 <link rel="search" 属性
|
||||
if '"search"' not in html_text and '"csrf-token"' not in html_text:
|
||||
res = RequestUtils(cookies=site_cookie,
|
||||
session=session,
|
||||
ua=ua,
|
||||
proxies=proxies
|
||||
).get_res(url=url + "/index.php")
|
||||
if res and res.status_code == 200:
|
||||
if re.search(r"charset=\"?utf-8\"?", res.text, re.IGNORECASE):
|
||||
res.encoding = "utf-8"
|
||||
else:
|
||||
res.encoding = res.apparent_encoding
|
||||
html_text = res.text
|
||||
if not html_text:
|
||||
return None
|
||||
# 排除掉单页面应用,单页面应用首页包含一个 div 容器
|
||||
if not re.search(r"id=\"?root\"?", res.text, re.IGNORECASE):
|
||||
res = RequestUtils(cookies=site_cookie,
|
||||
session=session,
|
||||
ua=ua,
|
||||
proxies=proxies
|
||||
).get_res(url=url + "/index.php")
|
||||
if res and res.status_code == 200:
|
||||
if re.search(r"charset=\"?utf-8\"?", res.text, re.IGNORECASE):
|
||||
res.encoding = "utf-8"
|
||||
else:
|
||||
res.encoding = res.apparent_encoding
|
||||
html_text = res.text
|
||||
if not html_text:
|
||||
return None
|
||||
elif res is not None:
|
||||
logger.error(f"站点 {site_name} 连接失败,状态码:{res.status_code}")
|
||||
return None
|
||||
|
||||
@@ -27,10 +27,10 @@ class TYemaSiteUserInfo(ISiteUserInfo):
|
||||
self._sys_mail_unread_page = None
|
||||
self._user_mail_unread_page = None
|
||||
self._mail_unread_params = {}
|
||||
self._torrent_seeding_page = "api/torrent/fetchUserTorrentList"
|
||||
self.__torrent_seeding_params = {
|
||||
"status": "seeding",
|
||||
"pageParam": {"current": 1, "pageSize": 40, "total": 40}
|
||||
self._torrent_seeding_page = "/api/userTorrent/fetchSeedTorrentInfo"
|
||||
self._torrent_seeding_params = {
|
||||
# 虽然这个参数是无意义的,但这个 API 必须用 POST
|
||||
"status": "seeding"
|
||||
}
|
||||
self._torrent_seeding_headers = {}
|
||||
self._addition_headers = {
|
||||
@@ -87,41 +87,18 @@ class TYemaSiteUserInfo(ISiteUserInfo):
|
||||
if not html_text:
|
||||
return None
|
||||
seeding_info = json.loads(html_text)
|
||||
if not seeding_info or not seeding_info.get("success"):
|
||||
if not seeding_info or not seeding_info.get("success") or not seeding_info.get("data"):
|
||||
return None
|
||||
torrents = seeding_info.get("data") or []
|
||||
page_seeding_size = 0
|
||||
page_seeding_info = []
|
||||
for info in torrents:
|
||||
size = info.get("promotionUploadSize")
|
||||
seeders = '0'
|
||||
page_seeding_size += size
|
||||
page_seeding_info.append([seeders, size])
|
||||
self.seeding += len(torrents)
|
||||
self.seeding_size += page_seeding_size
|
||||
self.seeding_info.extend(page_seeding_info)
|
||||
|
||||
# 查询总做种数
|
||||
seeder_count = 0
|
||||
try:
|
||||
result = self._get_page_content(
|
||||
url=urljoin(self.site_url, "api/torrent/fetchUserTorrentCount"),
|
||||
params={
|
||||
"status": "seeding",
|
||||
}
|
||||
)
|
||||
if result:
|
||||
seeder_info = json.loads(result)
|
||||
seeder_count = seeder_info.get("data") or 0
|
||||
except Exception as e:
|
||||
logger.error(f"获取做种数失败: {str(e)}")
|
||||
if not seeder_count:
|
||||
return None
|
||||
if self.seeding >= seeder_count:
|
||||
return None
|
||||
# 还有下一页
|
||||
self._torrent_seeding_params["pageParam"]["current"] += 1
|
||||
return ""
|
||||
torrents = seeding_info.get("data")
|
||||
|
||||
self.seeding += torrents.get("num")
|
||||
self.seeding_size += torrents.get("fileSize")
|
||||
|
||||
# 是否存在下页数据
|
||||
next_page = None
|
||||
|
||||
return next_page
|
||||
|
||||
def _parse_message_unread_links(self, html_text: str, msg_links: list) -> Optional[str]:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user