|
|
@@ -49,7 +49,9 @@ namespace molilian.core
|
|
|
UnionParse(content, ref result);
|
|
|
}
|
|
|
|
|
|
- public async Task<TkDataDTO> UnionParse2Async(string content, TkDataDTO result, CancellationToken cancellationToken = default, Dictionary<string, long> swData = null)
|
|
|
+ public async Task<TkDataDTO> UnionParse2Async(string content, TkDataDTO result,
|
|
|
+ CancellationToken cancellationToken = default,
|
|
|
+ Dictionary<string, long> swData = null)
|
|
|
{
|
|
|
if ("veapi".Equals(_api) && _api_id > 0)
|
|
|
{
|
|
|
@@ -81,7 +83,7 @@ namespace molilian.core
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 是否淘宝链接
|
|
|
+ /// 是否淘宝链接,如果是商品链接就格式化成https://item.taobao.com/item.htm?id=****
|
|
|
/// </summary>
|
|
|
/// <param name="url"></param>
|
|
|
/// <returns></returns>
|
|
|
@@ -399,41 +401,20 @@ namespace molilian.core
|
|
|
result.link_type = LinkTypeEnum.other_aff;
|
|
|
result.shortLinkurl = null;
|
|
|
}
|
|
|
+
|
|
|
private async Task<TkDataDTO> InternalTextProcessingAsync(string content, TkDataDTO result,
|
|
|
CancellationToken cancellationToken,
|
|
|
Dictionary<string, long> swData = null)
|
|
|
{
|
|
|
- Stopwatch stopwatch = Stopwatch.StartNew();
|
|
|
-
|
|
|
bool success;
|
|
|
string resultText;
|
|
|
LinkTypeEnum link_type = LinkTypeEnum.unknown;
|
|
|
|
|
|
-
|
|
|
- if (swData != null)
|
|
|
- {
|
|
|
- stopwatch.Reset();
|
|
|
- stopwatch.Start();
|
|
|
- }
|
|
|
+ //============================== 放弃转链-其他推广链接 ==============================
|
|
|
string url = GetLink(content);
|
|
|
- if (swData != null)
|
|
|
- {
|
|
|
- stopwatch.Stop();
|
|
|
- swData.Add("\tGetLink", stopwatch.ElapsedMilliseconds);
|
|
|
- }
|
|
|
if (!string.IsNullOrEmpty(url))
|
|
|
{
|
|
|
- if (swData != null)
|
|
|
- {
|
|
|
- stopwatch.Reset();
|
|
|
- stopwatch.Start();
|
|
|
- }
|
|
|
bool is_aff = IsAffLink(url);
|
|
|
- if (swData != null)
|
|
|
- {
|
|
|
- stopwatch.Stop();
|
|
|
- swData.Add("\t\tGetLink", stopwatch.ElapsedMilliseconds);
|
|
|
- }
|
|
|
if (is_aff)
|
|
|
{
|
|
|
result.success = false;
|
|
|
@@ -442,22 +423,9 @@ namespace molilian.core
|
|
|
result.link_type = LinkTypeEnum.other_aff;
|
|
|
result.shortLinkurl = url;
|
|
|
return result;
|
|
|
- //return (false, "排除淘客链接", LinkTypeEnum.other_aff, url);
|
|
|
}
|
|
|
|
|
|
- //直接提取
|
|
|
-
|
|
|
- if (swData != null)
|
|
|
- {
|
|
|
- stopwatch.Reset();
|
|
|
- stopwatch.Start();
|
|
|
- }
|
|
|
(success, resultText) = IsTaobaoUrl(url);
|
|
|
- if (swData != null)
|
|
|
- {
|
|
|
- stopwatch.Stop();
|
|
|
- swData.Add("\tIsTaobaoUrl", stopwatch.ElapsedMilliseconds);
|
|
|
- }
|
|
|
if (success)
|
|
|
{
|
|
|
result.success = true;
|
|
|
@@ -465,7 +433,6 @@ namespace molilian.core
|
|
|
result.link_type = LinkTypeEnum.goods;
|
|
|
result.shortLinkurl = resultText;
|
|
|
return result;
|
|
|
- //return (true, result, LinkTypeEnum.goods, result);
|
|
|
}
|
|
|
|
|
|
Stopwatch sw = Stopwatch.StartNew();
|
|
|
@@ -473,39 +440,23 @@ namespace molilian.core
|
|
|
sw.Stop();
|
|
|
// 获取执行时间
|
|
|
result.elapsedTime2 = (int)sw.ElapsedMilliseconds;
|
|
|
- if (swData != null)
|
|
|
- {
|
|
|
- swData.Add("\tGetDesiredUrlAsync", sw.ElapsedMilliseconds);
|
|
|
- }
|
|
|
-
|
|
|
+ swData?.Add("\tGetDesiredUrlAsync", sw.ElapsedMilliseconds);
|
|
|
|
|
|
+ //============================== 放弃转链-请求超时 ==============================
|
|
|
if (result.elapsedTime2 >= _config.rt_max || (!success && resultText.Contains("was canceled")))
|
|
|
{
|
|
|
result.success = false;
|
|
|
result.message = "放弃转链";
|
|
|
result.reason = "请求超时";
|
|
|
- result.itemName = "点击打开淘宝APP";
|
|
|
return result;
|
|
|
- //cancellationToken.ThrowIfCancellationRequested();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
if (success)
|
|
|
{
|
|
|
- //排除已知的淘客链接
|
|
|
-
|
|
|
- if (swData != null)
|
|
|
- {
|
|
|
- stopwatch.Reset();
|
|
|
- stopwatch.Start();
|
|
|
- }
|
|
|
- bool is_aff2 = IsAffLink(resultText);
|
|
|
- if (swData != null)
|
|
|
- {
|
|
|
- stopwatch.Stop();
|
|
|
- swData.Add("\t\tIsAffLink", stopwatch.ElapsedMilliseconds);
|
|
|
- }
|
|
|
+ string desiredUrl = resultText;
|
|
|
|
|
|
+ //============================== 放弃转链-其他推广链接 ==============================
|
|
|
+ bool is_aff2 = IsAffLink(desiredUrl);
|
|
|
if (is_aff2)
|
|
|
{
|
|
|
result.success = false;
|
|
|
@@ -514,64 +465,39 @@ namespace molilian.core
|
|
|
result.link_type = LinkTypeEnum.other_aff;
|
|
|
result.shortLinkurl = url;
|
|
|
return result;
|
|
|
- //return (false, "排除淘客链接", LinkTypeEnum.other_aff, url);
|
|
|
}
|
|
|
|
|
|
- if (swData != null)
|
|
|
- {
|
|
|
- stopwatch.Reset();
|
|
|
- stopwatch.Start();
|
|
|
- }
|
|
|
- (success, resultText) = IsTaobaoUrl(resultText);
|
|
|
- if (swData != null)
|
|
|
- {
|
|
|
- stopwatch.Stop();
|
|
|
- swData.Add("\t\tIsTaobaoUrl", stopwatch.ElapsedMilliseconds);
|
|
|
- }
|
|
|
+ (success, desiredUrl) = IsTaobaoUrl(desiredUrl);
|
|
|
if (success)
|
|
|
{
|
|
|
result.success = true;
|
|
|
- result.content = resultText;
|
|
|
+ result.content = desiredUrl;
|
|
|
result.link_type = LinkTypeEnum.goods;
|
|
|
- result.shortLinkurl = resultText;
|
|
|
+ result.shortLinkurl = desiredUrl;
|
|
|
return result;
|
|
|
- //return (true, resultText, LinkTypeEnum.goods, resultText);
|
|
|
}
|
|
|
- link_type = GetLinkType(resultText);
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- link_type = GetLinkType(url);
|
|
|
|
|
|
- }
|
|
|
+ link_type = GetLinkType(url);
|
|
|
|
|
|
result.success = false;
|
|
|
- result.message= "非标准链接";
|
|
|
+ result.message = "放弃转链";
|
|
|
+ result.reason = "非标准链接";
|
|
|
result.content = resultText;
|
|
|
result.link_type = link_type;
|
|
|
result.shortLinkurl = url;
|
|
|
-
|
|
|
return result;
|
|
|
//return (false, result, link_type, url);
|
|
|
}
|
|
|
|
|
|
|
|
|
- if (swData != null)
|
|
|
- {
|
|
|
- stopwatch.Reset();
|
|
|
- stopwatch.Start();
|
|
|
- }
|
|
|
- bool is_aff3 = ContainsSpecialFormat(content);
|
|
|
- if (swData != null)
|
|
|
- {
|
|
|
- stopwatch.Stop();
|
|
|
- swData.Add("\tContainsSpecialFormat", stopwatch.ElapsedMilliseconds);
|
|
|
- }
|
|
|
//判断淘客的¥羊角符号
|
|
|
+ bool is_aff3 = ContainsSpecialFormat(content);
|
|
|
if (is_aff3)
|
|
|
{
|
|
|
result.success = false;
|
|
|
- result.content = "排除淘口令";
|
|
|
+ result.message = "放弃转链";
|
|
|
+ result.reason = "排除淘口令";
|
|
|
result.link_type = LinkTypeEnum.other_aff;
|
|
|
result.shortLinkurl = null;
|
|
|
return result;
|
|
|
@@ -581,7 +507,8 @@ namespace molilian.core
|
|
|
//todo 临时应急 0614
|
|
|
//return (false, "纯口令 没链接", link_type, null);
|
|
|
result.success = false;
|
|
|
- result.content = "纯口令 没链接";
|
|
|
+ result.message = "放弃转链";
|
|
|
+ result.reason = "纯口令 没链接";
|
|
|
result.link_type = LinkTypeEnum.other_aff;
|
|
|
result.shortLinkurl = null;
|
|
|
return result;
|
|
|
@@ -697,8 +624,6 @@ namespace molilian.core
|
|
|
if (!response.Successed)
|
|
|
{
|
|
|
result.channel = TkChannelEnum.tb;
|
|
|
- result.accountId = _accountId;
|
|
|
- result.accountName = _accountName;
|
|
|
result.link_type = LinkTypeEnum.unknown;
|
|
|
result.success = false;
|
|
|
result.message = "fail";
|
|
|
@@ -815,8 +740,6 @@ namespace molilian.core
|
|
|
string deeplink_url = GetDeeplink(shortLinkurl);
|
|
|
|
|
|
result.channel = TkChannelEnum.tb;
|
|
|
- result.accountId = _accountId;
|
|
|
- result.accountName = _accountName;
|
|
|
result.link_type = success ? LinkTypeEnum.goods : result.link_type;
|
|
|
result.success = success;
|
|
|
result.message = message;
|