Support for setting subs-group remarks (group's name) from the (optional) "remark" query parameter in the pasted subs url

This commit is contained in:
OnceUponATimeInAmerica 2024-06-22 14:45:34 +03:30
parent b77cc3c33b
commit 4d69840364

View file

@ -1,6 +1,7 @@
using System.Data; using System.Data;
using System.IO; using System.IO;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Web;
using v2rayN.Enums; using v2rayN.Enums;
using v2rayN.Handler.Fmt; using v2rayN.Handler.Fmt;
using v2rayN.Models; using v2rayN.Models;
@ -1355,15 +1356,19 @@ namespace v2rayN.Handler
public static int AddSubItem(Config config, string url) public static int AddSubItem(Config config, string url)
{ {
//already exists //already exists
if (SQLiteHelper.Instance.Table<SubItem>().Where(e => e.url == url).Count() > 0) if (SQLiteHelper.Instance.Table<SubItem>().Any(e => e.url == url))
{ {
return 0; return 0;
} }
var uri = new Uri(url);
var queryVars = HttpUtility.ParseQueryString(uri.Query);
string remarks = queryVars["remarks"] ?? "import_sub";
SubItem subItem = new() SubItem subItem = new()
{ {
id = string.Empty, id = string.Empty,
remarks = "import_sub", remarks = remarks,
url = url url = url
}; };