Performance Improvements and Some Polish (#1702)
* Auto scale reading timeline * Added benchmarks for SharpImage and NetVips. When an epub has a malformed page, catch the error and present it better to the user. * Added a hint for an upcoming feature * Slightly sped up word count for epubs * Added one more test to reflect actual code. * Some light cleanup * Use compact number for stat lists * Fixed brightness being broken on manga reader * Replaced CoverToWebP SharpImage version with NetVips which is MUCH lighter on memory and CPU. * Added last modified on the progress dto for CdDisplayEx. * Code cleanup * Forgot one cleanup
This commit is contained in:
parent
d1596c4ab7
commit
b62d340bb3
15 changed files with 192 additions and 123 deletions
|
|
@ -196,8 +196,7 @@ public class WordCountAnalyzerService : IWordCountAnalyzerService
|
|||
return;
|
||||
}
|
||||
|
||||
file.LastFileAnalysis = DateTime.Now;
|
||||
_unitOfWork.MangaFileRepository.Update(file);
|
||||
UpdateFileAnalysis(file);
|
||||
}
|
||||
|
||||
chapter.WordCount = sum;
|
||||
|
|
@ -211,8 +210,7 @@ public class WordCountAnalyzerService : IWordCountAnalyzerService
|
|||
chapter.AvgHoursToRead = est.AvgHours;
|
||||
foreach (var file in chapter.Files)
|
||||
{
|
||||
file.LastFileAnalysis = DateTime.Now;
|
||||
_unitOfWork.MangaFileRepository.Update(file);
|
||||
UpdateFileAnalysis(file);
|
||||
}
|
||||
_unitOfWork.ChapterRepository.Update(chapter);
|
||||
}
|
||||
|
|
@ -233,22 +231,22 @@ public class WordCountAnalyzerService : IWordCountAnalyzerService
|
|||
_unitOfWork.SeriesRepository.Update(series);
|
||||
}
|
||||
|
||||
private void UpdateFileAnalysis(MangaFile file)
|
||||
{
|
||||
file.LastFileAnalysis = DateTime.Now;
|
||||
_unitOfWork.MangaFileRepository.Update(file);
|
||||
}
|
||||
|
||||
|
||||
private static async Task<int> GetWordCountFromHtml(EpubContentFileRef bookFile)
|
||||
{
|
||||
var doc = new HtmlDocument();
|
||||
doc.LoadHtml(await bookFile.ReadContentAsTextAsync());
|
||||
|
||||
var textNodes = doc.DocumentNode.SelectNodes("//body//text()[not(parent::script)]");
|
||||
if (textNodes == null) return 0;
|
||||
|
||||
return textNodes
|
||||
return doc.DocumentNode.SelectNodes("//body//text()[not(parent::script)]")
|
||||
.DefaultIfEmpty()
|
||||
.Select(node => node.InnerText.Split(' ', StringSplitOptions.RemoveEmptyEntries)
|
||||
.Where(s => char.IsLetter(s[0])))
|
||||
.Select(words => words.Count())
|
||||
.Where(wordCount => wordCount > 0)
|
||||
.Sum();
|
||||
.Sum(words => words.Count());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue