Skip to content

Commit

Permalink
ArkProjects.EHentai.Api extract ClientName from Settings page
Browse files Browse the repository at this point in the history
  • Loading branch information
mixa3607 committed May 15, 2024
1 parent 51192ff commit 984c445
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{
"ExpectedResult": {
"ClientId": 45244,
"ClientName": "services.lan",
"ClientKey": "PFxb12auaaaaaaaaaaaa",
"StaticRanges": 289,
"StaticRangeGroups": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,10 @@

namespace ArkProjects.EHentai.Api.Models.Requests;

public enum StaticRangeGroupType
{
Unknown,
Priority1,
Priority2,
Priority3,
Priority4,
HighCapacity
}

public class StaticRangeGroup
{
public StaticRangeGroupType Type { get; set; } = StaticRangeGroupType.Unknown;
public int Count { get; set; } = -1;
}

public class HathSettingsResponse
{
public long ClientId { get; set; } = -1;
public string? ClientName { get; set; }
public string? ClientKey { get; set; }

public int StaticRanges { get; set; } = -1;
Expand All @@ -47,11 +32,18 @@ public static HathSettingsResponse Parse(HtmlDocument doc)
}

{
var table = tables.First(x => x.SelectSingleNode(".//tr/td/div[text()='Reset Static Ranges']") != null);

var table = doc.DocumentNode.SelectSingleNode("//*/table[@class='infot']");
var rows = table.SelectNodes(".//tr");
foreach (var row in rows)
{
if (row.InnerText.Contains("Reset Static Ranges"))
if (row.SelectNodes(".//td[@class='infota']").FirstOrDefault()?.InnerText.Contains("Client Name") == true)
{
var text = row.SelectNodes(".//td[@class='infotv']/p/span").First().InnerText;
response.ClientName = text?.Trim();
}

if (row.SelectNodes(".//td[@class='infota']").FirstOrDefault()?.InnerText.Contains("Reset Static Ranges") == true)
{
var text = row.SelectNodes(".//td[@class='infotv']/p[1]").First().InnerText;
{
Expand All @@ -78,7 +70,6 @@ public static HathSettingsResponse Parse(HtmlDocument doc)
match = match.NextMatch();
}
}

}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace ArkProjects.EHentai.Api.Models.Requests;

public class StaticRangeGroup
{
public StaticRangeGroupType Type { get; set; } = StaticRangeGroupType.Unknown;
public int Count { get; set; } = -1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace ArkProjects.EHentai.Api.Models.Requests;

public enum StaticRangeGroupType
{
Unknown,
Priority1,
Priority2,
Priority3,
Priority4,
HighCapacity
}

0 comments on commit 984c445

Please sign in to comment.