diff --git a/back/src/Kyoo.Abstractions/Models/Resources/Interfaces/IThumbnails.cs b/back/src/Kyoo.Abstractions/Models/Resources/Interfaces/IThumbnails.cs index 92402690..69fbca66 100644 --- a/back/src/Kyoo.Abstractions/Models/Resources/Interfaces/IThumbnails.cs +++ b/back/src/Kyoo.Abstractions/Models/Resources/Interfaces/IThumbnails.cs @@ -104,10 +104,7 @@ public class Image string? src = document.RootElement.GetProperty("Source").GetString(); string? blurhash = document.RootElement.GetProperty("Blurhash").GetString(); Guid? id = document.RootElement.GetProperty("Id").GetGuid(); - return new Image(src ?? string.Empty, blurhash) - { - Id = id ?? Guid.Empty - }; + return new Image(src ?? string.Empty, blurhash) { Id = id ?? Guid.Empty }; } /// diff --git a/back/src/Kyoo.Core/Controllers/Repositories/EpisodeRepository.cs b/back/src/Kyoo.Core/Controllers/Repositories/EpisodeRepository.cs index 3820102c..d3162666 100644 --- a/back/src/Kyoo.Core/Controllers/Repositories/EpisodeRepository.cs +++ b/back/src/Kyoo.Core/Controllers/Repositories/EpisodeRepository.cs @@ -33,8 +33,11 @@ namespace Kyoo.Core.Controllers; /// /// A local repository to handle episodes. /// -public class EpisodeRepository(DatabaseContext database, IRepository shows, IThumbnailsManager thumbnails) - : GenericRepository(database) +public class EpisodeRepository( + DatabaseContext database, + IRepository shows, + IThumbnailsManager thumbnails +) : GenericRepository(database) { static EpisodeRepository() { @@ -86,9 +89,12 @@ public class EpisodeRepository(DatabaseContext database, IRepository shows resource.Season = null; if (resource.SeasonId == null && resource.SeasonNumber != null) { - resource.SeasonId = await Database.Seasons.Where(x => - x.ShowId == resource.ShowId && x.SeasonNumber == resource.SeasonNumber - ).Select(x => x.Id).FirstOrDefaultAsync(); + resource.SeasonId = await Database + .Seasons.Where(x => + x.ShowId == resource.ShowId && x.SeasonNumber == resource.SeasonNumber + ) + .Select(x => x.Id) + .FirstOrDefaultAsync(); } await thumbnails.DownloadImages(resource); } diff --git a/back/src/Kyoo.Core/Program.cs b/back/src/Kyoo.Core/Program.cs index b750bb60..fc4660d1 100644 --- a/back/src/Kyoo.Core/Program.cs +++ b/back/src/Kyoo.Core/Program.cs @@ -96,6 +96,7 @@ await using (AsyncServiceScope scope = app.Services.CreateAsyncScope()) { await MeilisearchModule.Initialize(scope.ServiceProvider); } + // The methods takes care of creating a scope and will download images on the background. _ = MiscRepository.DownloadMissingImages(app.Services); diff --git a/back/src/Kyoo.Core/Views/Content/ThumbnailsApi.cs b/back/src/Kyoo.Core/Views/Content/ThumbnailsApi.cs index c56851e3..908a88d7 100644 --- a/back/src/Kyoo.Core/Views/Content/ThumbnailsApi.cs +++ b/back/src/Kyoo.Core/Views/Content/ThumbnailsApi.cs @@ -65,4 +65,3 @@ public class ThumbnailsApi(IThumbnailsManager thumbs) : BaseApi return PhysicalFile(Path.GetFullPath(path), "image/webp", true); } } - diff --git a/back/src/Kyoo.Core/Views/Resources/MovieApi.cs b/back/src/Kyoo.Core/Views/Resources/MovieApi.cs index 03f07822..629c3d0f 100644 --- a/back/src/Kyoo.Core/Views/Resources/MovieApi.cs +++ b/back/src/Kyoo.Core/Views/Resources/MovieApi.cs @@ -40,8 +40,7 @@ namespace Kyoo.Core.Api; [ApiController] [PartialPermission(nameof(Show))] [ApiDefinition("Shows", Group = ResourcesGroup)] -public class MovieApi(ILibraryManager libraryManager) - : TranscoderApi(libraryManager.Movies) +public class MovieApi(ILibraryManager libraryManager) : TranscoderApi(libraryManager.Movies) { /// /// Get studio that made the show diff --git a/back/src/Kyoo.Postgresql/Migrations/20240420124608_ReworkImages.cs b/back/src/Kyoo.Postgresql/Migrations/20240420124608_ReworkImages.cs index 9606e2d7..699c74a9 100644 --- a/back/src/Kyoo.Postgresql/Migrations/20240420124608_ReworkImages.cs +++ b/back/src/Kyoo.Postgresql/Migrations/20240420124608_ReworkImages.cs @@ -9,23 +9,27 @@ namespace Kyoo.Postgresql.Migrations { private void MigrateImage(MigrationBuilder migrationBuilder, string table, string type) { - migrationBuilder.Sql($""" - update {table} as r set {type} = json_build_object( - 'Id', gen_random_uuid(), - 'Source', r.{type}_source, - 'Blurhash', r.{type}_blurhash - ) - where r.{type}_source is not null - """); + migrationBuilder.Sql( + $""" + update {table} as r set {type} = json_build_object( + 'Id', gen_random_uuid(), + 'Source', r.{type}_source, + 'Blurhash', r.{type}_blurhash + ) + where r.{type}_source is not null + """ + ); } private void UnMigrateImage(MigrationBuilder migrationBuilder, string table, string type) { - migrationBuilder.Sql($""" - update {table} as r - set {type}_source = r.{type}->>'Source', - {type}_blurhash = r.{type}->>'Blurhash' - """); + migrationBuilder.Sql( + $""" + update {table} as r + set {type}_source = r.{type}->>'Source', + {type}_blurhash = r.{type}->>'Blurhash' + """ + ); } /// diff --git a/scanner/matcher/matcher.py b/scanner/matcher/matcher.py index b0b76932..7b0c71e7 100644 --- a/scanner/matcher/matcher.py +++ b/scanner/matcher/matcher.py @@ -187,7 +187,9 @@ class Matcher: } current = await self._client.get(kind, kyoo_id) if self._provider.name not in current["externalId"]: - logger.error(f"Could not refresh metadata of {kind}/{kyoo_id}. Missisg provider id.") + logger.error( + f"Could not refresh metadata of {kind}/{kyoo_id}. Missisg provider id." + ) return False provider_id = current["externalId"][self._provider.name] new_value = await identify_table[kind](current, provider_id)