|
|
|
@ -191,6 +191,7 @@ class AnalyzeUrl( |
|
|
|
|
?.let { headerMap.putAll(it) } |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
headerMap[UA_NAME] = headerMap[UA_NAME] ?: userAgent |
|
|
|
|
charset = option.charset |
|
|
|
|
body = if (option.body is String) { |
|
|
|
|
option.body |
|
|
|
@ -348,23 +349,10 @@ class AnalyzeUrl( |
|
|
|
|
|
|
|
|
|
@Throws(Exception::class) |
|
|
|
|
fun getImageBytes(tag: String): ByteArray? { |
|
|
|
|
//资源为本站的资源,保留cookie |
|
|
|
|
//图片盗链的不保留当前的cookie,可由js生成图片源站的cookie |
|
|
|
|
val cookie = CookieStore.getCookie(tag) |
|
|
|
|
NetworkUtils.getBaseUrl(url)?.let { |
|
|
|
|
val regex: Any |
|
|
|
|
regex = if (it.lastIndexOf(".") != it.indexOf(".")) { |
|
|
|
|
it.substring(it.indexOf(".") + 1).toRegex() |
|
|
|
|
} else { |
|
|
|
|
it.substring(it.lastIndexOf("/") + 1).toRegex() |
|
|
|
|
} |
|
|
|
|
if (regex.containsMatchIn(tag)) { |
|
|
|
|
if (cookie.isNotEmpty()) { |
|
|
|
|
headerMap["Cookie"] += cookie |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (cookie.isNotEmpty()) { |
|
|
|
|
headerMap["Cookie"] += cookie |
|
|
|
|
} |
|
|
|
|
headerMap[UA_NAME] = headerMap[UA_NAME] ?: userAgent |
|
|
|
|
return if (fieldMap.isEmpty()) { |
|
|
|
|
HttpHelper.getBytes(url, mapOf(), headerMap) |
|
|
|
|
} else { |
|
|
|
|