mirror of https://github.com/ErsatzTV/ErsatzTV.git
Browse Source
* fix episode fallback metadata processing, fix show fallback metadata year parsing * fix sort title for "a" and "an" * add and index studio metadata * minimize circular logging with search index errors * update plex movie sort titles as needed * properly escape search links * force refreshing all movie/show metadatapull/96/head v0.0.23-prealpha
35 changed files with 3989 additions and 94 deletions
@ -1,8 +0,0 @@ |
|||||||
using ErsatzTV.Core; |
|
||||||
using LanguageExt; |
|
||||||
using MediatR; |
|
||||||
|
|
||||||
namespace ErsatzTV.Application.MediaCards.Queries |
|
||||||
{ |
|
||||||
public record GetSearchCards(string Query) : IRequest<Either<BaseError, SearchCardResultsViewModel>>; |
|
||||||
} |
|
||||||
@ -1,43 +0,0 @@ |
|||||||
using System.Threading; |
|
||||||
using System.Threading.Tasks; |
|
||||||
using ErsatzTV.Core; |
|
||||||
using ErsatzTV.Core.Interfaces.Repositories; |
|
||||||
using LanguageExt; |
|
||||||
using MediatR; |
|
||||||
using static ErsatzTV.Application.MediaCards.Mapper; |
|
||||||
using static LanguageExt.Prelude; |
|
||||||
|
|
||||||
namespace ErsatzTV.Application.MediaCards.Queries |
|
||||||
{ |
|
||||||
public class GetSearchCardsHandler : IRequestHandler<GetSearchCards, Either<BaseError, SearchCardResultsViewModel>> |
|
||||||
{ |
|
||||||
private readonly ISearchRepository _searchRepository; |
|
||||||
|
|
||||||
public GetSearchCardsHandler(ISearchRepository searchRepository) => _searchRepository = searchRepository; |
|
||||||
|
|
||||||
public Task<Either<BaseError, SearchCardResultsViewModel>> Handle( |
|
||||||
GetSearchCards request, |
|
||||||
CancellationToken cancellationToken) => |
|
||||||
request.Query.Split(":").Head() switch |
|
||||||
{ |
|
||||||
"genre" => GenreSearch(request.Query.Replace("genre:", string.Empty)), |
|
||||||
"tag" => TagSearch(request.Query.Replace("tag:", string.Empty)), |
|
||||||
_ => TitleSearch(request.Query) |
|
||||||
}; |
|
||||||
|
|
||||||
private Task<Either<BaseError, SearchCardResultsViewModel>> TitleSearch(string query) => |
|
||||||
Try(_searchRepository.SearchMediaItemsByTitle(query)).Sequence() |
|
||||||
.Map(ProjectToSearchResults) |
|
||||||
.Map(t => t.ToEither(ex => BaseError.New($"Failed to search: {ex.Message}"))); |
|
||||||
|
|
||||||
private Task<Either<BaseError, SearchCardResultsViewModel>> GenreSearch(string query) => |
|
||||||
Try(_searchRepository.SearchMediaItemsByGenre(query)).Sequence() |
|
||||||
.Map(ProjectToSearchResults) |
|
||||||
.Map(t => t.ToEither(ex => BaseError.New($"Failed to search: {ex.Message}"))); |
|
||||||
|
|
||||||
private Task<Either<BaseError, SearchCardResultsViewModel>> TagSearch(string query) => |
|
||||||
Try(_searchRepository.SearchMediaItemsByTag(query)).Sequence() |
|
||||||
.Map(ProjectToSearchResults) |
|
||||||
.Map(t => t.ToEither(ex => BaseError.New($"Failed to search: {ex.Message}"))); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -0,0 +1,8 @@ |
|||||||
|
namespace ErsatzTV.Core.Domain |
||||||
|
{ |
||||||
|
public class Studio |
||||||
|
{ |
||||||
|
public int Id { get; set; } |
||||||
|
public string Name { get; set; } |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,11 @@ |
|||||||
|
using ErsatzTV.Core.Domain; |
||||||
|
using Microsoft.EntityFrameworkCore; |
||||||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders; |
||||||
|
|
||||||
|
namespace ErsatzTV.Infrastructure.Data.Configurations |
||||||
|
{ |
||||||
|
public class StudioConfiguration : IEntityTypeConfiguration<Studio> |
||||||
|
{ |
||||||
|
public void Configure(EntityTypeBuilder<Studio> builder) => builder.ToTable("Studio"); |
||||||
|
} |
||||||
|
} |
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,75 @@ |
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||||
|
|
||||||
|
namespace ErsatzTV.Infrastructure.Migrations |
||||||
|
{ |
||||||
|
public partial class Add_Studio : Migration |
||||||
|
{ |
||||||
|
protected override void Up(MigrationBuilder migrationBuilder) |
||||||
|
{ |
||||||
|
migrationBuilder.CreateTable( |
||||||
|
"Studio", |
||||||
|
table => new |
||||||
|
{ |
||||||
|
Id = table.Column<int>("INTEGER", nullable: false) |
||||||
|
.Annotation("Sqlite:Autoincrement", true), |
||||||
|
Name = table.Column<string>("TEXT", nullable: true), |
||||||
|
EpisodeMetadataId = table.Column<int>("INTEGER", nullable: true), |
||||||
|
MovieMetadataId = table.Column<int>("INTEGER", nullable: true), |
||||||
|
SeasonMetadataId = table.Column<int>("INTEGER", nullable: true), |
||||||
|
ShowMetadataId = table.Column<int>("INTEGER", nullable: true) |
||||||
|
}, |
||||||
|
constraints: table => |
||||||
|
{ |
||||||
|
table.PrimaryKey("PK_Studio", x => x.Id); |
||||||
|
table.ForeignKey( |
||||||
|
"FK_Studio_EpisodeMetadata_EpisodeMetadataId", |
||||||
|
x => x.EpisodeMetadataId, |
||||||
|
"EpisodeMetadata", |
||||||
|
"Id", |
||||||
|
onDelete: ReferentialAction.Restrict); |
||||||
|
table.ForeignKey( |
||||||
|
"FK_Studio_MovieMetadata_MovieMetadataId", |
||||||
|
x => x.MovieMetadataId, |
||||||
|
"MovieMetadata", |
||||||
|
"Id", |
||||||
|
onDelete: ReferentialAction.Cascade); |
||||||
|
table.ForeignKey( |
||||||
|
"FK_Studio_SeasonMetadata_SeasonMetadataId", |
||||||
|
x => x.SeasonMetadataId, |
||||||
|
"SeasonMetadata", |
||||||
|
"Id", |
||||||
|
onDelete: ReferentialAction.Restrict); |
||||||
|
table.ForeignKey( |
||||||
|
"FK_Studio_ShowMetadata_ShowMetadataId", |
||||||
|
x => x.ShowMetadataId, |
||||||
|
"ShowMetadata", |
||||||
|
"Id", |
||||||
|
onDelete: ReferentialAction.Cascade); |
||||||
|
}); |
||||||
|
|
||||||
|
migrationBuilder.CreateIndex( |
||||||
|
"IX_Studio_EpisodeMetadataId", |
||||||
|
"Studio", |
||||||
|
"EpisodeMetadataId"); |
||||||
|
|
||||||
|
migrationBuilder.CreateIndex( |
||||||
|
"IX_Studio_MovieMetadataId", |
||||||
|
"Studio", |
||||||
|
"MovieMetadataId"); |
||||||
|
|
||||||
|
migrationBuilder.CreateIndex( |
||||||
|
"IX_Studio_SeasonMetadataId", |
||||||
|
"Studio", |
||||||
|
"SeasonMetadataId"); |
||||||
|
|
||||||
|
migrationBuilder.CreateIndex( |
||||||
|
"IX_Studio_ShowMetadataId", |
||||||
|
"Studio", |
||||||
|
"ShowMetadataId"); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder) => |
||||||
|
migrationBuilder.DropTable( |
||||||
|
"Studio"); |
||||||
|
} |
||||||
|
} |
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,18 @@ |
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||||
|
|
||||||
|
namespace ErsatzTV.Infrastructure.Migrations |
||||||
|
{ |
||||||
|
public partial class Reset_MetadataDateUpdated_Studio : Migration |
||||||
|
{ |
||||||
|
protected override void Up(MigrationBuilder migrationBuilder) |
||||||
|
{ |
||||||
|
migrationBuilder.Sql(@"UPDATE MovieMetadata SET DateUpdated = '0001-01-01 00:00:00'"); |
||||||
|
migrationBuilder.Sql(@"UPDATE ShowMetadata SET DateUpdated = '0001-01-01 00:00:00'"); |
||||||
|
migrationBuilder.Sql(@"UPDATE Library SET LastScan = '0001-01-01 00:00:00'"); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder) |
||||||
|
{ |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue