From bb8a5148304e6859dca224d6d7509ba6c7eae9c1 Mon Sep 17 00:00:00 2001 From: Glax Date: Sun, 9 Feb 2025 17:57:08 +0100 Subject: [PATCH 1/4] Do not create .duplicate files anymore. Just warn in log and delete (or attempt to delete) --- Tranga/Jobs/JobBoss.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Tranga/Jobs/JobBoss.cs b/Tranga/Jobs/JobBoss.cs index 4631a66..4ecf2e2 100644 --- a/Tranga/Jobs/JobBoss.cs +++ b/Tranga/Jobs/JobBoss.cs @@ -167,9 +167,10 @@ public class JobBoss : GlobalBase Log($"Adding Job {job}"); if (!AddJob(job, file.FullName)) //If we detect a duplicate, delete the file. { - string path = string.Concat(file.FullName, ".duplicate"); - file.MoveTo(path); - Log($"Duplicate detected or otherwise not able to add job to list.\nMoved job {job} to {path}"); + //string path = string.Concat(file.FullName, ".duplicate"); + //file.MoveTo(path); + //Log($"Duplicate detected or otherwise not able to add job to list.\nMoved job {job} to {path}"); + Log($"Duplicate detected or otherwise not able to add job to list. Removed the file {file.FullName} {job}"); } } catch (Exception e) From 603e1b41d9c1832771ee53607a77d8d5b27349bf Mon Sep 17 00:00:00 2001 From: Glax Date: Sun, 9 Feb 2025 18:37:33 +0100 Subject: [PATCH 2/4] Add Chromium referer header --- Tranga/MangaConnectors/ChromiumDownloadClient.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Tranga/MangaConnectors/ChromiumDownloadClient.cs b/Tranga/MangaConnectors/ChromiumDownloadClient.cs index 5c00005..86ac881 100644 --- a/Tranga/MangaConnectors/ChromiumDownloadClient.cs +++ b/Tranga/MangaConnectors/ChromiumDownloadClient.cs @@ -73,6 +73,7 @@ internal class ChromiumDownloadClient : DownloadClient return new RequestResult(HttpStatusCode.InternalServerError, null, Stream.Null); IPage page = _browser.NewPageAsync().Result; page.DefaultTimeout = TrangaSettings.ChromiumPageTimeoutMs; + page.SetExtraHttpHeadersAsync(new() { { "Referer", referrer } }); IResponse response; try { From a95cb90561e1582ddb6846f7e2417090d0ef5da0 Mon Sep 17 00:00:00 2001 From: Glax Date: Sun, 9 Feb 2025 18:37:41 +0100 Subject: [PATCH 3/4] Update Nuget packages --- Tranga/Tranga.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tranga/Tranga.csproj b/Tranga/Tranga.csproj index 1ca1c49..6447817 100644 --- a/Tranga/Tranga.csproj +++ b/Tranga/Tranga.csproj @@ -10,9 +10,9 @@ - + - + From e6d40a7b36df8f881fd8119731d34b0223925570 Mon Sep 17 00:00:00 2001 From: Glax Date: Sun, 9 Feb 2025 18:37:55 +0100 Subject: [PATCH 4/4] Remove unused code from Weebcentral --- Tranga/MangaConnectors/WeebCentral.cs | 40 ++------------------------- 1 file changed, 3 insertions(+), 37 deletions(-) diff --git a/Tranga/MangaConnectors/WeebCentral.cs b/Tranga/MangaConnectors/WeebCentral.cs index 50d63c4..c5d355f 100644 --- a/Tranga/MangaConnectors/WeebCentral.cs +++ b/Tranga/MangaConnectors/WeebCentral.cs @@ -43,7 +43,7 @@ public class Weebcentral : MangaConnector private Manga[] ParsePublicationsFromHtml(HtmlDocument document) { if (document.DocumentNode.SelectNodes("//article") == null) - return Array.Empty(); + 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 similarity = new(); - foreach (var sr in unfilteredSearchResults) - { - List 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(); + return []; //Return Chapters ordered by Chapter-Number if (requestResult.htmlDocument is null) - return Array.Empty(); + 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; } - } } \ No newline at end of file