fix: H&R只解析红色数字(未达标),用CSS选择器font.fcr/font[color=red]

This commit is contained in:
mediabot-pt
2026-07-02 00:03:11 +08:00
parent 2f0e035f6f
commit 8cb4ff53af

View File

@@ -26,7 +26,6 @@ private Map parseIndex(doc) {
def sm = t =~ /⬆\s*(\d+)/
def lm = t =~ /⬇\s*(\d+)/
def im = t =~ /邀请[::]\s*(\d+)/
def hm = t =~ /H[&&]R[::]\s*(\d+)/
if (um) fields.upload = um[0][1] + (um[0][2] ?: '')
if (dm) fields.download = dm[0][1] + (dm[0][2] ?: '')
if (rm) fields.ratio = rm[0][1]
@@ -34,7 +33,13 @@ private Map parseIndex(doc) {
if (sm) fields.seeding = sm[0][1]
if (lm) fields.leeching = lm[0][1]
if (im) fields.invites = im[0][1]
if (hm) fields.hnr = hm[0][1]
// H&R:只取红色数字(未达标数),用 CSS 选取 red 元素
def hrEl = doc.selectFirst('#info_block font[class=fcr], #info_block font[color=red], #info_block .red')
if (hrEl) {
def hrText = hrEl.text()
def hrm = hrText ==~ /(\d+)/ ? (hrText =~ /(\d+)/) : null
if (hrm) fields.hnr = hrm[0][1]
}
return [pageName: '用户信息', fields: fields, message: fields.isEmpty() ? '未提取' : '解析成功']
}
@@ -103,14 +108,18 @@ Map sync(PluginContext ctx) {
def bm = t =~ /魔力值\([^)]*\)[^0-9]*([\d.,]+)/
def sm = t =~ /⬆\s*(\d+)/
def im = t =~ /邀请[::]\s*(\d+)/
def hm = t =~ /H[&&]R[::]\s*(\d+)/
if (um) result.upload = utils.parseTraffic(um[0][1] + (um[0][2] ?: ''))
if (dm) result.download = utils.parseTraffic(dm[0][1] + (dm[0][2] ?: ''))
if (rm) result.shareRatio = rm[0][1].replace(',','') as double
if (bm) result.bonus = bm[0][1].replace(',','') as double
if (sm) result.seeding = sm[0][1] as int
if (im) result.invites = im[0][1] as int
if (hm) result.hnr = hm[0][1] as int
// H&R 红色数字(未达标数)
def hrEl = doc.selectFirst('#info_block font[class=fcr], #info_block font[color=red], #info_block .red')
if (hrEl) {
def hrm = hrEl.text() =~ /(\d+)/
if (hrm) result.hnr = hrm[0][1] as int
}
if (!result.upload || !result.download) ctx.incomplete = true
return result
} catch (e) { ctx.incomplete = true; return [message: "同步失败: ${e.message}"] }