mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Replacing IEnumearble with ICollections inside resources
This commit is contained in:
parent
5f6c663f18
commit
bc7a314409
@ -241,9 +241,8 @@ namespace Kyoo.Controllers
|
||||
Task<Studio> EditStudio(Studio studio, bool resetOld);
|
||||
Task<People> EditPeople(People people, bool resetOld);
|
||||
|
||||
|
||||
// Delete values
|
||||
Task DelteLibrary(Library library);
|
||||
Task DeleteLibrary(Library library);
|
||||
Task DeleteCollection(Collection collection);
|
||||
Task DeleteShow(Show show);
|
||||
Task DeleteSeason(Season season);
|
||||
@ -254,7 +253,7 @@ namespace Kyoo.Controllers
|
||||
Task DeletePeople(People people);
|
||||
|
||||
//Delete by slug
|
||||
Task DelteLibrary(string slug);
|
||||
Task DeleteLibrary(string slug);
|
||||
Task DeleteCollection(string slug);
|
||||
Task DeleteShow(string slug);
|
||||
Task DeleteSeason(string slug);
|
||||
@ -265,7 +264,7 @@ namespace Kyoo.Controllers
|
||||
Task DeletePeople(string slug);
|
||||
|
||||
//Delete by id
|
||||
Task DelteLibrary(int id);
|
||||
Task DeleteLibrary(int id);
|
||||
Task DeleteCollection(int id);
|
||||
Task DeleteShow(int id);
|
||||
Task DeleteSeason(int id);
|
||||
|
@ -11,8 +11,8 @@ namespace Kyoo.Controllers
|
||||
Task<Collection> GetCollectionFromName(string name);
|
||||
|
||||
Task<Show> GetShowByID(Show show);
|
||||
Task<IEnumerable<Show>> SearchShows(string showName, bool isMovie);
|
||||
Task<IEnumerable<PeopleRole>> GetPeople(Show show);
|
||||
Task<ICollection<Show>> SearchShows(string showName, bool isMovie);
|
||||
Task<ICollection<PeopleRole>> GetPeople(Show show);
|
||||
|
||||
Task<Season> GetSeason(Show show, int seasonNumber);
|
||||
|
||||
|
@ -12,6 +12,6 @@ namespace Kyoo.Controllers
|
||||
Task<IEnumerable<Show>> SearchShows(string showName, bool isMovie, Library library);
|
||||
Task<Season> GetSeason(Show show, int seasonNumber, Library library);
|
||||
Task<Episode> GetEpisode(Show show, string episodePath, int seasonNumber, int episodeNumber, int absoluteNumber, Library library);
|
||||
Task<IEnumerable<PeopleRole>> GetPeople(Show show, Library library);
|
||||
Task<ICollection<PeopleRole>> GetPeople(Show show, Library library);
|
||||
}
|
||||
}
|
@ -12,7 +12,7 @@
|
||||
<Company>SDG</Company>
|
||||
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
|
||||
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
|
||||
<PackageVersion>1.0.22</PackageVersion>
|
||||
<PackageVersion>1.0.23</PackageVersion>
|
||||
<IncludeSymbols>true</IncludeSymbols>
|
||||
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||
<LangVersion>default</LangVersion>
|
||||
@ -23,4 +23,8 @@
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.0-beta-20204-02" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Controllers\Implementations" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using Kyoo.Models.Attributes;
|
||||
|
||||
@ -33,7 +34,7 @@ namespace Kyoo.Models
|
||||
}
|
||||
|
||||
[ExpressionRewrite(nameof(People) + "."+ nameof(Models.People.ExternalIDs))]
|
||||
public IEnumerable<MetadataID> ExternalIDs
|
||||
public ICollection<MetadataID> ExternalIDs
|
||||
{
|
||||
get => People.ExternalIDs;
|
||||
set => People.ExternalIDs = value;
|
||||
@ -75,7 +76,7 @@ namespace Kyoo.Models
|
||||
|
||||
public string Slug { get; set; }
|
||||
public string Title { get; set; }
|
||||
public IEnumerable<string> Aliases { get; set; }
|
||||
public ICollection<string> Aliases { get; set; }
|
||||
[JsonIgnore] public string Path { get; set; }
|
||||
public string Overview { get; set; }
|
||||
public Status? Status { get; set; }
|
||||
@ -96,7 +97,7 @@ namespace Kyoo.Models
|
||||
Type = x.Type;
|
||||
Slug = x.Show.Slug;
|
||||
Title = x.Show.Title;
|
||||
Aliases = x.Show.Aliases;
|
||||
Aliases = x.Show.Aliases?.ToArray();
|
||||
Path = x.Show.Path;
|
||||
Overview = x.Show.Overview;
|
||||
Status = x.Show.Status;
|
||||
@ -116,7 +117,7 @@ namespace Kyoo.Models
|
||||
Type = x.Type,
|
||||
Slug = x.Show.Slug,
|
||||
Title = x.Show.Title,
|
||||
Aliases = x.Show.Aliases,
|
||||
Aliases = x.Show.Aliases != null ? x.Show.Aliases.ToArray() : null,
|
||||
Path = x.Show.Path,
|
||||
Overview = x.Show.Overview,
|
||||
Status = x.Show.Status,
|
||||
|
@ -5,6 +5,6 @@ namespace Kyoo.Models
|
||||
public interface IPlugin
|
||||
{
|
||||
public string Name { get; }
|
||||
public IEnumerable<ITask> Tasks { get; }
|
||||
public ICollection<ITask> Tasks { get; }
|
||||
}
|
||||
}
|
@ -10,8 +10,8 @@ namespace Kyoo.Models
|
||||
public string Name { get; set; }
|
||||
public string Poster { get; set; }
|
||||
public string Overview { get; set; }
|
||||
[JsonIgnore] public virtual IEnumerable<Show> Shows { get; set; }
|
||||
[JsonIgnore] public virtual IEnumerable<Library> Libraries { get; set; }
|
||||
[JsonIgnore] public virtual ICollection<Show> Shows { get; set; }
|
||||
[JsonIgnore] public virtual ICollection<Library> Libraries { get; set; }
|
||||
|
||||
public Collection() { }
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Kyoo.Models.Attributes;
|
||||
|
||||
namespace Kyoo.Models
|
||||
@ -24,9 +25,9 @@ namespace Kyoo.Models
|
||||
public int Runtime { get; set; } //This runtime variable should be in minutes
|
||||
|
||||
[JsonIgnore] public string Poster { get; set; }
|
||||
[EditableRelation] public virtual IEnumerable<MetadataID> ExternalIDs { get; set; }
|
||||
[EditableRelation] public virtual ICollection<MetadataID> ExternalIDs { get; set; }
|
||||
|
||||
[JsonIgnore] public virtual IEnumerable<Track> Tracks { get; set; }
|
||||
[JsonIgnore] public virtual ICollection<Track> Tracks { get; set; }
|
||||
|
||||
public string ShowTitle => Show.Title;
|
||||
public string Slug => Show != null ? GetSlug(Show.Slug, SeasonNumber, EpisodeNumber) : ID.ToString();
|
||||
@ -61,7 +62,7 @@ namespace Kyoo.Models
|
||||
ReleaseDate = releaseDate;
|
||||
Runtime = runtime;
|
||||
Poster = poster;
|
||||
ExternalIDs = externalIDs;
|
||||
ExternalIDs = externalIDs?.ToArray();
|
||||
}
|
||||
|
||||
public Episode(int showID,
|
||||
@ -76,19 +77,11 @@ namespace Kyoo.Models
|
||||
int runtime,
|
||||
string poster,
|
||||
IEnumerable<MetadataID> externalIDs)
|
||||
: this(seasonNumber, episodeNumber, absoluteNumber, title, overview, releaseDate, runtime, poster, externalIDs)
|
||||
{
|
||||
ShowID = showID;
|
||||
SeasonID = seasonID;
|
||||
SeasonNumber = seasonNumber;
|
||||
EpisodeNumber = episodeNumber;
|
||||
AbsoluteNumber = absoluteNumber;
|
||||
Path = path;
|
||||
Title = title;
|
||||
Overview = overview;
|
||||
ReleaseDate = releaseDate;
|
||||
Runtime = runtime;
|
||||
Poster = poster;
|
||||
ExternalIDs = externalIDs;
|
||||
}
|
||||
|
||||
public static string GetSlug(string showSlug, int seasonNumber, int episodeNumber)
|
||||
|
@ -9,7 +9,7 @@ namespace Kyoo.Models
|
||||
public string Slug { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonIgnore] public virtual IEnumerable<Show> Shows { get; set; }
|
||||
[JsonIgnore] public virtual ICollection<Show> Shows { get; set; }
|
||||
|
||||
public Genre() {}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Kyoo.Models.Attributes;
|
||||
|
||||
namespace Kyoo.Models
|
||||
@ -8,12 +9,12 @@ namespace Kyoo.Models
|
||||
[JsonIgnore] public int ID { get; set; }
|
||||
public string Slug { get; set; }
|
||||
public string Name { get; set; }
|
||||
public IEnumerable<string> Paths { get; set; }
|
||||
public ICollection<string> Paths { get; set; }
|
||||
|
||||
[EditableRelation] public virtual IEnumerable<ProviderID> Providers { get; set; }
|
||||
[EditableRelation] public virtual ICollection<ProviderID> Providers { get; set; }
|
||||
|
||||
[JsonIgnore] public virtual IEnumerable<Show> Shows { get; set; }
|
||||
[JsonIgnore] public virtual IEnumerable<Collection> Collections { get; set; }
|
||||
[JsonIgnore] public virtual ICollection<Show> Shows { get; set; }
|
||||
[JsonIgnore] public virtual ICollection<Collection> Collections { get; set; }
|
||||
|
||||
public Library() { }
|
||||
|
||||
@ -21,8 +22,8 @@ namespace Kyoo.Models
|
||||
{
|
||||
Slug = slug;
|
||||
Name = name;
|
||||
Paths = paths;
|
||||
Providers = providers;
|
||||
Paths = paths?.ToArray();
|
||||
Providers = providers?.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Kyoo.Models.Attributes;
|
||||
|
||||
namespace Kyoo.Models
|
||||
@ -9,9 +10,9 @@ namespace Kyoo.Models
|
||||
public string Slug { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Poster { get; set; }
|
||||
[EditableRelation] public virtual IEnumerable<MetadataID> ExternalIDs { get; set; }
|
||||
[EditableRelation] public virtual ICollection<MetadataID> ExternalIDs { get; set; }
|
||||
|
||||
[EditableRelation] [JsonReadOnly] public virtual IEnumerable<PeopleRole> Roles { get; set; }
|
||||
[EditableRelation] [JsonReadOnly] public virtual ICollection<PeopleRole> Roles { get; set; }
|
||||
|
||||
public People() {}
|
||||
|
||||
@ -20,7 +21,7 @@ namespace Kyoo.Models
|
||||
Slug = slug;
|
||||
Name = name;
|
||||
Poster = poster;
|
||||
ExternalIDs = externalIDs;
|
||||
ExternalIDs = externalIDs?.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Kyoo.Models.Attributes;
|
||||
|
||||
namespace Kyoo.Models
|
||||
@ -17,10 +18,10 @@ namespace Kyoo.Models
|
||||
public int? Year { get; set; }
|
||||
|
||||
[JsonIgnore] public string Poster { get; set; }
|
||||
[EditableRelation] public virtual IEnumerable<MetadataID> ExternalIDs { get; set; }
|
||||
[EditableRelation] public virtual ICollection<MetadataID> ExternalIDs { get; set; }
|
||||
|
||||
[JsonIgnore] public virtual Show Show { get; set; }
|
||||
[JsonIgnore] public virtual IEnumerable<Episode> Episodes { get; set; }
|
||||
[JsonIgnore] public virtual ICollection<Episode> Episodes { get; set; }
|
||||
|
||||
public Season() { }
|
||||
|
||||
@ -38,7 +39,7 @@ namespace Kyoo.Models
|
||||
Overview = overview;
|
||||
Year = year;
|
||||
Poster = poster;
|
||||
ExternalIDs = externalIDs;
|
||||
ExternalIDs = externalIDs?.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ namespace Kyoo.Models
|
||||
public int ID { get; set; }
|
||||
public string Slug { get; set; }
|
||||
public string Title { get; set; }
|
||||
[EditableRelation] public IEnumerable<string> Aliases { get; set; }
|
||||
[EditableRelation] public ICollection<string> Aliases { get; set; }
|
||||
[JsonIgnore] public string Path { get; set; }
|
||||
public string Overview { get; set; }
|
||||
public Status? Status { get; set; }
|
||||
@ -24,17 +24,17 @@ namespace Kyoo.Models
|
||||
|
||||
public bool IsMovie { get; set; }
|
||||
|
||||
[EditableRelation] public virtual IEnumerable<MetadataID> ExternalIDs { get; set; }
|
||||
[EditableRelation] public virtual ICollection<MetadataID> ExternalIDs { get; set; }
|
||||
|
||||
|
||||
[JsonIgnore] public int? StudioID { get; set; }
|
||||
[EditableRelation] [JsonReadOnly] public virtual Studio Studio { get; set; }
|
||||
[EditableRelation] [JsonReadOnly] public virtual IEnumerable<Genre> Genres { get; set; }
|
||||
[EditableRelation] [JsonReadOnly] public virtual IEnumerable<PeopleRole> People { get; set; }
|
||||
[JsonIgnore] public virtual IEnumerable<Season> Seasons { get; set; }
|
||||
[JsonIgnore] public virtual IEnumerable<Episode> Episodes { get; set; }
|
||||
[JsonIgnore] public virtual IEnumerable<Library> Libraries { get; set; }
|
||||
[JsonIgnore] public virtual IEnumerable<Collection> Collections { get; set; }
|
||||
[EditableRelation] [JsonReadOnly] public virtual ICollection<Genre> Genres { get; set; }
|
||||
[EditableRelation] [JsonReadOnly] public virtual ICollection<PeopleRole> People { get; set; }
|
||||
[JsonIgnore] public virtual ICollection<Season> Seasons { get; set; }
|
||||
[JsonIgnore] public virtual ICollection<Episode> Episodes { get; set; }
|
||||
[JsonIgnore] public virtual ICollection<Library> Libraries { get; set; }
|
||||
[JsonIgnore] public virtual ICollection<Collection> Collections { get; set; }
|
||||
|
||||
public Show() { }
|
||||
|
||||
@ -51,15 +51,15 @@ namespace Kyoo.Models
|
||||
{
|
||||
Slug = slug;
|
||||
Title = title;
|
||||
Aliases = aliases;
|
||||
Aliases = aliases?.ToArray();
|
||||
Path = path;
|
||||
Overview = overview;
|
||||
TrailerUrl = trailerUrl;
|
||||
Genres = genres;
|
||||
Genres = genres?.ToArray();
|
||||
Status = status;
|
||||
StartYear = startYear;
|
||||
EndYear = endYear;
|
||||
ExternalIDs = externalIDs;
|
||||
ExternalIDs = externalIDs?.ToArray();
|
||||
}
|
||||
|
||||
public Show(string slug,
|
||||
@ -78,7 +78,7 @@ namespace Kyoo.Models
|
||||
{
|
||||
Slug = slug;
|
||||
Title = title;
|
||||
Aliases = aliases;
|
||||
Aliases = aliases?.ToArray();
|
||||
Path = path;
|
||||
Overview = overview;
|
||||
TrailerUrl = trailerUrl;
|
||||
@ -88,7 +88,7 @@ namespace Kyoo.Models
|
||||
Poster = poster;
|
||||
Logo = logo;
|
||||
Backdrop = backdrop;
|
||||
ExternalIDs = externalIDs;
|
||||
ExternalIDs = externalIDs?.ToArray();
|
||||
}
|
||||
|
||||
public string GetID(string provider)
|
||||
|
@ -9,7 +9,7 @@ namespace Kyoo.Models
|
||||
public string Slug { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonIgnore] public virtual IEnumerable<Show> Shows { get; set; }
|
||||
[JsonIgnore] public virtual ICollection<Show> Shows { get; set; }
|
||||
|
||||
public Studio() { }
|
||||
|
||||
|
@ -6,7 +6,7 @@ using Kyoo.Models;
|
||||
|
||||
namespace Kyoo.Controllers
|
||||
{
|
||||
public abstract class ALibraryManager : ILibraryManager
|
||||
public class LibraryManager : ILibraryManager
|
||||
{
|
||||
public ILibraryRepository LibraryRepository { get; }
|
||||
public ILibraryItemRepository LibraryItemRepository { get; }
|
||||
@ -20,7 +20,7 @@ namespace Kyoo.Controllers
|
||||
public IPeopleRepository PeopleRepository { get; }
|
||||
public IProviderRepository ProviderRepository { get; }
|
||||
|
||||
public ALibraryManager(ILibraryRepository libraryRepository,
|
||||
protected LibraryManager(ILibraryRepository libraryRepository,
|
||||
ILibraryItemRepository libraryItemRepository,
|
||||
ICollectionRepository collectionRepository,
|
||||
IShowRepository showRepository,
|
||||
@ -235,9 +235,12 @@ namespace Kyoo.Controllers
|
||||
return PeopleRepository.Get(where);
|
||||
}
|
||||
|
||||
public abstract Task Load<T, T2>(T obj, Expression<Func<T, T2>> member)
|
||||
public virtual Task Load<T, T2>(T obj, Expression<Func<T, T2>> member)
|
||||
where T : class, IResource
|
||||
where T2 : class;
|
||||
where T2 : class
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task<ICollection<Library>> GetLibraries(Expression<Func<Library, bool>> where = null,
|
||||
Sort<Library> sort = default,
|
||||
@ -544,7 +547,7 @@ namespace Kyoo.Controllers
|
||||
return PeopleRepository.Edit(people, resetOld);
|
||||
}
|
||||
|
||||
public Task DelteLibrary(Library library)
|
||||
public Task DeleteLibrary(Library library)
|
||||
{
|
||||
return LibraryRepository.Delete(library);
|
||||
}
|
||||
@ -589,7 +592,7 @@ namespace Kyoo.Controllers
|
||||
return PeopleRepository.Delete(people);
|
||||
}
|
||||
|
||||
public Task DelteLibrary(string library)
|
||||
public Task DeleteLibrary(string library)
|
||||
{
|
||||
return LibraryRepository.Delete(library);
|
||||
}
|
||||
@ -634,7 +637,7 @@ namespace Kyoo.Controllers
|
||||
return PeopleRepository.Delete(people);
|
||||
}
|
||||
|
||||
public Task DelteLibrary(int library)
|
||||
public Task DeleteLibrary(int library)
|
||||
{
|
||||
return LibraryRepository.Delete(library);
|
||||
}
|
@ -3,15 +3,16 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||
|
||||
namespace Kyoo.Controllers
|
||||
{
|
||||
public class LibraryManager : ALibraryManager
|
||||
public class TLibraryManager : LibraryManager
|
||||
{
|
||||
private readonly DatabaseContext _database;
|
||||
private readonly DbContext _database;
|
||||
|
||||
public LibraryManager(ILibraryRepository libraryRepository,
|
||||
public TLibraryManager(ILibraryRepository libraryRepository,
|
||||
ILibraryItemRepository libraryItemRepository,
|
||||
ICollectionRepository collectionRepository,
|
||||
IShowRepository showRepository,
|
||||
@ -22,7 +23,7 @@ namespace Kyoo.Controllers
|
||||
IStudioRepository studioRepository,
|
||||
IProviderRepository providerRepository,
|
||||
IPeopleRepository peopleRepository,
|
||||
DatabaseContext database)
|
||||
DbContext database)
|
||||
: base(libraryRepository,
|
||||
libraryItemRepository,
|
||||
collectionRepository,
|
@ -40,7 +40,7 @@ namespace Kyoo.Controllers
|
||||
}
|
||||
|
||||
private async Task<List<T>> GetMetadata<T>(
|
||||
Func<IMetadataProvider, Task<IEnumerable<T>>> providerCall,
|
||||
Func<IMetadataProvider, Task<ICollection<T>>> providerCall,
|
||||
Library library,
|
||||
string what)
|
||||
{
|
||||
@ -146,7 +146,7 @@ namespace Kyoo.Controllers
|
||||
return episode;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<PeopleRole>> GetPeople(Show show, Library library)
|
||||
public async Task<ICollection<PeopleRole>> GetPeople(Show show, Library library)
|
||||
{
|
||||
List<PeopleRole> people = await GetMetadata(
|
||||
provider => provider.GetPeople(show),
|
||||
|
@ -20,6 +20,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../Kyoo.Common/Kyoo.Common.csproj" />
|
||||
<ProjectReference Include="../Kyoo.CommonAPI/Kyoo.CommonAPI.csproj" />
|
||||
<PackageReference Include="IdentityServer4" Version="4.1.1" />
|
||||
<PackageReference Include="IdentityServer4.AspNetIdentity" Version="4.1.1" />
|
||||
<PackageReference Include="IdentityServer4.EntityFramework" Version="4.1.1" />
|
||||
@ -28,7 +30,6 @@
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.3" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.2" />
|
||||
<PackageReference Include="Portable.BouncyCastle" Version="1.8.9" />
|
||||
<ProjectReference Include="../Kyoo.Common/Kyoo.Common.csproj" />
|
||||
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
|
||||
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="5.0.3" />
|
||||
@ -45,7 +46,6 @@
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="5.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="5.0.3" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<ProjectReference Include="../Kyoo.CommonAPI/Kyoo.CommonAPI.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -44,7 +44,7 @@ namespace Kyoo
|
||||
NpgsqlConnection.GlobalTypeMapper.MapEnum<StreamType>();
|
||||
}
|
||||
|
||||
private readonly ValueComparer<IEnumerable<string>> _stringArrayComparer = new(
|
||||
private readonly ValueComparer<ICollection<string>> _stringArrayComparer = new(
|
||||
(l1, l2) => l1.SequenceEqual(l2),
|
||||
arr => arr.Aggregate(0, (i, s) => s.GetHashCode())
|
||||
);
|
||||
|
@ -8,18 +8,18 @@ namespace Kyoo.Models
|
||||
{
|
||||
[JsonIgnore] [NotMergable] public virtual ICollection<CollectionLink> Links { get; set; }
|
||||
[ExpressionRewrite(nameof(Links), nameof(CollectionLink.Child))]
|
||||
public override IEnumerable<Show> Shows
|
||||
public override ICollection<Show> Shows
|
||||
{
|
||||
get => Links?.Select(x => x.Child);
|
||||
get => Links?.Select(x => x.Child).ToList();
|
||||
set => Links = value?.Select(x => new CollectionLink(this, x)).ToList();
|
||||
}
|
||||
|
||||
[JsonIgnore] [NotMergable] public virtual ICollection<LibraryLink> LibraryLinks { get; set; }
|
||||
|
||||
[ExpressionRewrite(nameof(LibraryLinks), nameof(GenreLink.Child))]
|
||||
public override IEnumerable<Library> Libraries
|
||||
public override ICollection<Library> Libraries
|
||||
{
|
||||
get => LibraryLinks?.Select(x => x.Library);
|
||||
get => LibraryLinks?.Select(x => x.Library).ToList();
|
||||
set => LibraryLinks = value?.Select(x => new LibraryLink(x, this)).ToList();
|
||||
}
|
||||
|
||||
|
@ -9,9 +9,9 @@ namespace Kyoo.Models
|
||||
[JsonIgnore] [NotMergable] public virtual ICollection<GenreLink> Links { get; set; }
|
||||
|
||||
[ExpressionRewrite(nameof(Links), nameof(GenreLink.Child))]
|
||||
[JsonIgnore] [NotMergable] public override IEnumerable<Show> Shows
|
||||
[JsonIgnore] [NotMergable] public override ICollection<Show> Shows
|
||||
{
|
||||
get => Links?.Select(x => x.Parent);
|
||||
get => Links?.Select(x => x.Parent).ToList();
|
||||
set => Links = value?.Select(x => new GenreLink(x, this)).ToList();
|
||||
}
|
||||
|
||||
|
@ -8,25 +8,25 @@ namespace Kyoo.Models
|
||||
{
|
||||
[EditableRelation] [JsonIgnore] [NotMergable] public virtual ICollection<ProviderLink> ProviderLinks { get; set; }
|
||||
[ExpressionRewrite(nameof(ProviderLinks), nameof(ProviderLink.Child))]
|
||||
public override IEnumerable<ProviderID> Providers
|
||||
public override ICollection<ProviderID> Providers
|
||||
{
|
||||
get => ProviderLinks?.Select(x => x.Child);
|
||||
get => ProviderLinks?.Select(x => x.Child).ToList();
|
||||
set => ProviderLinks = value?.Select(x => new ProviderLink(x, this)).ToList();
|
||||
}
|
||||
|
||||
[JsonIgnore] [NotMergable] public virtual ICollection<LibraryLink> Links { get; set; }
|
||||
[ExpressionRewrite(nameof(Links), nameof(LibraryLink.Show))]
|
||||
public override IEnumerable<Show> Shows
|
||||
public override ICollection<Show> Shows
|
||||
{
|
||||
get => Links?.Where(x => x.Show != null).Select(x => x.Show);
|
||||
get => Links?.Where(x => x.Show != null).Select(x => x.Show).ToList();
|
||||
set => Links = Utility.MergeLists(
|
||||
value?.Select(x => new LibraryLink(this, x)),
|
||||
Links?.Where(x => x.Show == null))?.ToList();
|
||||
}
|
||||
[ExpressionRewrite(nameof(Links), nameof(LibraryLink.Collection))]
|
||||
public override IEnumerable<Collection> Collections
|
||||
public override ICollection<Collection> Collections
|
||||
{
|
||||
get => Links?.Where(x => x.Collection != null).Select(x => x.Collection);
|
||||
get => Links?.Where(x => x.Collection != null).Select(x => x.Collection).ToList();
|
||||
set => Links = Utility.MergeLists(
|
||||
value?.Select(x => new LibraryLink(this, x)),
|
||||
Links?.Where(x => x.Collection == null))?.ToList();
|
||||
|
@ -8,25 +8,25 @@ namespace Kyoo.Models
|
||||
{
|
||||
[EditableRelation] [JsonReadOnly] [NotMergable] public virtual ICollection<GenreLink> GenreLinks { get; set; }
|
||||
[ExpressionRewrite(nameof(GenreLinks), nameof(GenreLink.Child))]
|
||||
public override IEnumerable<Genre> Genres
|
||||
public override ICollection<Genre> Genres
|
||||
{
|
||||
get => GenreLinks?.Select(x => x.Child);
|
||||
get => GenreLinks?.Select(x => x.Child).ToList();
|
||||
set => GenreLinks = value?.Select(x => new GenreLink(this, x)).ToList();
|
||||
}
|
||||
|
||||
[JsonReadOnly] [NotMergable] public virtual ICollection<LibraryLink> LibraryLinks { get; set; }
|
||||
[ExpressionRewrite(nameof(LibraryLinks), nameof(LibraryLink.Library))]
|
||||
public override IEnumerable<Library> Libraries
|
||||
public override ICollection<Library> Libraries
|
||||
{
|
||||
get => LibraryLinks?.Select(x => x.Library);
|
||||
get => LibraryLinks?.Select(x => x.Library).ToList();
|
||||
set => LibraryLinks = value?.Select(x => new LibraryLink(x, this)).ToList();
|
||||
}
|
||||
|
||||
[JsonReadOnly] [NotMergable] public virtual ICollection<CollectionLink> CollectionLinks { get; set; }
|
||||
[ExpressionRewrite(nameof(CollectionLinks), nameof(CollectionLink.Parent))]
|
||||
public override IEnumerable<Collection> Collections
|
||||
public override ICollection<Collection> Collections
|
||||
{
|
||||
get => CollectionLinks?.Select(x => x.Parent);
|
||||
get => CollectionLinks?.Select(x => x.Parent).ToList();
|
||||
set => CollectionLinks = value?.Select(x => new CollectionLink(x, this)).ToList();
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ namespace Kyoo
|
||||
_ => null
|
||||
};
|
||||
|
||||
if (debug == null)
|
||||
if (debug == null && !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ENVIRONEMENT")))
|
||||
Console.WriteLine($"Invalid ENVIRONEMENT variable. Supported values are \"debug\" and \"prod\". Ignoring...");
|
||||
|
||||
Console.WriteLine($"Running as {Environment.UserName}.");
|
||||
|
@ -147,7 +147,7 @@ namespace Kyoo
|
||||
services.AddScoped<IGenreRepository, GenreRepository>();
|
||||
services.AddScoped<IProviderRepository, ProviderRepository>();
|
||||
|
||||
services.AddScoped<ILibraryManager, LibraryManager>();
|
||||
// services.AddScoped<ILibraryManager, LibraryManager>();
|
||||
services.AddSingleton<ITranscoder, Transcoder>();
|
||||
services.AddSingleton<IThumbnailsManager, ThumbnailsManager>();
|
||||
services.AddSingleton<IProviderManager, ProviderManager>();
|
||||
|
@ -75,9 +75,8 @@ namespace Kyoo.Controllers
|
||||
ICollection<Library> libraries = argument == null
|
||||
? await libraryManager.GetLibraries()
|
||||
: new [] { await libraryManager.GetLibrary(argument)};
|
||||
// TODO replace this grotesque way to load the providers.
|
||||
foreach (Library library in libraries)
|
||||
library.Providers = library.Providers;
|
||||
await libraryManager.Load(library, x => x.Providers);
|
||||
|
||||
foreach (Library library in libraries)
|
||||
await Scan(library, episodes, tracks, cancellationToken);
|
||||
@ -353,7 +352,7 @@ namespace Kyoo.Controllers
|
||||
return episode;
|
||||
}
|
||||
|
||||
private async Task<IEnumerable<Track>> GetTracks(Episode episode)
|
||||
private async Task<ICollection<Track>> GetTracks(Episode episode)
|
||||
{
|
||||
episode.Tracks = (await _transcoder.ExtractInfos(episode.Path))
|
||||
.Where(x => x.Type != StreamType.Font)
|
||||
|
@ -99,8 +99,8 @@ namespace Kyoo.Tasks
|
||||
if (subs)
|
||||
{
|
||||
// TODO handle external subtites.
|
||||
episode.Tracks = (await _transcoder!.ExtractInfos(episode.Path))
|
||||
.Where(x => x.Type != StreamType.Font);
|
||||
episode.Tracks = (await _transcoder!.ExtractInfos(episode.Path))
|
||||
.Where(x => x.Type != StreamType.Font).ToArray();
|
||||
await _library.EditEpisode(episode, false);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user