mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Format code
This commit is contained in:
parent
9e38c3f333
commit
996209d205
@ -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 };
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
@ -33,8 +33,11 @@ namespace Kyoo.Core.Controllers;
|
||||
/// <summary>
|
||||
/// A local repository to handle episodes.
|
||||
/// </summary>
|
||||
public class EpisodeRepository(DatabaseContext database, IRepository<Show> shows, IThumbnailsManager thumbnails)
|
||||
: GenericRepository<Episode>(database)
|
||||
public class EpisodeRepository(
|
||||
DatabaseContext database,
|
||||
IRepository<Show> shows,
|
||||
IThumbnailsManager thumbnails
|
||||
) : GenericRepository<Episode>(database)
|
||||
{
|
||||
static EpisodeRepository()
|
||||
{
|
||||
@ -86,9 +89,12 @@ public class EpisodeRepository(DatabaseContext database, IRepository<Show> 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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -65,4 +65,3 @@ public class ThumbnailsApi(IThumbnailsManager thumbs) : BaseApi
|
||||
return PhysicalFile(Path.GetFullPath(path), "image/webp", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,8 +40,7 @@ namespace Kyoo.Core.Api;
|
||||
[ApiController]
|
||||
[PartialPermission(nameof(Show))]
|
||||
[ApiDefinition("Shows", Group = ResourcesGroup)]
|
||||
public class MovieApi(ILibraryManager libraryManager)
|
||||
: TranscoderApi<Movie>(libraryManager.Movies)
|
||||
public class MovieApi(ILibraryManager libraryManager) : TranscoderApi<Movie>(libraryManager.Movies)
|
||||
{
|
||||
/// <summary>
|
||||
/// Get studio that made the show
|
||||
|
@ -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'
|
||||
"""
|
||||
);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user