fix: parseUserInfo支持PTTIME格式(td.bottom.clearfix+⬆⬇做种数)
This commit is contained in:
@@ -16,17 +16,23 @@ Map parse(String content, String url) {
|
||||
|
||||
private Map parseUserInfo(doc) {
|
||||
def fields = [:]
|
||||
def el = utils.selectFirst(doc, '#info_block')
|
||||
def el = utils.selectFirst(doc, '#info_block, td.bottom.clearfix, .userbar')
|
||||
if (el) {
|
||||
def t = utils.text(el)
|
||||
def um = t =~ /上传[::]\s*([0-9.]+)\s*(TB|GB|MB|KB|B)?/
|
||||
def dm = t =~ /下载[::]\s*([0-9.]+)\s*(TB|GB|MB|KB|B)?/
|
||||
def rm = t =~ /分享率[::]\s*([\d.]+)/
|
||||
def bm = t =~ /魔力[值::]*\s*([\d,]+)/
|
||||
// 通用正则提取
|
||||
def um = t =~ /上传[::]\s*([0-9.,]+)\s*(TB|GB|MB|KB|B)?/
|
||||
def dm = t =~ /下载[::]\s*([0-9.,]+)\s*(TB|GB|MB|KB|B)?/
|
||||
def rm = t =~ /分享率[::]\s*([\d.,]+)/
|
||||
def bm = t =~ /魔力[值::]*[^0-9]*([\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]
|
||||
if (bm) fields.bonus = bm[0][1]
|
||||
// PTTIME 特殊:做种/下载计数
|
||||
def sm = t =~ /⬆\s*(\d+)/
|
||||
def lm = t =~ /⬇\s*(\d+)/
|
||||
if (sm) fields.seeding = sm[0][1]
|
||||
if (lm) fields.leeching = lm[0][1]
|
||||
}
|
||||
return [pageName: '用户信息', fields: fields]
|
||||
}
|
||||
@@ -84,18 +90,21 @@ Map sync(PluginContext ctx) {
|
||||
try {
|
||||
def conn = ctx.httpGet('/index.php')
|
||||
def doc = jsoup.parse(conn.body())
|
||||
def el = utils.selectFirst(doc, '#info_block')
|
||||
def el = utils.selectFirst(doc, '#info_block, td.bottom.clearfix, .userbar')
|
||||
if (!el) return [message: "未找到用户信息"]
|
||||
def t = utils.text(el)
|
||||
def result = [:]
|
||||
def um = t =~ /上传[::]\s*([0-9.]+)\s*(TB|GB|MB|KB|B)?/
|
||||
def dm = t =~ /下载[::]\s*([0-9.]+)\s*(TB|GB|MB|KB|B)?/
|
||||
def rm = t =~ /分享率[::]\s*([\d.]+)/
|
||||
def bm = t =~ /魔力[值::]*\s*([\d,]+)/
|
||||
if (um) result.upload = parseTraffic(um[0][1] as double, um[0][2])
|
||||
if (dm) result.download = parseTraffic(dm[0][1] as double, dm[0][2])
|
||||
if (rm) result.shareRate = rm[0][1] as double
|
||||
def um = t =~ /上传[::]\s*([0-9.,]+)\s*(TB|GB|MB|KB|B)?/
|
||||
def dm = t =~ /下载[::]\s*([0-9.,]+)\s*(TB|GB|MB|KB|B)?/
|
||||
def rm = t =~ /分享率[::]\s*([\d.,]+)/
|
||||
def bm = t =~ /魔力[值::]*[^0-9]*([\d.,]+)/
|
||||
if (um) result.upload = parseTraffic(um[0][1].replace(',','') as double, um[0][2])
|
||||
if (dm) result.download = parseTraffic(dm[0][1].replace(',','') as double, dm[0][2])
|
||||
if (rm) result.shareRate = rm[0][1].replace(',','') as double
|
||||
if (bm) result.bonus = bm[0][1].replace(',','') as double
|
||||
// 做种数
|
||||
def sm = t =~ /⬆\s*(\d+)/
|
||||
if (sm) result.seeding = sm[0][1] as int
|
||||
return result
|
||||
} catch (e) { return [message: "同步失败: ${e.message}"] }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user