|
|
@@ -118,14 +118,18 @@ public class CommonMailServiceImpl implements CommonMailService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //Netflix get verify code
|
|
|
- if (Constant.NETFLIX_GID.equals(goodsId) && linkType == null && (type == null || type == 1) && StrUtil.isNotBlank(emailPwd)) {
|
|
|
+ //Netflix get verify code or household device link
|
|
|
+ if (Constant.NETFLIX_GID.equals(goodsId) && StrUtil.isNotBlank(emailPwd)
|
|
|
+ && ((linkType == null && (type == null || type == 1))
|
|
|
+ || (linkType == 1 && Boolean.TRUE.equals(isReturnDeviceUrl)))) {
|
|
|
try {
|
|
|
String url = "https://ms.lqqq.cc/web/" + account + "----" + emailPwd;
|
|
|
HttpRequest post = HttpUtil.createGet(url).timeout(Constant.CONNECT_MILLISECONDS);
|
|
|
HttpResponse execute = post.execute();
|
|
|
String body = execute.body();
|
|
|
- String code = getNetflixVerifyCodeByLqqqMail(account, emailPwd, body);
|
|
|
+ String code = linkType != null && linkType == 1
|
|
|
+ ? getNetflixHouseholdDeviceUrlByLqqqMail(account, body)
|
|
|
+ : getNetflixVerifyCodeByLqqqMail(account, body);
|
|
|
if (StrUtil.isNotBlank(code)) {
|
|
|
return code;
|
|
|
}
|
|
|
@@ -137,17 +141,17 @@ public class CommonMailServiceImpl implements CommonMailService {
|
|
|
String checkEmail = StrUtil.isNotEmpty(relateEmail) ? relateEmail : account;
|
|
|
//关联邮箱
|
|
|
if (cuiQiuMailService.isCuiQiuEmail(checkEmail)) {
|
|
|
- return cuiQiuMailService.getVerifyCode(account, relateEmail, goodsId, type, linkType, false);
|
|
|
+ return cuiQiuMailService.getVerifyCode(account, relateEmail, goodsId, type, linkType, Boolean.TRUE.equals(isReturnDeviceUrl));
|
|
|
}
|
|
|
//是否是 mail lu邮箱
|
|
|
if (mailLuService.isMailLuEmail(checkEmail)) {
|
|
|
- return mailLuService.getVerifyCode(account, relateEmail, goodsId, type, linkType, false);
|
|
|
+ return mailLuService.getVerifyCode(account, relateEmail, goodsId, type, linkType, Boolean.TRUE.equals(isReturnDeviceUrl));
|
|
|
}
|
|
|
//银河域名邮件
|
|
|
- return yhMailService.getVerifyCode(account, relateEmail, goodsId, type, linkType, false);
|
|
|
+ return yhMailService.getVerifyCode(account, relateEmail, goodsId, type, linkType, Boolean.TRUE.equals(isReturnDeviceUrl));
|
|
|
}
|
|
|
|
|
|
- private String getNetflixVerifyCodeByLqqqMail(String account, String emailPwd, String body) {
|
|
|
+ private String getNetflixVerifyCodeByLqqqMail(String account, String body) {
|
|
|
if (StrUtil.isBlank(body)) {
|
|
|
return StrUtil.EMPTY;
|
|
|
}
|
|
|
@@ -181,6 +185,66 @@ public class CommonMailServiceImpl implements CommonMailService {
|
|
|
return StrUtil.EMPTY;
|
|
|
}
|
|
|
|
|
|
+ private String getNetflixHouseholdDeviceUrlByLqqqMail(String account, String body) {
|
|
|
+ if (StrUtil.isBlank(body)) {
|
|
|
+ return StrUtil.EMPTY;
|
|
|
+ }
|
|
|
+ String url = getNetflixHouseholdDeviceUrl(body);
|
|
|
+ if (StrUtil.isNotBlank(url)) {
|
|
|
+ return url;
|
|
|
+ }
|
|
|
+ Matcher matcher = Pattern.compile("<a\\b[^>]*href=\"([^\"]*/show_email/[^\"]+)\"[^>]*>", Pattern.CASE_INSENSITIVE).matcher(body);
|
|
|
+ while (matcher.find()) {
|
|
|
+ String emailItem = getMailListItemHtml(body, matcher.start());
|
|
|
+ if (!isNetflixHouseholdDeviceMail(emailItem)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ String href = decodeHtmlUrl(matcher.group(1));
|
|
|
+ String detailUrl = href.startsWith("http") ? href : "https://ms.lqqq.cc" + href;
|
|
|
+ HttpResponse detailResp = HttpUtil.createGet(detailUrl).timeout(Constant.CONNECT_MILLISECONDS).execute();
|
|
|
+ url = getNetflixHouseholdDeviceUrl(detailResp.body());
|
|
|
+ if (StrUtil.isNotBlank(url)) {
|
|
|
+ log.info("Netflix {} get household device url from lqqq mail detail", account);
|
|
|
+ return url;
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("Netflix {} read household device mail failed: {}", account, StringUtil.getErrorMsg(e));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return StrUtil.EMPTY;
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean isNetflixHouseholdDeviceMail(String body) {
|
|
|
+ if (StrUtil.isBlank(body) || !body.toLowerCase().contains("netflix")) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ String text = cleanMailHtml(body).toLowerCase();
|
|
|
+ return text.contains("update netflix household")
|
|
|
+ || text.contains("netflix household device")
|
|
|
+ || text.contains("update-primary-location")
|
|
|
+ || text.contains("\u66f4\u65b0 netflix \u540c\u6237\u8bbe\u5907")
|
|
|
+ || text.contains("\u66f4\u65b0 netflix \u540c\u6236\u88dd\u7f6e");
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getNetflixHouseholdDeviceUrl(String body) {
|
|
|
+ if (StrUtil.isBlank(body)) {
|
|
|
+ return StrUtil.EMPTY;
|
|
|
+ }
|
|
|
+ Matcher matcher = Pattern.compile("https://www\\.netflix\\.com/account/update-primary-location[^\\s\\\"'<>]*", Pattern.CASE_INSENSITIVE).matcher(body);
|
|
|
+ if (matcher.find()) {
|
|
|
+ return decodeHtmlUrl(matcher.group());
|
|
|
+ }
|
|
|
+ return StrUtil.EMPTY;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String decodeHtmlUrl(String url) {
|
|
|
+ return StrUtil.blankToDefault(url, StrUtil.EMPTY)
|
|
|
+ .replace("&", "&")
|
|
|
+ .replace("&", "&")
|
|
|
+ .replace("&", "&");
|
|
|
+ }
|
|
|
+
|
|
|
private String getMailListItemHtml(String body, int hrefStart) {
|
|
|
int cardStart = body.lastIndexOf("<article", hrefStart);
|
|
|
if (cardStart < 0) {
|