(resObj)
| 213 | } |
| 214 | |
| 215 | async function get302URL(resObj) { |
| 216 | try { |
| 217 | let z = 1 |
| 218 | while (z <= 6) { |
| 219 | if (z >= 2) { |
| 220 | printYellow(`获取失败,正在第${z - 1}次重试`) |
| 221 | } |
| 222 | const controller = new AbortController() |
| 223 | const timeoutId = setTimeout(() => { |
| 224 | controller.abort() |
| 225 | printRed("请求超时") |
| 226 | }, 6000); |
| 227 | const obj = await fetch(`${resObj.url}`, { |
| 228 | method: "GET", |
| 229 | redirect: "manual", |
| 230 | signal: controller.signal |
| 231 | }).catch(err => { |
| 232 | clearTimeout(timeoutId); |
| 233 | console.log(err) |
| 234 | }) |
| 235 | clearTimeout(timeoutId); |
| 236 | const location = obj.headers.get("Location") |
| 237 | |
| 238 | if (location != "" && location != undefined && location != null) { |
| 239 | if (!location.startsWith("http://bofang")) { |
| 240 | return location |
| 241 | } |
| 242 | } |
| 243 | if (z != 6) { |
| 244 | await delay(150) |
| 245 | } |
| 246 | z++ |
| 247 | } |
| 248 | } catch (error) { |
| 249 | console.log(error) |
| 250 | } |
| 251 | printRed(`获取失败,返回原链接`) |
| 252 | return "" |
| 253 | } |
| 254 | |
| 255 | function printLoginInfo(resObj) { |
| 256 | if (resObj.content.body?.auth?.logined) { |
nothing calls this directly
no test coverage detected