diff --git a/docs/pttime.groovy b/docs/pttime.groovy
index 8af05fb..cb1724d 100644
--- a/docs/pttime.groovy
+++ b/docs/pttime.groovy
@@ -1,8 +1,9 @@
// PTTIME 适配脚本
-// PTTIME 基于 NexusPHP,但 HTML 结构有差异:
-// - 搜索页 torrent 表格无
,数据行直接 下
-// - 用户信息在 #info_block > td.bottom.clearfix 中
-// - 做种/下载数用 ⬆⬇ emoji 表示
+// PTTIME 基于 NexusPHP,HTML 结构差异:
+// - 搜索页 torrent 表格无
+// - 用户信息在 #info_block 中
+// - 做种/下载数用 ⬆⬇ emoji
+// - 认证字段 ctx.site.auth
Map parse(String content, String url) {
def doc = jsoup.parse(content)
@@ -15,8 +16,6 @@ Map parse(String content, String url) {
return [pageName: '未知页面', message: "未配置: ${url}"]
}
-// ── 首页 / 用户信息 ──
-
private Map parseIndex(doc) {
def el = utils.selectFirst(doc, '#info_block')
if (!el) return [pageName: '首页', message: '未找到用户信息']
@@ -37,11 +36,8 @@ private Map parseIndex(doc) {
return [pageName: '用户信息', fields: fields]
}
-// ── 搜索(无 tbody 版本)──
-
private Map parseSearch(doc) {
def rows = []
- // PTTIME 列表列序: 类别|标题|PTR(dn)|评论(dn)|时间|大小|做种|下载|完成|进度|发布者|行为
doc.select('table.torrents tr:has(td.rowfollow):not(:has(.colhead))').each { row ->
def titleEl = utils.selectFirst(row, 'td.embedded a.torrentname_title')
if (!titleEl) return
@@ -63,30 +59,23 @@ private Map parseSearch(doc) {
return [pageName: '搜索', extracted: rows, message: "共 ${rows.size()} 条"]
}
-// ── 种子详情 ──
-
private Map parseDetail(doc) {
def fields = [:]
def titleEl = utils.selectFirst(doc, 'a.torrentname_title b, #top h1')
fields.title = utils.text(titleEl)
- // 描述
def descEl = utils.selectFirst(doc, 'td.embedded font[title], #kdescr')
if (descEl) fields.description = utils.text(descEl).take(200)
return [pageName: '种子详情', fields: fields]
}
-// ── 签到 ──
-
private Map parseSign(doc) {
def t = utils.text(doc.body())
def matched = t ==~ /.*(签到成功|已签到|重复签到|获得.*魔力值).*/
return [pageName: '签到', fields: [result: t.take(200)], message: matched ? '成功' : '未知']
}
-// ==================== mediabot 运行时 ====================
-
Map sync(PluginContext ctx) {
- if (!ctx.site.auth) return [message: "未配置认证", loginRequired: true]
+ if (!ctx.site?.auth) return [message: "未配置认证", loginRequired: true]
try {
def conn = ctx.httpGet('/index.php')
def doc = jsoup.parse(conn.body())
@@ -109,7 +98,7 @@ Map sync(PluginContext ctx) {
}
Map sign(PluginContext ctx) {
- if (!ctx.site.auth) return [message: "未配置认证", loginRequired: true]
+ if (!ctx.site?.auth) return [message: "未配置认证", loginRequired: true]
try {
def conn = ctx.httpGet('/attendance.php')
def matched = conn.body() ==~ /.*(签到成功|已签到|重复签到|获得.*魔力值).*/
@@ -118,7 +107,7 @@ Map sign(PluginContext ctx) {
}
List search(PluginContext ctx, Map params) {
- if (!ctx.site.auth) return []
+ if (!ctx.site?.auth) return []
try {
def keyword = params.keyword ?: ''
def page = (params.page ?: 0) as int
@@ -142,8 +131,6 @@ List search(PluginContext ctx, Map params) {
} catch (e) { return [] }
}
-// ==================== 工具 ====================
-
private long parseTraffic(double val, String unit) {
def m = [B:1,KB:1024,MB:1048576,GB:1073741824,TB:1099511627776]
return (val * (m[unit?.toUpperCase()] ?: 1)) as long