From a550312279ff279f62069bb89a889c03cf106432 Mon Sep 17 00:00:00 2001 From: Joe Milazzo Date: Fri, 4 Aug 2023 14:34:44 -0500 Subject: [PATCH] Epub Weblinks + Localization Changes (#2180) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fixed a bug where scan series wasn't ignoring optimizations for chapter metadata updates. Implemented pulling weblinks from epubs. * Fixed localization issue * Translations update from Hosted Weblate (#2179) * Translated using Weblate (French) Currently translated at 8.2% (13 of 158 strings) Translation: Kavita/backend Translate-URL: https://hosted.weblate.org/projects/kavita/backend/fr/ * Translated using Weblate (French) Currently translated at 13.2% (21 of 158 strings) Translation: Kavita/backend Translate-URL: https://hosted.weblate.org/projects/kavita/backend/fr/ * Added translation using Weblate (Japanese) * Added translation using Weblate (Undetermined) * Added translation using Weblate (Thai) * Added translation using Weblate (Chinese (Simplified)) * Added translation using Weblate (Chinese (Simplified)) * Added translation using Weblate (Thai) * Translated using Weblate (Spanish) Currently translated at 1.5% (22 of 1416 strings) Translation: Kavita/ui Translate-URL: https://hosted.weblate.org/projects/kavita/ui/es/ * Translated using Weblate (Dutch) Currently translated at 98.1% (155 of 158 strings) Translation: Kavita/backend Translate-URL: https://hosted.weblate.org/projects/kavita/backend/nl/ * Translated using Weblate (Dutch) Currently translated at 98.1% (155 of 158 strings) Translation: Kavita/backend Translate-URL: https://hosted.weblate.org/projects/kavita/backend/nl/ * Translated using Weblate (Dutch) Currently translated at 8.1% (115 of 1416 strings) Translation: Kavita/ui Translate-URL: https://hosted.weblate.org/projects/kavita/ui/nl/ * Translated using Weblate (Dutch) Currently translated at 8.1% (115 of 1416 strings) Translation: Kavita/ui Translate-URL: https://hosted.weblate.org/projects/kavita/ui/nl/ * Translated using Weblate (Thai) Currently translated at 7.5% (12 of 158 strings) Translation: Kavita/backend Translate-URL: https://hosted.weblate.org/projects/kavita/backend/th/ * Translated using Weblate (Chinese (Simplified)) Currently translated at 5.0% (72 of 1416 strings) Translation: Kavita/ui Translate-URL: https://hosted.weblate.org/projects/kavita/ui/zh_Hans/ * Translated using Weblate (Chinese (Simplified)) Currently translated at 8.2% (13 of 158 strings) Translation: Kavita/backend Translate-URL: https://hosted.weblate.org/projects/kavita/backend/zh_Hans/ * Translated using Weblate (Chinese (Simplified)) Currently translated at 5.6% (80 of 1416 strings) Translation: Kavita/ui Translate-URL: https://hosted.weblate.org/projects/kavita/ui/zh_Hans/ * Added translation using Weblate (Portuguese) * Translated using Weblate (Dutch) Currently translated at 11.4% (162 of 1416 strings) Translation: Kavita/ui Translate-URL: https://hosted.weblate.org/projects/kavita/ui/nl/ * Translated using Weblate (Dutch) Currently translated at 11.4% (162 of 1416 strings) Translation: Kavita/ui Translate-URL: https://hosted.weblate.org/projects/kavita/ui/nl/ * Translated using Weblate (Chinese (Simplified)) Currently translated at 12.0% (19 of 158 strings) Translation: Kavita/backend Translate-URL: https://hosted.weblate.org/projects/kavita/backend/zh_Hans/ * Added translation using Weblate (Italian) * Translated using Weblate (Dutch) Currently translated at 12.6% (179 of 1416 strings) Translation: Kavita/ui Translate-URL: https://hosted.weblate.org/projects/kavita/ui/nl/ * Translated using Weblate (Dutch) Currently translated at 12.6% (179 of 1416 strings) Translation: Kavita/ui Translate-URL: https://hosted.weblate.org/projects/kavita/ui/nl/ * Translated using Weblate (Thai) Currently translated at 2.3% (33 of 1416 strings) Translation: Kavita/ui Translate-URL: https://hosted.weblate.org/projects/kavita/ui/th/ * Translated using Weblate (Thai) Currently translated at 2.3% (33 of 1416 strings) Translation: Kavita/ui Translate-URL: https://hosted.weblate.org/projects/kavita/ui/th/ * Translated using Weblate (Portuguese) Currently translated at 0.6% (1 of 158 strings) Translation: Kavita/backend Translate-URL: https://hosted.weblate.org/projects/kavita/backend/pt/ * Translated using Weblate (Italian) Currently translated at 40.5% (64 of 158 strings) Translation: Kavita/backend Translate-URL: https://hosted.weblate.org/projects/kavita/backend/it/ * Translated using Weblate (French) Currently translated at 15.8% (25 of 158 strings) Translation: Kavita/backend Translate-URL: https://hosted.weblate.org/projects/kavita/backend/fr/ * Translated using Weblate (Thai) Currently translated at 4.8% (69 of 1416 strings) Translation: Kavita/ui Translate-URL: https://hosted.weblate.org/projects/kavita/ui/th/ * Translated using Weblate (Portuguese) Currently translated at 89.8% (142 of 158 strings) Translation: Kavita/backend Translate-URL: https://hosted.weblate.org/projects/kavita/backend/pt/ * Translated using Weblate (Italian) Currently translated at 67.7% (107 of 158 strings) Translation: Kavita/backend Translate-URL: https://hosted.weblate.org/projects/kavita/backend/it/ * Translated using Weblate (Spanish) Currently translated at 5.1% (73 of 1416 strings) Translation: Kavita/ui Translate-URL: https://hosted.weblate.org/projects/kavita/ui/es/ * Translated using Weblate (Dutch) Currently translated at 12.8% (182 of 1416 strings) Translation: Kavita/ui Translate-URL: https://hosted.weblate.org/projects/kavita/ui/nl/ * Translated using Weblate (Spanish) Currently translated at 12.8% (182 of 1416 strings) Translation: Kavita/ui Translate-URL: https://hosted.weblate.org/projects/kavita/ui/es/ --------- Co-authored-by: Francois Wilhelmy Co-authored-by: 周書丞 Co-authored-by: 书签 Co-authored-by: AlienHack Co-authored-by: NeneNeko Co-authored-by: Toto Saurio Co-authored-by: Stijn Co-authored-by: Hans Kalisvaart Co-authored-by: Duarte Silva Co-authored-by: stan xu Co-authored-by: Tomas Battistini Co-authored-by: majora2007 Co-authored-by: zeedif * Removed a blank API localization file --------- Co-authored-by: Weblate (bot) Co-authored-by: Francois Wilhelmy Co-authored-by: 周書丞 Co-authored-by: 书签 Co-authored-by: AlienHack Co-authored-by: NeneNeko Co-authored-by: Toto Saurio Co-authored-by: Stijn Co-authored-by: Hans Kalisvaart Co-authored-by: Duarte Silva Co-authored-by: stan xu Co-authored-by: Tomas Battistini Co-authored-by: majora2007 Co-authored-by: zeedif --- API/Controllers/SeriesController.cs | 2 +- API/Services/BookService.cs | 29 ++++++++++++++----- API/Services/Tasks/Scanner/ProcessSeries.cs | 10 +++---- API/Services/Tasks/ScannerService.cs | 2 +- .../review-card/review-card.component.html | 2 +- UI/Web/src/assets/langs/en.json | 3 +- openapi.json | 2 +- 7 files changed, 33 insertions(+), 17 deletions(-) diff --git a/API/Controllers/SeriesController.cs b/API/Controllers/SeriesController.cs index 8c2a0ced0..c420a955f 100644 --- a/API/Controllers/SeriesController.cs +++ b/API/Controllers/SeriesController.cs @@ -322,7 +322,7 @@ public class SeriesController : BaseApiController [HttpPost("scan")] public ActionResult ScanSeries(RefreshSeriesDto refreshSeriesDto) { - _taskScheduler.ScanSeries(refreshSeriesDto.LibraryId, refreshSeriesDto.SeriesId, refreshSeriesDto.ForceUpdate); + _taskScheduler.ScanSeries(refreshSeriesDto.LibraryId, refreshSeriesDto.SeriesId, true); return Ok(); } diff --git a/API/Services/BookService.cs b/API/Services/BookService.cs index d03a44daa..54d2257ab 100644 --- a/API/Services/BookService.cs +++ b/API/Services/BookService.cs @@ -455,17 +455,32 @@ public class BookService : IBookService }; ComicInfo.CleanComicInfo(info); - foreach (var identifier in epubBook.Schema.Package.Metadata.Identifiers.Where(id => !string.IsNullOrEmpty(id.Scheme) && id.Scheme.Equals("ISBN"))) + var weblinks = new List(); + foreach (var identifier in epubBook.Schema.Package.Metadata.Identifiers) { if (string.IsNullOrEmpty(identifier.Identifier)) continue; - var isbn = identifier.Identifier.Replace("urn:isbn:", string.Empty).Replace("isbn:", string.Empty); - if (!ArticleNumberHelper.IsValidIsbn10(isbn) && !ArticleNumberHelper.IsValidIsbn13(isbn)) + if (!string.IsNullOrEmpty(identifier.Scheme) && identifier.Scheme.Equals("ISBN", StringComparison.InvariantCultureIgnoreCase)) { - _logger.LogDebug("[BookService] {File} has invalid ISBN number", filePath); - continue; + var isbn = identifier.Identifier.Replace("urn:isbn:", string.Empty).Replace("isbn:", string.Empty); + if (!ArticleNumberHelper.IsValidIsbn10(isbn) && !ArticleNumberHelper.IsValidIsbn13(isbn)) + { + _logger.LogDebug("[BookService] {File} has invalid ISBN number", filePath); + continue; + } + info.Isbn = isbn; } - info.Isbn = isbn; - break; + + if ((!string.IsNullOrEmpty(identifier.Scheme) && identifier.Scheme.Equals("URL", StringComparison.InvariantCultureIgnoreCase)) || + identifier.Identifier.StartsWith("url:")) + { + var url = identifier.Identifier.Replace("url:", string.Empty); + weblinks.Add(url.Trim()); + } + } + + if (weblinks.Count > 0) + { + info.Web = string.Join(',', weblinks.Distinct()); } // Parse tags not exposed via Library diff --git a/API/Services/Tasks/Scanner/ProcessSeries.cs b/API/Services/Tasks/Scanner/ProcessSeries.cs index bf634f6b6..6ad7f6100 100644 --- a/API/Services/Tasks/Scanner/ProcessSeries.cs +++ b/API/Services/Tasks/Scanner/ProcessSeries.cs @@ -36,7 +36,7 @@ public interface IProcessSeries void UpdateVolumes(Series series, IList parsedInfos, bool forceUpdate = false); void UpdateChapters(Series series, Volume volume, IList parsedInfos, bool forceUpdate = false); void AddOrUpdateFileForChapter(Chapter chapter, ParserInfo info, bool forceUpdate = false); - void UpdateChapterFromComicInfo(Chapter chapter, ComicInfo? comicInfo); + void UpdateChapterFromComicInfo(Chapter chapter, ComicInfo? comicInfo, bool forceUpdate = false); } /// @@ -534,11 +534,11 @@ public class ProcessSeries : IProcessSeries foreach (var chapter in volume.Chapters) { var firstFile = chapter.Files.MinBy(x => x.Chapter); - if (firstFile == null || _cacheHelper.IsFileUnmodifiedSinceCreationOrLastScan(chapter, false, firstFile)) continue; + if (firstFile == null || _cacheHelper.IsFileUnmodifiedSinceCreationOrLastScan(chapter, forceUpdate, firstFile)) continue; try { var firstChapterInfo = infos.SingleOrDefault(i => i.FullFilePath.Equals(firstFile.FilePath)); - UpdateChapterFromComicInfo(chapter, firstChapterInfo?.ComicInfo); + UpdateChapterFromComicInfo(chapter, firstChapterInfo?.ComicInfo, forceUpdate); } catch (Exception ex) { @@ -660,12 +660,12 @@ public class ProcessSeries : IProcessSeries } } - public void UpdateChapterFromComicInfo(Chapter chapter, ComicInfo? comicInfo) + public void UpdateChapterFromComicInfo(Chapter chapter, ComicInfo? comicInfo, bool forceUpdate = false) { if (comicInfo == null) return; var firstFile = chapter.Files.MinBy(x => x.Chapter); if (firstFile == null || - _cacheHelper.IsFileUnmodifiedSinceCreationOrLastScan(chapter, false, firstFile)) return; + _cacheHelper.IsFileUnmodifiedSinceCreationOrLastScan(chapter, forceUpdate, firstFile)) return; _logger.LogTrace("[ScannerService] Read ComicInfo for {File}", firstFile.FilePath); diff --git a/API/Services/Tasks/ScannerService.cs b/API/Services/Tasks/ScannerService.cs index 5569e8640..7f41f685a 100644 --- a/API/Services/Tasks/ScannerService.cs +++ b/API/Services/Tasks/ScannerService.cs @@ -258,7 +258,7 @@ public class ScannerService : IScannerService return; } - await _processSeries.ProcessSeriesAsync(parsedFiles, library); + await _processSeries.ProcessSeriesAsync(parsedFiles, library, bypassFolderOptimizationChecks); parsedSeries.Add(foundParsedSeries, parsedFiles); } diff --git a/UI/Web/src/app/_single-module/review-card/review-card.component.html b/UI/Web/src/app/_single-module/review-card/review-card.component.html index fd888e2a4..e665aaaaf 100644 --- a/UI/Web/src/app/_single-module/review-card/review-card.component.html +++ b/UI/Web/src/app/_single-module/review-card/review-card.component.html @@ -30,7 +30,7 @@ {{(isMyReview ? '' : review.username | defaultValue:'')}} - {{t('rating-percentage', {r: review.score})}}% + {{t('rating-percentage', {r: review.score})}} diff --git a/UI/Web/src/assets/langs/en.json b/UI/Web/src/assets/langs/en.json index da9894680..079e8ba93 100644 --- a/UI/Web/src/assets/langs/en.json +++ b/UI/Web/src/assets/langs/en.json @@ -951,7 +951,8 @@ "less-than-hour": "<1 Hour", "range-hours": "{{value}} {{hourWord}}", "hour": "Hour", - "hours": "Hours" + "hours": "Hours", + "read-time-title": "{{series-info-cards.read-time-title}}" }, "series-info-cards": { diff --git a/openapi.json b/openapi.json index 18abbc66e..b4cf725bd 100644 --- a/openapi.json +++ b/openapi.json @@ -7,7 +7,7 @@ "name": "GPL-3.0", "url": "https://github.com/Kareadita/Kavita/blob/develop/LICENSE" }, - "version": "0.7.6.2" + "version": "0.7.6.5" }, "servers": [ {