|
|
@@ -110,6 +110,8 @@ public class SpotifyServiceImpl implements SpotifyService {
|
|
|
jsonObject.put("email",registerOrderDon.getEmail());
|
|
|
jsonObject.put("iagree","1");
|
|
|
request.setMethod(Method.POST);
|
|
|
+ request.setConnectionTimeout(30 * 1000);
|
|
|
+ request.setReadTimeout(30 * 1000);
|
|
|
|
|
|
request.form(jsonObject);
|
|
|
|
|
|
@@ -117,60 +119,71 @@ public class SpotifyServiceImpl implements SpotifyService {
|
|
|
log.info(proxyJson);
|
|
|
JSONArray array = JSONUtil.parseObj(proxyJson).getJSONArray("proxies");
|
|
|
List<ProxyInfo> proxyInfos = array.toList(ProxyInfo.class);
|
|
|
- log.info("{}",proxyInfos);
|
|
|
+ log.info("{}", proxyInfos);
|
|
|
|
|
|
int start = 1;
|
|
|
int limit = 20;
|
|
|
boolean regFlag = false;
|
|
|
- while (true){
|
|
|
+ while (true) {
|
|
|
for (ProxyInfo proxyInfo : proxyInfos) {
|
|
|
try {
|
|
|
- log.info("执行:info:{}",proxyInfo);
|
|
|
+ log.info("执行:info:{}", proxyInfo);
|
|
|
Proxy proxy = new Proxy(Proxy.Type.HTTP,
|
|
|
new InetSocketAddress(proxyInfo.getIp(), proxyInfo.getPort()));
|
|
|
request.setProxy(proxy);
|
|
|
HttpResponse response = request.execute();
|
|
|
String body = response.body();
|
|
|
- log.info("spotify 返回body:{}",body);
|
|
|
+ log.info("spotify 返回body:{}", body);
|
|
|
JSONObject resObj = JSONUtil.parseObj(body);
|
|
|
JSONObject errors = resObj.getJSONObject("errors");
|
|
|
- String errorMsg = errors.getStr("generic_error");
|
|
|
- if (!errors.isEmpty()) {
|
|
|
- if ("你似乎正在使用代理服务。请关闭此类服务,然后再试一次。如需更多帮助,请联系客服服务。".equals(errorMsg)) {
|
|
|
- log.info("spotify 注册 被监测出代理服务 。 删除该代理 ip:{}",proxyInfo.getIp());
|
|
|
- if(proxyInfo.getId() != null){
|
|
|
+
|
|
|
+ Integer status = resObj.getInt("status");
|
|
|
+ if (status == 320) {
|
|
|
+ String errorMsg = errors.getStr("generic_error");
|
|
|
+ if (StringUtils.isNotBlank(errorMsg) || "你似乎正在使用代理服务。请关闭此类服务,然后再试一次。如需更多帮助,请联系客户服务。".equals(errorMsg) || errorMsg.contains("代理")) {
|
|
|
+ log.info("spotify 注册 被监测出代理服务 。 删除该代理 ip:{}", proxyInfo.getIp());
|
|
|
+ if (proxyInfo.getId() != null) {
|
|
|
proxysMapper.deleteById(proxyInfo.getId());
|
|
|
}
|
|
|
continue;
|
|
|
- }else {
|
|
|
- registerOrderDon.setErrorMsg(errorMsg);
|
|
|
- registerOrderDon.setStatus(RegisterOrderDon.Status.error);
|
|
|
- registerOrderDonMapper.updateById(registerOrderDon);
|
|
|
- break;
|
|
|
}
|
|
|
}
|
|
|
- if(StringUtils.isNotBlank(resObj.getStr("login_token"))){
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(resObj.getStr("login_token"))) {
|
|
|
log.info("注册成功!");
|
|
|
registerOrderDon.setStatus(RegisterOrderDon.Status.complete);
|
|
|
registerOrderDonMapper.updateById(registerOrderDon);
|
|
|
regFlag = true;
|
|
|
break;
|
|
|
+ } else {
|
|
|
+ if (errors != null && !errors.isEmpty()) {
|
|
|
+ StringBuilder error = new StringBuilder();
|
|
|
+ for (String str : errors.keySet()) {
|
|
|
+ error.append(errors.getStr(str));
|
|
|
+ }
|
|
|
+ registerOrderDon.setErrorMsg(error.toString());
|
|
|
+ registerOrderDon.setStatus(RegisterOrderDon.Status.error);
|
|
|
+ registerOrderDonMapper.updateById(registerOrderDon);
|
|
|
+ regFlag = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
- }catch (Exception e){
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- log.error("错误 ip:{}",proxyInfo.getIp());
|
|
|
+ log.error("错误 ip:{}", proxyInfo.getIp());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(regFlag){
|
|
|
+ if (regFlag) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
List<Proxys> records = proxysMapper.selectPage(new Page<>(start, limit), Wrappers.lambdaQuery(Proxys.class).orderByDesc(Proxys::getId)).getRecords();
|
|
|
- if(records.isEmpty()){
|
|
|
+ if (records.isEmpty()) {
|
|
|
break;
|
|
|
}
|
|
|
- proxyInfos = records.stream().map((proxy)->{
|
|
|
+ proxyInfos = records.stream().map((proxy) -> {
|
|
|
ProxyInfo proxyInfo = new ProxyInfo();
|
|
|
proxyInfo.setIp(proxy.getIp());
|
|
|
proxyInfo.setPort(proxy.getPort());
|