Skip to content

Commit

Permalink
优化订阅URL匹配
Browse files Browse the repository at this point in the history
  • Loading branch information
aiqinxuancai committed Jan 15, 2025
1 parent 5e02e54 commit e65e673
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
36 changes: 17 additions & 19 deletions Aria2Fast/Service/Model/TaskModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public bool FromSubscription
{
get
{
//if (!string.IsNullOrWhiteSpace(Data.Gid) &&
// SubscriptionManager.Instance.TaskUrlToSubscriptionName.ContainsKey(Data.Gid))
//{
// return true;
//}
if (!string.IsNullOrWhiteSpace(Data.Gid) &&
SubscriptionManager.Instance.TaskUrlToSubscriptionName.ContainsKey(Data.Gid))
{
return true;
}
if (!string.IsNullOrWhiteSpace(Data.InfoHash) &&
SubscriptionManager.Instance.TaskUrlToSubscriptionName.Any(a => a.Key.Contains(Data.InfoHash)))
{
Expand Down Expand Up @@ -73,26 +73,24 @@ public string SubscriptionName
{
if (FromSubscription)
{
//var name = (string)SubscriptionManager.Instance.TaskUrlToSubscriptionName[Data.Gid];
//if (!string.IsNullOrWhiteSpace(name))
//{
// return name;
//}

SubscriptionManager.Instance.TaskUrlToSubscriptionName.TryGetValue(Data.InfoHash!, out string name);
var name = (string)SubscriptionManager.Instance.TaskUrlToSubscriptionName[Data.Gid];
if (!string.IsNullOrWhiteSpace(name))
{
return name;
}
else

SubscriptionManager.Instance.TaskUrlToSubscriptionName.TryGetValue(Data.InfoHash!, out string nameFromHash);
if (!string.IsNullOrWhiteSpace(nameFromHash))
{
var kv = SubscriptionManager.Instance.TaskUrlToSubscriptionName.FirstOrDefault(a => a.Key.Contains(Data.InfoHash));
if (!string.IsNullOrWhiteSpace(kv.Value))
{
return kv.Value;
}
return nameFromHash;
}


var kv = SubscriptionManager.Instance.TaskUrlToSubscriptionName.LastOrDefault(a => a.Key.Contains(Data.InfoHash));
if (!string.IsNullOrWhiteSpace(kv.Value))
{
return kv.Value;
}


return ShowName;

Expand Down
1 change: 1 addition & 0 deletions Aria2Fast/Service/SubscriptionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ public async Task CheckSubscriptionOne(SubscriptionModel subscription, string cu
{
TaskUrlToSubscriptionName[aria2Result.InfoHash] = subject;
}
TaskUrlToSubscriptionName[downloadUrl] = subject;
}

if (aria2Result.IsSuccessed)
Expand Down

0 comments on commit e65e673

Please sign in to comment.