mirror of
https://github.com/C9Glax/tranga.git
synced 2025-02-22 07:10:13 +01:00
Merge branch 'cuttingedge-merge-ServerV2' into postgres-Server-V2
# Conflicts: # API/MangaDownloadClients/ChromiumDownloadClient.cs # Tranga/Jobs/JobBoss.cs # Tranga/Tranga.csproj
This commit is contained in:
commit
dccc9fdbef
@ -69,6 +69,7 @@ internal class ChromiumDownloadClient : DownloadClient
|
||||
if (_browser is null)
|
||||
return new RequestResult(HttpStatusCode.InternalServerError, null, Stream.Null);
|
||||
IPage page = _browser.NewPageAsync().Result;
|
||||
page.SetExtraHttpHeadersAsync(new() { { "Referer", referrer } });
|
||||
page.DefaultTimeout = 10000;
|
||||
IResponse response;
|
||||
try
|
||||
|
@ -43,7 +43,7 @@ public class Weebcentral : MangaConnector
|
||||
private Manga[] ParsePublicationsFromHtml(HtmlDocument document)
|
||||
{
|
||||
if (document.DocumentNode.SelectNodes("//article") == null)
|
||||
return Array.Empty<Manga>();
|
||||
return [];
|
||||
|
||||
var urls = document.DocumentNode.SelectNodes("/html/body/article/a[@class='link link-hover']")
|
||||
.Select(elem => elem.GetAttributeValue("href", "")).ToList();
|
||||
@ -127,33 +127,6 @@ public class Weebcentral : MangaConnector
|
||||
return GetMangaFromUrl($"https://weebcentral.com/series/{publicationId}");
|
||||
}
|
||||
|
||||
private string ToFilteredString(string input)
|
||||
{
|
||||
return string.Join(' ', input.ToLower().Split(' ').Where(word => _filterWords.Contains(word) == false));
|
||||
}
|
||||
|
||||
private SearchResult[] FilteredResults(string publicationTitle, SearchResult[] unfilteredSearchResults)
|
||||
{
|
||||
Dictionary<SearchResult, int> similarity = new();
|
||||
foreach (var sr in unfilteredSearchResults)
|
||||
{
|
||||
List<int> scores = new();
|
||||
var filteredPublicationString = ToFilteredString(publicationTitle);
|
||||
var filteredSString = ToFilteredString(sr.s);
|
||||
scores.Add(NeedlemanWunschStringUtil.CalculateSimilarity(filteredSString, filteredPublicationString));
|
||||
foreach (var srA in sr.a)
|
||||
{
|
||||
var filteredAString = ToFilteredString(srA);
|
||||
scores.Add(NeedlemanWunschStringUtil.CalculateSimilarity(filteredAString, filteredPublicationString));
|
||||
}
|
||||
|
||||
similarity.Add(sr, scores.Sum() / scores.Count);
|
||||
}
|
||||
|
||||
var ret = similarity.OrderBy(s => s.Value).Take(10).Select(s => s.Key).ToList();
|
||||
return ret.ToArray();
|
||||
}
|
||||
|
||||
public override Chapter[] GetChapters(Manga manga, string language = "en")
|
||||
{
|
||||
Log($"Getting chapters {manga}");
|
||||
@ -161,11 +134,11 @@ public class Weebcentral : MangaConnector
|
||||
var requestResult =
|
||||
downloadClient.MakeRequest(requestUrl, RequestType.Default);
|
||||
if ((int)requestResult.statusCode < 200 || (int)requestResult.statusCode >= 300)
|
||||
return Array.Empty<Chapter>();
|
||||
return [];
|
||||
|
||||
//Return Chapters ordered by Chapter-Number
|
||||
if (requestResult.htmlDocument is null)
|
||||
return Array.Empty<Chapter>();
|
||||
return [];
|
||||
var chapters = ParseChaptersFromHtml(manga, requestResult.htmlDocument);
|
||||
Log($"Got {chapters.Count} chapters. {manga}");
|
||||
return chapters.Order().ToArray();
|
||||
@ -233,11 +206,4 @@ public class Weebcentral : MangaConnector
|
||||
|
||||
return DownloadChapterImages(urls, chapter, RequestType.MangaImage, progressToken: progressToken);
|
||||
}
|
||||
|
||||
private struct SearchResult
|
||||
{
|
||||
public string i { get; set; }
|
||||
public string s { get; set; }
|
||||
public string[] a { get; set; }
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user