fix: 所有返回都加matched字段
This commit is contained in:
@@ -7,10 +7,10 @@
|
|||||||
Map parse(context) {
|
Map parse(context) {
|
||||||
if (context.status != 200) {
|
if (context.status != 200) {
|
||||||
return switch(context.status) {
|
return switch(context.status) {
|
||||||
case 302 -> [redirect: context.headers?.Location ?: '']
|
case 302 -> [matched: false, redirect: context.headers?.Location ?: '']
|
||||||
case 403 -> [banned: true, message: 'IP被禁']
|
case 403 -> [matched: false, banned: true, message: 'IP被禁']
|
||||||
case 429 -> [rateLimited: true]
|
case 429 -> [matched: false, rateLimited: true]
|
||||||
default -> [error: true, status: context.status, message: "HTTP ${context.status}"]
|
default -> [matched: false, error: true, status: context.status, message: "HTTP ${context.status}"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return switch(context.pageKey) {
|
return switch(context.pageKey) {
|
||||||
@@ -71,7 +71,7 @@ private Map parseSearchPage(doc) {
|
|||||||
publishDate: time,
|
publishDate: time,
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
return [pageName: '搜索', items: items]
|
return [pageName: '搜索', matched: !items.isEmpty(), items: items]
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== 种子详情 ====================
|
// ==================== 种子详情 ====================
|
||||||
@@ -98,7 +98,7 @@ private Map parseDetailPage(doc) {
|
|||||||
private Map parseSignPage(doc) {
|
private Map parseSignPage(doc) {
|
||||||
def t = doc.body().text()
|
def t = doc.body().text()
|
||||||
def matched = t ==~ /.*(签到成功|已签到|重复签到|今日已签|已经签到|获得.*).*/
|
def matched = t ==~ /.*(签到成功|已签到|重复签到|今日已签|已经签到|获得.*).*/
|
||||||
return [pageName: '签到', sign: true, message: matched ? '成功' : '结果未匹配']
|
return [pageName: '签到', matched: matched, sign: true, message: matched ? '成功' : '结果未匹配']
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== 下载 ====================
|
// ==================== 下载 ====================
|
||||||
@@ -106,12 +106,12 @@ private Map parseSignPage(doc) {
|
|||||||
private Map parseDownload(context) {
|
private Map parseDownload(context) {
|
||||||
// 下载页通常是重定向到种子文件
|
// 下载页通常是重定向到种子文件
|
||||||
if (context.status == 302 || context.status == 301) {
|
if (context.status == 302 || context.status == 301) {
|
||||||
return [pageName: '下载', redirect: context.headers?.Location ?: '']
|
return [pageName: '下载', matched: false, redirect: context.headers?.Location ?: '']
|
||||||
}
|
}
|
||||||
if (context.headers?.'Content-Type'?.contains('octet-stream')) {
|
if (context.headers?.'Content-Type'?.contains('octet-stream')) {
|
||||||
return [pageName: '下载', downloaded: true, size: context.content.length()]
|
return [pageName: '下载', matched: true, downloaded: true, size: context.content.length()]
|
||||||
}
|
}
|
||||||
return [pageName: '下载', error: true, status: context.status, message: "非种子文件 response"]
|
return [pageName: '下载', matched: false, error: true, status: context.status, message: "非种子文件 response"]
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== 工具方法 ====================
|
// ==================== 工具方法 ====================
|
||||||
|
|||||||
Reference in New Issue
Block a user