|
@@ -43,16 +43,19 @@ namespace molilian.core
|
|
|
{
|
|
{
|
|
|
if (string.IsNullOrEmpty(url)) return string.Empty;
|
|
if (string.IsNullOrEmpty(url)) return string.Empty;
|
|
|
|
|
|
|
|
- // 定义正则表达式模式,使用捕获组提取数字ID
|
|
|
|
|
- string pattern = @"https?://item(?:\.m)?\.jd\.com/(?:product/)?(\d+)\.html(?:\?.*)?";
|
|
|
|
|
|
|
+ string[] patterns = [
|
|
|
|
|
+ @"https?://(?:i-)?item(?:\.m)?\.jd\.com/(?:product/)?(\d+)\.html(?:\?.*)?"
|
|
|
|
|
+ //@"https?:\/\/b2b\.m\.jd\.com\/goods-detail\/.*[?&]skuId=(\d+)"
|
|
|
|
|
+ ];
|
|
|
|
|
|
|
|
- // 使用正则表达式进行匹配
|
|
|
|
|
- Match match = Regex.Match(url, pattern);
|
|
|
|
|
-
|
|
|
|
|
- if (match.Success)
|
|
|
|
|
|
|
+ foreach (var pattern in patterns)
|
|
|
{
|
|
{
|
|
|
- string idNumber = match.Groups[1].Value; // 捕获组1包含数字ID
|
|
|
|
|
- return idNumber;
|
|
|
|
|
|
|
+ Match match = Regex.Match(url, pattern);
|
|
|
|
|
+ if (match.Success)
|
|
|
|
|
+ {
|
|
|
|
|
+ string idNumber = match.Groups[1].Value; // 捕获组1包含数字ID
|
|
|
|
|
+ return idNumber;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
return string.Empty;
|
|
return string.Empty;
|
|
|
}
|
|
}
|
|
@@ -128,29 +131,33 @@ namespace molilian.core
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(url)) return LinkTypeEnum.unknown;
|
|
if (string.IsNullOrEmpty(url)) return LinkTypeEnum.unknown;
|
|
|
string lowerUrl = url.ToLower();
|
|
string lowerUrl = url.ToLower();
|
|
|
|
|
+ Uri uri = new(url);
|
|
|
|
|
|
|
|
- if (lowerUrl.StartsWith("https://u.jd.com") ||
|
|
|
|
|
- lowerUrl.StartsWith("http://u.jd.com"))
|
|
|
|
|
- return LinkTypeEnum.other_aff;
|
|
|
|
|
|
|
+ if ("3.cn".Equals(uri.Host))
|
|
|
|
|
+ {
|
|
|
|
|
+ var target_url = GetDesiredUrl(url);
|
|
|
|
|
+ return GetLinkType(target_url, out desiredUrl, out itemId);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ string[] arr = ["mall.jd.com", "shop.m.jd.com", "shop.jd.com"];
|
|
|
|
|
+ if (arr.Contains(uri.Host)) return LinkTypeEnum.profile;
|
|
|
|
|
+
|
|
|
|
|
+ arr = ["lives.jd.com"];
|
|
|
|
|
+ if (arr.Contains(uri.Host)) return LinkTypeEnum.live;
|
|
|
|
|
|
|
|
- if (lowerUrl.StartsWith("https://lives.jd.com/") ||
|
|
|
|
|
- lowerUrl.StartsWith("http://lives.jd.com/"))
|
|
|
|
|
- return LinkTypeEnum.live;
|
|
|
|
|
|
|
+ arr = ["u.jd.com"];
|
|
|
|
|
+ if (arr.Contains(uri.Host)) return LinkTypeEnum.other_aff;
|
|
|
|
|
|
|
|
- if (lowerUrl.StartsWith("https://h5.m.jd.com/active/faxian/video/index.html") ||
|
|
|
|
|
- lowerUrl.StartsWith("http://h5.m.jd.com/active/faxian/video/index.html"))
|
|
|
|
|
|
|
+ arr = ["h5.m.jd.com"];
|
|
|
|
|
+ if (arr.Contains(uri.Host)) return LinkTypeEnum.video;
|
|
|
|
|
+
|
|
|
|
|
+ if (lowerUrl.Contains("h5.m.jd.com/active/faxian/video/index.html"))
|
|
|
return LinkTypeEnum.video;
|
|
return LinkTypeEnum.video;
|
|
|
|
|
|
|
|
- if (lowerUrl.StartsWith("https://eco.m.jd.com/content/dr_home/index.html") ||
|
|
|
|
|
- lowerUrl.StartsWith("http://eco.m.jd.com/content/dr_home/index.html")) return LinkTypeEnum.profile;
|
|
|
|
|
|
|
+ if (lowerUrl.Contains("eco.m.jd.com/content/dr_home/index.html"))
|
|
|
|
|
+ return LinkTypeEnum.profile;
|
|
|
|
|
|
|
|
- if (lowerUrl.StartsWith("https://3.cn") ||
|
|
|
|
|
- lowerUrl.StartsWith("http://3.cn"))
|
|
|
|
|
- {
|
|
|
|
|
- var target_url = GetDesiredUrl(url);
|
|
|
|
|
- return GetLinkType(target_url, out desiredUrl, out itemId);
|
|
|
|
|
- }
|
|
|
|
|
- if (lowerUrl.Contains("jd.com"))
|
|
|
|
|
|
|
+ if (uri.Host.Contains("jd.com"))
|
|
|
{
|
|
{
|
|
|
itemId = GetItemId(url);
|
|
itemId = GetItemId(url);
|
|
|
if (!string.IsNullOrEmpty(itemId)) return LinkTypeEnum.goods;
|
|
if (!string.IsNullOrEmpty(itemId)) return LinkTypeEnum.goods;
|
|
@@ -241,38 +248,64 @@ namespace molilian.core
|
|
|
url = out_url;
|
|
url = out_url;
|
|
|
result.itemId = itemId;
|
|
result.itemId = itemId;
|
|
|
|
|
|
|
|
- if (result.link_type == LinkTypeEnum.other_aff)
|
|
|
|
|
- {
|
|
|
|
|
- result.success = false;
|
|
|
|
|
- result.link_type = LinkTypeEnum.unknown;
|
|
|
|
|
- result.channel_type = ChannelTypeEnum.jd;
|
|
|
|
|
- result.message = "放弃转链";
|
|
|
|
|
- result.reason = "其他推广链接";
|
|
|
|
|
- result.accountId = 0;
|
|
|
|
|
- result.accountName = string.Empty;
|
|
|
|
|
- result.content = content;
|
|
|
|
|
- result.shortLinkurl = url;
|
|
|
|
|
- result.deeplink_url = GetDeeplink(url);
|
|
|
|
|
- return result;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (string.IsNullOrEmpty(url) || string.IsNullOrEmpty(result.itemId) ||
|
|
|
|
|
- (!url.StartsWith("https://item.jd.com/") &&
|
|
|
|
|
- !url.StartsWith("https://item.m.jd.com/product/") &&
|
|
|
|
|
- !url.StartsWith("http://item.m.jd.com/product/") &&
|
|
|
|
|
- !url.StartsWith("http://item.m.jd.com/product/")))
|
|
|
|
|
|
|
+ switch (result.link_type)
|
|
|
{
|
|
{
|
|
|
- result.success = false;
|
|
|
|
|
- result.link_type = LinkTypeEnum.unknown;
|
|
|
|
|
- result.channel_type = ChannelTypeEnum.jd;
|
|
|
|
|
- result.message = "放弃转链";
|
|
|
|
|
- result.reason = "非标链接";
|
|
|
|
|
- result.accountId = 0;
|
|
|
|
|
- result.accountName = string.Empty;
|
|
|
|
|
- result.content = content;
|
|
|
|
|
- result.shortLinkurl = url;
|
|
|
|
|
- result.deeplink_url = GetDeeplink(url);
|
|
|
|
|
- return result;
|
|
|
|
|
|
|
+ case LinkTypeEnum.profile:
|
|
|
|
|
+ case LinkTypeEnum.live:
|
|
|
|
|
+ case LinkTypeEnum.video:
|
|
|
|
|
+
|
|
|
|
|
+ result.success = false;
|
|
|
|
|
+ result.channel_type = ChannelTypeEnum.jd;
|
|
|
|
|
+ result.message = "放弃转链";
|
|
|
|
|
+ result.reason = result.link_type switch
|
|
|
|
|
+ {
|
|
|
|
|
+ LinkTypeEnum.profile => "店铺",
|
|
|
|
|
+ LinkTypeEnum.live => "直播",
|
|
|
|
|
+ LinkTypeEnum.video => "视频",
|
|
|
|
|
+ _ => "非标链接",
|
|
|
|
|
+ };
|
|
|
|
|
+ result.accountId = 0;
|
|
|
|
|
+ result.accountName = string.Empty;
|
|
|
|
|
+ result.content = content;
|
|
|
|
|
+ result.shortLinkurl = url;
|
|
|
|
|
+ result.deeplink_url = GetDeeplink(url);
|
|
|
|
|
+ return result;
|
|
|
|
|
+ case LinkTypeEnum.other_aff:
|
|
|
|
|
+ result.success = false;
|
|
|
|
|
+ result.link_type = LinkTypeEnum.unknown;
|
|
|
|
|
+ result.channel_type = ChannelTypeEnum.jd;
|
|
|
|
|
+ result.message = "放弃转链";
|
|
|
|
|
+ result.reason = "其他推广链接";
|
|
|
|
|
+ result.accountId = 0;
|
|
|
|
|
+ result.accountName = string.Empty;
|
|
|
|
|
+ result.content = content;
|
|
|
|
|
+ result.shortLinkurl = url;
|
|
|
|
|
+ result.deeplink_url = GetDeeplink(url);
|
|
|
|
|
+ return result;
|
|
|
|
|
+ default:
|
|
|
|
|
+ if (string.IsNullOrEmpty(url) || string.IsNullOrEmpty(result.itemId) ||
|
|
|
|
|
+ (!url.StartsWith("https://item.jd.com/") &&
|
|
|
|
|
+ !url.StartsWith("https://item.m.jd.com/product/") &&
|
|
|
|
|
+ !url.StartsWith("http://item.m.jd.com/product/") &&
|
|
|
|
|
+ !url.StartsWith("http://item.m.jd.com/product/")))
|
|
|
|
|
+ {
|
|
|
|
|
+ result.success = false;
|
|
|
|
|
+ result.link_type = LinkTypeEnum.unknown;
|
|
|
|
|
+ result.channel_type = ChannelTypeEnum.jd;
|
|
|
|
|
+ result.message = "放弃转链";
|
|
|
|
|
+ result.reason = "非标链接";
|
|
|
|
|
+ result.accountId = 0;
|
|
|
|
|
+ result.accountName = string.Empty;
|
|
|
|
|
+ result.content = content;
|
|
|
|
|
+ result.shortLinkurl = url;
|
|
|
|
|
+ result.deeplink_url = result.link_type switch
|
|
|
|
|
+ {
|
|
|
|
|
+ LinkTypeEnum.other_aff or LinkTypeEnum.goods => JdUnionPlus.GetDeeplink(result.shortLinkurl),
|
|
|
|
|
+ _ => JdUnionPlus.GetDeeplink(string.Empty),
|
|
|
|
|
+ };
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (!result.ip.StartsWith("127.0.0") && FlowControlIgnoreRequest(_config, out string reason))
|
|
if (!result.ip.StartsWith("127.0.0") && FlowControlIgnoreRequest(_config, out string reason))
|
|
@@ -286,7 +319,11 @@ namespace molilian.core
|
|
|
result.accountName = string.Empty;
|
|
result.accountName = string.Empty;
|
|
|
result.content = content;
|
|
result.content = content;
|
|
|
result.shortLinkurl = url;
|
|
result.shortLinkurl = url;
|
|
|
- result.deeplink_url = GetDeeplink(url);
|
|
|
|
|
|
|
+ result.deeplink_url = result.link_type switch
|
|
|
|
|
+ {
|
|
|
|
|
+ LinkTypeEnum.other_aff or LinkTypeEnum.goods => JdUnionPlus.GetDeeplink(result.shortLinkurl),
|
|
|
|
|
+ _ => JdUnionPlus.GetDeeplink(string.Empty),
|
|
|
|
|
+ };
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|