mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
LibraryRepository: Adding more tests
This commit is contained in:
parent
47f855bdb9
commit
4ae28f2594
@ -30,7 +30,7 @@ namespace Kyoo.Controllers
|
|||||||
/// Retrieve the local path of the poster of the given item.
|
/// Retrieve the local path of the poster of the given item.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item">The item to retrieve the poster from.</param>
|
/// <param name="item">The item to retrieve the poster from.</param>
|
||||||
/// <param name="imageID">The ID of the image. See <see cref="Thumbnails"/> for values.</param>
|
/// <param name="imageID">The ID of the image. See <see cref="Images"/> for values.</param>
|
||||||
/// <typeparam name="T">The type of the item</typeparam>
|
/// <typeparam name="T">The type of the item</typeparam>
|
||||||
/// <exception cref="NotSupportedException">If the type does not have a poster</exception>
|
/// <exception cref="NotSupportedException">If the type does not have a poster</exception>
|
||||||
/// <returns>The path of the poster for the given resource (it might or might not exists).</returns>
|
/// <returns>The path of the poster for the given resource (it might or might not exists).</returns>
|
||||||
|
@ -63,7 +63,7 @@ namespace Kyoo.Models
|
|||||||
/// This can be disabled using the internal query flag.
|
/// This can be disabled using the internal query flag.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SerializeAs("{HOST}/api/{Type:l}/{Slug}/poster")]
|
[SerializeAs("{HOST}/api/{Type:l}/{Slug}/poster")]
|
||||||
public string Poster => Images?.GetValueOrDefault(Thumbnails.Poster);
|
public string Poster => Images?.GetValueOrDefault(Models.Images.Poster);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The type of this item (ether a collection, a show or a movie).
|
/// The type of this item (ether a collection, a show or a movie).
|
||||||
|
@ -31,7 +31,7 @@ namespace Kyoo.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[SerializeAs("{HOST}/api/collection/{Slug}/poster")]
|
[SerializeAs("{HOST}/api/collection/{Slug}/poster")]
|
||||||
[Obsolete("Use Images instead of this, this is only kept for the API response.")]
|
[Obsolete("Use Images instead of this, this is only kept for the API response.")]
|
||||||
public string Poster => Images?.GetValueOrDefault(Thumbnails.Poster);
|
public string Poster => Images?.GetValueOrDefault(Models.Images.Poster);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The description of this collection.
|
/// The description of this collection.
|
||||||
|
@ -113,7 +113,7 @@ namespace Kyoo.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[SerializeAs("{HOST}/api/episodes/{Slug}/thumb")]
|
[SerializeAs("{HOST}/api/episodes/{Slug}/thumb")]
|
||||||
[Obsolete("Use Images instead of this, this is only kept for the API response.")]
|
[Obsolete("Use Images instead of this, this is only kept for the API response.")]
|
||||||
public string Thumb => Images?.GetValueOrDefault(Thumbnails.Thumbnail);
|
public string Thumb => Images?.GetValueOrDefault(Models.Images.Thumbnail);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The title of this episode.
|
/// The title of this episode.
|
||||||
|
@ -13,7 +13,7 @@ namespace Kyoo.Models
|
|||||||
/// The string value should be a path supported by the <see cref="IFileSystem"/>.
|
/// The string value should be a path supported by the <see cref="IFileSystem"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// An arbitrary index should not be used, instead use indexes from <see cref="Thumbnails"/>
|
/// An arbitrary index should not be used, instead use indexes from <see cref="Models.Images"/>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public Dictionary<int, string> Images { get; set; }
|
public Dictionary<int, string> Images { get; set; }
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ namespace Kyoo.Models
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// A class containing constant values for images. To be used as index of a <see cref="IThumbnails.Images"/>.
|
/// A class containing constant values for images. To be used as index of a <see cref="IThumbnails.Images"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class Thumbnails
|
public static class Images
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A poster is a 9/16 format image with the cover of the resource.
|
/// A poster is a 9/16 format image with the cover of the resource.
|
||||||
|
@ -30,7 +30,7 @@ namespace Kyoo.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[SerializeAs("{HOST}/api/people/{Slug}/poster")]
|
[SerializeAs("{HOST}/api/people/{Slug}/poster")]
|
||||||
[Obsolete("Use Images instead of this, this is only kept for the API response.")]
|
[Obsolete("Use Images instead of this, this is only kept for the API response.")]
|
||||||
public string Poster => Images?.GetValueOrDefault(Thumbnails.Poster);
|
public string Poster => Images?.GetValueOrDefault(Models.Images.Poster);
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
[EditableRelation] [LoadableRelation] public ICollection<MetadataID> ExternalIDs { get; set; }
|
[EditableRelation] [LoadableRelation] public ICollection<MetadataID> ExternalIDs { get; set; }
|
||||||
|
@ -32,7 +32,7 @@ namespace Kyoo.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[SerializeAs("{HOST}/api/providers/{Slug}/logo")]
|
[SerializeAs("{HOST}/api/providers/{Slug}/logo")]
|
||||||
[Obsolete("Use Images instead of this, this is only kept for the API response.")]
|
[Obsolete("Use Images instead of this, this is only kept for the API response.")]
|
||||||
public string Logo => Images?.GetValueOrDefault(Thumbnails.Logo);
|
public string Logo => Images?.GetValueOrDefault(Models.Images.Logo);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The list of libraries that uses this provider.
|
/// The list of libraries that uses this provider.
|
||||||
@ -56,7 +56,7 @@ namespace Kyoo.Models
|
|||||||
Name = name;
|
Name = name;
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Thumbnails.Logo] = logo
|
[Models.Images.Logo] = logo
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ namespace Kyoo.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[SerializeAs("{HOST}/api/seasons/{Slug}/thumb")]
|
[SerializeAs("{HOST}/api/seasons/{Slug}/thumb")]
|
||||||
[Obsolete("Use Images instead of this, this is only kept for the API response.")]
|
[Obsolete("Use Images instead of this, this is only kept for the API response.")]
|
||||||
public string Poster => Images?.GetValueOrDefault(Thumbnails.Poster);
|
public string Poster => Images?.GetValueOrDefault(Models.Images.Poster);
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
[EditableRelation] [LoadableRelation] public ICollection<MetadataID> ExternalIDs { get; set; }
|
[EditableRelation] [LoadableRelation] public ICollection<MetadataID> ExternalIDs { get; set; }
|
||||||
|
@ -47,7 +47,7 @@ namespace Kyoo.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// TODO for now, this is set to a youtube url. It should be cached and converted to a local file.
|
/// TODO for now, this is set to a youtube url. It should be cached and converted to a local file.
|
||||||
[Obsolete("Use Images instead of this, this is only kept for the API response.")]
|
[Obsolete("Use Images instead of this, this is only kept for the API response.")]
|
||||||
public string TrailerUrl => Images?.GetValueOrDefault(Thumbnails.Trailer);
|
public string TrailerUrl => Images?.GetValueOrDefault(Models.Images.Trailer);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The date this show started airing. It can be null if this is unknown.
|
/// The date this show started airing. It can be null if this is unknown.
|
||||||
@ -71,7 +71,7 @@ namespace Kyoo.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[SerializeAs("{HOST}/api/shows/{Slug}/poster")]
|
[SerializeAs("{HOST}/api/shows/{Slug}/poster")]
|
||||||
[Obsolete("Use Images instead of this, this is only kept for the API response.")]
|
[Obsolete("Use Images instead of this, this is only kept for the API response.")]
|
||||||
public string Poster => Images?.GetValueOrDefault(Thumbnails.Poster);
|
public string Poster => Images?.GetValueOrDefault(Models.Images.Poster);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The path of this show's logo.
|
/// The path of this show's logo.
|
||||||
@ -80,7 +80,7 @@ namespace Kyoo.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[SerializeAs("{HOST}/api/shows/{Slug}/logo")]
|
[SerializeAs("{HOST}/api/shows/{Slug}/logo")]
|
||||||
[Obsolete("Use Images instead of this, this is only kept for the API response.")]
|
[Obsolete("Use Images instead of this, this is only kept for the API response.")]
|
||||||
public string Logo => Images?.GetValueOrDefault(Thumbnails.Logo);
|
public string Logo => Images?.GetValueOrDefault(Models.Images.Logo);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The path of this show's backdrop.
|
/// The path of this show's backdrop.
|
||||||
@ -89,7 +89,7 @@ namespace Kyoo.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[SerializeAs("{HOST}/api/shows/{Slug}/backdrop")]
|
[SerializeAs("{HOST}/api/shows/{Slug}/backdrop")]
|
||||||
[Obsolete("Use Images instead of this, this is only kept for the API response.")]
|
[Obsolete("Use Images instead of this, this is only kept for the API response.")]
|
||||||
public string Backdrop => Images?.GetValueOrDefault(Thumbnails.Thumbnail);
|
public string Backdrop => Images?.GetValueOrDefault(Models.Images.Thumbnail);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// True if this show represent a movie, false otherwise.
|
/// True if this show represent a movie, false otherwise.
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Kyoo.Controllers;
|
using Kyoo.Controllers;
|
||||||
using Kyoo.Models;
|
using Kyoo.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using Xunit.Abstractions;
|
using Xunit.Abstractions;
|
||||||
|
|
||||||
@ -36,6 +39,39 @@ namespace Kyoo.Tests.Database
|
|||||||
_repository = Repositories.LibraryManager.LibraryRepository;
|
_repository = Repositories.LibraryManager.LibraryRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task CreateWithoutPathTest()
|
||||||
|
{
|
||||||
|
Library library = TestSample.GetNew<Library>();
|
||||||
|
library.Paths = null;
|
||||||
|
await Assert.ThrowsAsync<ArgumentException>(() => _repository.Create(library));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task CreateWithEmptySlugTest()
|
||||||
|
{
|
||||||
|
Library library = TestSample.GetNew<Library>();
|
||||||
|
library.Slug = "";
|
||||||
|
await Assert.ThrowsAsync<ArgumentException>(() => _repository.Create(library));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task CreateWithNumberSlugTest()
|
||||||
|
{
|
||||||
|
Library library = TestSample.GetNew<Library>();
|
||||||
|
library.Slug = "2";
|
||||||
|
Library ret = await _repository.Create(library);
|
||||||
|
Assert.Equal("2!", library.Slug);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task CreateWithoutNameTest()
|
||||||
|
{
|
||||||
|
Library library = TestSample.GetNew<Library>();
|
||||||
|
library.Name = null;
|
||||||
|
await Assert.ThrowsAsync<ArgumentException>(() => _repository.Create(library));
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task CreateWithProvider()
|
public async Task CreateWithProvider()
|
||||||
{
|
{
|
||||||
@ -47,5 +83,76 @@ namespace Kyoo.Tests.Database
|
|||||||
Assert.Equal(1, retrieved.Providers.Count);
|
Assert.Equal(1, retrieved.Providers.Count);
|
||||||
Assert.Equal(TestSample.Get<Provider>().Slug, retrieved.Providers.First().Slug);
|
Assert.Equal(TestSample.Get<Provider>().Slug, retrieved.Providers.First().Slug);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task EditTest()
|
||||||
|
{
|
||||||
|
Library value = await _repository.Get(TestSample.Get<Library>().Slug);
|
||||||
|
value.Paths = new [] {"/super", "/test"};
|
||||||
|
value.Name = "New Title";
|
||||||
|
Library edited = await _repository.Edit(value, false);
|
||||||
|
|
||||||
|
await using DatabaseContext database = Repositories.Context.New();
|
||||||
|
Library show = await database.Libraries.FirstAsync();
|
||||||
|
|
||||||
|
KAssert.DeepEqual(show, edited);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task EditProvidersTest()
|
||||||
|
{
|
||||||
|
Library value = await _repository.Get(TestSample.Get<Library>().Slug);
|
||||||
|
value.Providers = new[]
|
||||||
|
{
|
||||||
|
TestSample.GetNew<Provider>()
|
||||||
|
};
|
||||||
|
Library edited = await _repository.Edit(value, false);
|
||||||
|
|
||||||
|
await using DatabaseContext database = Repositories.Context.New();
|
||||||
|
Library show = await database.Libraries
|
||||||
|
.Include(x => x.Providers)
|
||||||
|
.FirstAsync();
|
||||||
|
|
||||||
|
show.Providers.ForEach(x => x.Libraries = null);
|
||||||
|
edited.Providers.ForEach(x => x.Libraries = null);
|
||||||
|
KAssert.DeepEqual(show, edited);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task AddProvidersTest()
|
||||||
|
{
|
||||||
|
Library value = await _repository.Get(TestSample.Get<Library>().Slug);
|
||||||
|
await Repositories.LibraryManager.Load(value, x => x.Providers);
|
||||||
|
value.Providers.Add(TestSample.GetNew<Provider>());
|
||||||
|
Library edited = await _repository.Edit(value, false);
|
||||||
|
|
||||||
|
await using DatabaseContext database = Repositories.Context.New();
|
||||||
|
Library show = await database.Libraries
|
||||||
|
.Include(x => x.Providers)
|
||||||
|
.FirstAsync();
|
||||||
|
|
||||||
|
show.Providers.ForEach(x => x.Libraries = null);
|
||||||
|
edited.Providers.ForEach(x => x.Libraries = null);
|
||||||
|
KAssert.DeepEqual(show, edited);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Theory]
|
||||||
|
[InlineData("test")]
|
||||||
|
[InlineData("super")]
|
||||||
|
[InlineData("title")]
|
||||||
|
[InlineData("TiTlE")]
|
||||||
|
[InlineData("SuPeR")]
|
||||||
|
public async Task SearchTest(string query)
|
||||||
|
{
|
||||||
|
Library value = new()
|
||||||
|
{
|
||||||
|
Slug = "super-test",
|
||||||
|
Name = "This is a test title",
|
||||||
|
Paths = new [] {"path"}
|
||||||
|
};
|
||||||
|
await _repository.Create(value);
|
||||||
|
ICollection<Library> ret = await _repository.Search(query);
|
||||||
|
KAssert.DeepEqual(value, ret.First());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -31,13 +31,26 @@ namespace Kyoo.Tests
|
|||||||
EndAir = new DateTime(2011, 1, 1),
|
EndAir = new DateTime(2011, 1, 1),
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Thumbnails.Poster] = "Poster",
|
[Images.Poster] = "Poster",
|
||||||
[Thumbnails.Logo] = "Logo",
|
[Images.Logo] = "Logo",
|
||||||
[Thumbnails.Thumbnail] = "Thumbnail"
|
[Images.Thumbnail] = "Thumbnail"
|
||||||
},
|
},
|
||||||
IsMovie = false,
|
IsMovie = false,
|
||||||
Studio = null
|
Studio = null
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
typeof(Provider),
|
||||||
|
() => new Provider
|
||||||
|
{
|
||||||
|
ID = 2,
|
||||||
|
Slug = "new-provider",
|
||||||
|
Name = "Provider NewSample",
|
||||||
|
Images = new Dictionary<int, string>
|
||||||
|
{
|
||||||
|
[Images.Logo] = "logo"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -64,7 +77,7 @@ namespace Kyoo.Tests
|
|||||||
Overview = "A nice collection for tests",
|
Overview = "A nice collection for tests",
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Thumbnails.Poster] = "Poster"
|
[Images.Poster] = "Poster"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -90,9 +103,9 @@ namespace Kyoo.Tests
|
|||||||
EndAir = new DateTime(2011, 1, 1),
|
EndAir = new DateTime(2011, 1, 1),
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Thumbnails.Poster] = "Poster",
|
[Images.Poster] = "Poster",
|
||||||
[Thumbnails.Logo] = "Logo",
|
[Images.Logo] = "Logo",
|
||||||
[Thumbnails.Thumbnail] = "Thumbnail"
|
[Images.Thumbnail] = "Thumbnail"
|
||||||
},
|
},
|
||||||
IsMovie = false,
|
IsMovie = false,
|
||||||
Studio = null
|
Studio = null
|
||||||
@ -112,9 +125,9 @@ namespace Kyoo.Tests
|
|||||||
EndDate = new DateTime(2020, 07, 05),
|
EndDate = new DateTime(2020, 07, 05),
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Thumbnails.Poster] = "Poster",
|
[Images.Poster] = "Poster",
|
||||||
[Thumbnails.Logo] = "Logo",
|
[Images.Logo] = "Logo",
|
||||||
[Thumbnails.Thumbnail] = "Thumbnail"
|
[Images.Thumbnail] = "Thumbnail"
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -132,9 +145,9 @@ namespace Kyoo.Tests
|
|||||||
Path = "/home/kyoo/anohana-s1e1",
|
Path = "/home/kyoo/anohana-s1e1",
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Thumbnails.Poster] = "Poster",
|
[Images.Poster] = "Poster",
|
||||||
[Thumbnails.Logo] = "Logo",
|
[Images.Logo] = "Logo",
|
||||||
[Thumbnails.Thumbnail] = "Thumbnail"
|
[Images.Thumbnail] = "Thumbnail"
|
||||||
},
|
},
|
||||||
Title = "Episode 1",
|
Title = "Episode 1",
|
||||||
Overview = "Summary of the first episode",
|
Overview = "Summary of the first episode",
|
||||||
@ -168,9 +181,9 @@ namespace Kyoo.Tests
|
|||||||
Name = "The Actor",
|
Name = "The Actor",
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Thumbnails.Poster] = "Poster",
|
[Images.Poster] = "Poster",
|
||||||
[Thumbnails.Logo] = "Logo",
|
[Images.Logo] = "Logo",
|
||||||
[Thumbnails.Thumbnail] = "Thumbnail"
|
[Images.Thumbnail] = "Thumbnail"
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -201,9 +214,9 @@ namespace Kyoo.Tests
|
|||||||
Name = "The TVDB",
|
Name = "The TVDB",
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Thumbnails.Poster] = "Poster",
|
[Images.Poster] = "Poster",
|
||||||
[Thumbnails.Logo] = "path/tvdb.svg",
|
[Images.Logo] = "path/tvdb.svg",
|
||||||
[Thumbnails.Thumbnail] = "Thumbnail"
|
[Images.Thumbnail] = "Thumbnail"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -306,9 +319,9 @@ namespace Kyoo.Tests
|
|||||||
Path = "/home/kyoo/anohana-3",
|
Path = "/home/kyoo/anohana-3",
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Thumbnails.Poster] = "Poster",
|
[Images.Poster] = "Poster",
|
||||||
[Thumbnails.Logo] = "Logo",
|
[Images.Logo] = "Logo",
|
||||||
[Thumbnails.Thumbnail] = "Thumbnail"
|
[Images.Thumbnail] = "Thumbnail"
|
||||||
},
|
},
|
||||||
Title = "Episode 3",
|
Title = "Episode 3",
|
||||||
Overview = "Summary of the third absolute episode",
|
Overview = "Summary of the third absolute episode",
|
||||||
@ -326,9 +339,9 @@ namespace Kyoo.Tests
|
|||||||
Path = "/home/kyoo/john-wick",
|
Path = "/home/kyoo/john-wick",
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Thumbnails.Poster] = "Poster",
|
[Images.Poster] = "Poster",
|
||||||
[Thumbnails.Logo] = "Logo",
|
[Images.Logo] = "Logo",
|
||||||
[Thumbnails.Thumbnail] = "Thumbnail"
|
[Images.Thumbnail] = "Thumbnail"
|
||||||
},
|
},
|
||||||
Title = "John wick",
|
Title = "John wick",
|
||||||
Overview = "A movie episode test",
|
Overview = "A movie episode test",
|
||||||
|
@ -32,7 +32,7 @@ namespace Kyoo.Tests.Identifier.Tvdb
|
|||||||
Assert.Equal("Aliases", show.Aliases[0]);
|
Assert.Equal("Aliases", show.Aliases[0]);
|
||||||
Assert.Equal("overview", show.Overview);
|
Assert.Equal("overview", show.Overview);
|
||||||
Assert.Equal(new DateTime(2021, 7, 23), show.StartAir);
|
Assert.Equal(new DateTime(2021, 7, 23), show.StartAir);
|
||||||
Assert.Equal("https://www.thetvdb.com/poster", show.Poster);
|
Assert.Equal("https://www.thetvdb.com/poster", show.Images[Images.Poster]);
|
||||||
Assert.Single(show.ExternalIDs);
|
Assert.Single(show.ExternalIDs);
|
||||||
Assert.Equal("5", show.ExternalIDs.First().DataID);
|
Assert.Equal("5", show.ExternalIDs.First().DataID);
|
||||||
Assert.Equal(provider, show.ExternalIDs.First().Provider);
|
Assert.Equal(provider, show.ExternalIDs.First().Provider);
|
||||||
@ -63,7 +63,7 @@ namespace Kyoo.Tests.Identifier.Tvdb
|
|||||||
Assert.Equal("Aliases", show.Aliases[0]);
|
Assert.Equal("Aliases", show.Aliases[0]);
|
||||||
Assert.Equal("overview", show.Overview);
|
Assert.Equal("overview", show.Overview);
|
||||||
Assert.Null(show.StartAir);
|
Assert.Null(show.StartAir);
|
||||||
Assert.Equal("https://www.thetvdb.com/poster", show.Poster);
|
Assert.Equal("https://www.thetvdb.com/poster", show.Images[Images.Poster]);
|
||||||
Assert.Single(show.ExternalIDs);
|
Assert.Single(show.ExternalIDs);
|
||||||
Assert.Equal("5", show.ExternalIDs.First().DataID);
|
Assert.Equal("5", show.ExternalIDs.First().DataID);
|
||||||
Assert.Equal(provider, show.ExternalIDs.First().Provider);
|
Assert.Equal(provider, show.ExternalIDs.First().Provider);
|
||||||
@ -100,8 +100,8 @@ namespace Kyoo.Tests.Identifier.Tvdb
|
|||||||
Assert.Equal("Aliases", show.Aliases[0]);
|
Assert.Equal("Aliases", show.Aliases[0]);
|
||||||
Assert.Equal("overview", show.Overview);
|
Assert.Equal("overview", show.Overview);
|
||||||
Assert.Equal(new DateTime(2021, 7, 23), show.StartAir);
|
Assert.Equal(new DateTime(2021, 7, 23), show.StartAir);
|
||||||
Assert.Equal("https://www.thetvdb.com/banners/poster", show.Poster);
|
Assert.Equal("https://www.thetvdb.com/banners/poster", show.Images[Images.Poster]);
|
||||||
Assert.Equal("https://www.thetvdb.com/banners/fanart", show.Backdrop);
|
Assert.Equal("https://www.thetvdb.com/banners/fanart", show.Images[Images.Thumbnail]);
|
||||||
Assert.Single(show.ExternalIDs);
|
Assert.Single(show.ExternalIDs);
|
||||||
Assert.Equal("5", show.ExternalIDs.First().DataID);
|
Assert.Equal("5", show.ExternalIDs.First().DataID);
|
||||||
Assert.Equal(provider, show.ExternalIDs.First().Provider);
|
Assert.Equal(provider, show.ExternalIDs.First().Provider);
|
||||||
@ -130,7 +130,7 @@ namespace Kyoo.Tests.Identifier.Tvdb
|
|||||||
Assert.Equal("name", people.Slug);
|
Assert.Equal("name", people.Slug);
|
||||||
Assert.Equal("Name", people.People.Name);
|
Assert.Equal("Name", people.People.Name);
|
||||||
Assert.Equal("role", people.Role);
|
Assert.Equal("role", people.Role);
|
||||||
Assert.Equal("https://www.thetvdb.com/banners/image", people.People.Poster);
|
Assert.Equal("https://www.thetvdb.com/banners/image", people.People.Images[Images.Poster]);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@ -154,7 +154,7 @@ namespace Kyoo.Tests.Identifier.Tvdb
|
|||||||
Assert.Equal(3, episode.EpisodeNumber);
|
Assert.Equal(3, episode.EpisodeNumber);
|
||||||
Assert.Equal(23, episode.AbsoluteNumber);
|
Assert.Equal(23, episode.AbsoluteNumber);
|
||||||
Assert.Equal("overview", episode.Overview);
|
Assert.Equal("overview", episode.Overview);
|
||||||
Assert.Equal("https://www.thetvdb.com/banners/thumb", episode.Thumb);
|
Assert.Equal("https://www.thetvdb.com/banners/thumb", episode.Images[Images.Thumbnail]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -24,10 +24,10 @@ namespace Kyoo.TheMovieDb
|
|||||||
Overview = collection.Overview,
|
Overview = collection.Overview,
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Thumbnails.Poster] = collection.PosterPath != null
|
[Images.Poster] = collection.PosterPath != null
|
||||||
? $"https://image.tmdb.org/t/p/original{collection.PosterPath}"
|
? $"https://image.tmdb.org/t/p/original{collection.PosterPath}"
|
||||||
: null,
|
: null,
|
||||||
[Thumbnails.Thumbnail] = collection.BackdropPath != null
|
[Images.Thumbnail] = collection.BackdropPath != null
|
||||||
? $"https://image.tmdb.org/t/p/original{collection.BackdropPath}"
|
? $"https://image.tmdb.org/t/p/original{collection.BackdropPath}"
|
||||||
: null
|
: null
|
||||||
},
|
},
|
||||||
@ -57,10 +57,10 @@ namespace Kyoo.TheMovieDb
|
|||||||
Name = collection.Name,
|
Name = collection.Name,
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Thumbnails.Poster] = collection.PosterPath != null
|
[Images.Poster] = collection.PosterPath != null
|
||||||
? $"https://image.tmdb.org/t/p/original{collection.PosterPath}"
|
? $"https://image.tmdb.org/t/p/original{collection.PosterPath}"
|
||||||
: null,
|
: null,
|
||||||
[Thumbnails.Thumbnail] = collection.BackdropPath != null
|
[Images.Thumbnail] = collection.BackdropPath != null
|
||||||
? $"https://image.tmdb.org/t/p/original{collection.BackdropPath}"
|
? $"https://image.tmdb.org/t/p/original{collection.BackdropPath}"
|
||||||
: null
|
: null
|
||||||
},
|
},
|
||||||
|
@ -27,7 +27,7 @@ namespace Kyoo.TheMovieDb
|
|||||||
ReleaseDate = episode.AirDate,
|
ReleaseDate = episode.AirDate,
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Thumbnails.Thumbnail] = episode.StillPath != null
|
[Images.Thumbnail] = episode.StillPath != null
|
||||||
? $"https://image.tmdb.org/t/p/original{episode.StillPath}"
|
? $"https://image.tmdb.org/t/p/original{episode.StillPath}"
|
||||||
: null
|
: null
|
||||||
},
|
},
|
||||||
|
@ -30,13 +30,13 @@ namespace Kyoo.TheMovieDb
|
|||||||
EndAir = movie.ReleaseDate,
|
EndAir = movie.ReleaseDate,
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Thumbnails.Poster] = movie.PosterPath != null
|
[Images.Poster] = movie.PosterPath != null
|
||||||
? $"https://image.tmdb.org/t/p/original{movie.PosterPath}"
|
? $"https://image.tmdb.org/t/p/original{movie.PosterPath}"
|
||||||
: null,
|
: null,
|
||||||
[Thumbnails.Thumbnail] = movie.BackdropPath != null
|
[Images.Thumbnail] = movie.BackdropPath != null
|
||||||
? $"https://image.tmdb.org/t/p/original{movie.BackdropPath}"
|
? $"https://image.tmdb.org/t/p/original{movie.BackdropPath}"
|
||||||
: null,
|
: null,
|
||||||
[Thumbnails.Trailer] = movie.Videos?.Results
|
[Images.Trailer] = movie.Videos?.Results
|
||||||
.Where(x => x.Type is "Trailer" or "Teaser" && x.Site == "YouTube")
|
.Where(x => x.Type is "Trailer" or "Teaser" && x.Site == "YouTube")
|
||||||
.Select(x => "https://www.youtube.com/watch?v=" + x.Key).FirstOrDefault(),
|
.Select(x => "https://www.youtube.com/watch?v=" + x.Key).FirstOrDefault(),
|
||||||
},
|
},
|
||||||
@ -78,10 +78,10 @@ namespace Kyoo.TheMovieDb
|
|||||||
EndAir = movie.ReleaseDate,
|
EndAir = movie.ReleaseDate,
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Thumbnails.Poster] = movie.PosterPath != null
|
[Images.Poster] = movie.PosterPath != null
|
||||||
? $"https://image.tmdb.org/t/p/original{movie.PosterPath}"
|
? $"https://image.tmdb.org/t/p/original{movie.PosterPath}"
|
||||||
: null,
|
: null,
|
||||||
[Thumbnails.Thumbnail] = movie.BackdropPath != null
|
[Images.Thumbnail] = movie.BackdropPath != null
|
||||||
? $"https://image.tmdb.org/t/p/original{movie.BackdropPath}"
|
? $"https://image.tmdb.org/t/p/original{movie.BackdropPath}"
|
||||||
: null,
|
: null,
|
||||||
},
|
},
|
||||||
|
@ -3,6 +3,7 @@ using Kyoo.Models;
|
|||||||
using TMDbLib.Objects.General;
|
using TMDbLib.Objects.General;
|
||||||
using TMDbLib.Objects.People;
|
using TMDbLib.Objects.People;
|
||||||
using TMDbLib.Objects.Search;
|
using TMDbLib.Objects.Search;
|
||||||
|
using Images = Kyoo.Models.Images;
|
||||||
using TvCast = TMDbLib.Objects.TvShows.Cast;
|
using TvCast = TMDbLib.Objects.TvShows.Cast;
|
||||||
using MovieCast = TMDbLib.Objects.Movies.Cast;
|
using MovieCast = TMDbLib.Objects.Movies.Cast;
|
||||||
|
|
||||||
@ -29,7 +30,7 @@ namespace Kyoo.TheMovieDb
|
|||||||
Name = cast.Name,
|
Name = cast.Name,
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Thumbnails.Poster] = cast.ProfilePath != null
|
[Images.Poster] = cast.ProfilePath != null
|
||||||
? $"https://image.tmdb.org/t/p/original{cast.ProfilePath}"
|
? $"https://image.tmdb.org/t/p/original{cast.ProfilePath}"
|
||||||
: null
|
: null
|
||||||
},
|
},
|
||||||
@ -64,7 +65,7 @@ namespace Kyoo.TheMovieDb
|
|||||||
Name = cast.Name,
|
Name = cast.Name,
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Thumbnails.Poster] = cast.ProfilePath != null
|
[Images.Poster] = cast.ProfilePath != null
|
||||||
? $"https://image.tmdb.org/t/p/original{cast.ProfilePath}"
|
? $"https://image.tmdb.org/t/p/original{cast.ProfilePath}"
|
||||||
: null
|
: null
|
||||||
},
|
},
|
||||||
@ -99,7 +100,7 @@ namespace Kyoo.TheMovieDb
|
|||||||
Name = crew.Name,
|
Name = crew.Name,
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Thumbnails.Poster] = crew.ProfilePath != null
|
[Images.Poster] = crew.ProfilePath != null
|
||||||
? $"https://image.tmdb.org/t/p/original{crew.ProfilePath}"
|
? $"https://image.tmdb.org/t/p/original{crew.ProfilePath}"
|
||||||
: null
|
: null
|
||||||
},
|
},
|
||||||
@ -132,7 +133,7 @@ namespace Kyoo.TheMovieDb
|
|||||||
Name = person.Name,
|
Name = person.Name,
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Thumbnails.Poster] = person.ProfilePath != null
|
[Images.Poster] = person.ProfilePath != null
|
||||||
? $"https://image.tmdb.org/t/p/original{person.ProfilePath}"
|
? $"https://image.tmdb.org/t/p/original{person.ProfilePath}"
|
||||||
: null
|
: null
|
||||||
},
|
},
|
||||||
@ -162,7 +163,7 @@ namespace Kyoo.TheMovieDb
|
|||||||
Name = person.Name,
|
Name = person.Name,
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Thumbnails.Poster] = person.ProfilePath != null
|
[Images.Poster] = person.ProfilePath != null
|
||||||
? $"https://image.tmdb.org/t/p/original{person.ProfilePath}"
|
? $"https://image.tmdb.org/t/p/original{person.ProfilePath}"
|
||||||
: null
|
: null
|
||||||
},
|
},
|
||||||
|
@ -26,7 +26,7 @@ namespace Kyoo.TheMovieDb
|
|||||||
StartDate = season.AirDate,
|
StartDate = season.AirDate,
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Thumbnails.Poster] = season.PosterPath != null
|
[Images.Poster] = season.PosterPath != null
|
||||||
? $"https://image.tmdb.org/t/p/original{season.PosterPath}"
|
? $"https://image.tmdb.org/t/p/original{season.PosterPath}"
|
||||||
: null
|
: null
|
||||||
},
|
},
|
||||||
|
@ -30,13 +30,13 @@ namespace Kyoo.TheMovieDb
|
|||||||
EndAir = tv.LastAirDate,
|
EndAir = tv.LastAirDate,
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Thumbnails.Poster] = tv.PosterPath != null
|
[Images.Poster] = tv.PosterPath != null
|
||||||
? $"https://image.tmdb.org/t/p/original{tv.PosterPath}"
|
? $"https://image.tmdb.org/t/p/original{tv.PosterPath}"
|
||||||
: null,
|
: null,
|
||||||
[Thumbnails.Thumbnail] = tv.BackdropPath != null
|
[Images.Thumbnail] = tv.BackdropPath != null
|
||||||
? $"https://image.tmdb.org/t/p/original{tv.BackdropPath}"
|
? $"https://image.tmdb.org/t/p/original{tv.BackdropPath}"
|
||||||
: null,
|
: null,
|
||||||
[Thumbnails.Trailer] = tv.Videos?.Results
|
[Images.Trailer] = tv.Videos?.Results
|
||||||
.Where(x => x.Type is "Trailer" or "Teaser" && x.Site == "YouTube")
|
.Where(x => x.Type is "Trailer" or "Teaser" && x.Site == "YouTube")
|
||||||
.Select(x => "https://www.youtube.com/watch?v=" + x.Key).FirstOrDefault()
|
.Select(x => "https://www.youtube.com/watch?v=" + x.Key).FirstOrDefault()
|
||||||
},
|
},
|
||||||
@ -76,10 +76,10 @@ namespace Kyoo.TheMovieDb
|
|||||||
StartAir = tv.FirstAirDate,
|
StartAir = tv.FirstAirDate,
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Thumbnails.Poster] = tv.PosterPath != null
|
[Images.Poster] = tv.PosterPath != null
|
||||||
? $"https://image.tmdb.org/t/p/original{tv.PosterPath}"
|
? $"https://image.tmdb.org/t/p/original{tv.PosterPath}"
|
||||||
: null,
|
: null,
|
||||||
[Thumbnails.Thumbnail] = tv.BackdropPath != null
|
[Images.Thumbnail] = tv.BackdropPath != null
|
||||||
? $"https://image.tmdb.org/t/p/original{tv.BackdropPath}"
|
? $"https://image.tmdb.org/t/p/original{tv.BackdropPath}"
|
||||||
: null,
|
: null,
|
||||||
},
|
},
|
||||||
|
@ -35,7 +35,7 @@ namespace Kyoo.TheMovieDb
|
|||||||
Name = "TheMovieDB",
|
Name = "TheMovieDB",
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Thumbnails.Logo] = "https://www.themoviedb.org/assets/2/v4/logos/v2/" +
|
[Images.Logo] = "https://www.themoviedb.org/assets/2/v4/logos/v2/" +
|
||||||
"blue_short-8e7b30f73a4020692ccca9c88bafe5dcb6f8a62a4c6bc55cd9ba82bb2cd95f6c.svg"
|
"blue_short-8e7b30f73a4020692ccca9c88bafe5dcb6f8a62a4c6bc55cd9ba82bb2cd95f6c.svg"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -58,7 +58,7 @@ namespace Kyoo.TheTvdb
|
|||||||
StartAir = _ParseDate(result.FirstAired),
|
StartAir = _ParseDate(result.FirstAired),
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Thumbnails.Poster] = result.Poster != null
|
[Images.Poster] = result.Poster != null
|
||||||
? $"https://www.thetvdb.com{result.Poster}"
|
? $"https://www.thetvdb.com{result.Poster}"
|
||||||
: null,
|
: null,
|
||||||
},
|
},
|
||||||
@ -92,10 +92,10 @@ namespace Kyoo.TheTvdb
|
|||||||
StartAir = _ParseDate(series.FirstAired),
|
StartAir = _ParseDate(series.FirstAired),
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Thumbnails.Poster] = series.Poster != null
|
[Images.Poster] = series.Poster != null
|
||||||
? $"https://www.thetvdb.com/banners/{series.Poster}"
|
? $"https://www.thetvdb.com/banners/{series.Poster}"
|
||||||
: null,
|
: null,
|
||||||
[Thumbnails.Thumbnail] = series.FanArt != null
|
[Images.Thumbnail] = series.FanArt != null
|
||||||
? $"https://www.thetvdb.com/banners/{series.FanArt}"
|
? $"https://www.thetvdb.com/banners/{series.FanArt}"
|
||||||
: null
|
: null
|
||||||
},
|
},
|
||||||
@ -128,7 +128,7 @@ namespace Kyoo.TheTvdb
|
|||||||
Name = actor.Name,
|
Name = actor.Name,
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Thumbnails.Poster] = actor.Image != null
|
[Images.Poster] = actor.Image != null
|
||||||
? $"https://www.thetvdb.com/banners/{actor.Image}"
|
? $"https://www.thetvdb.com/banners/{actor.Image}"
|
||||||
: null
|
: null
|
||||||
},
|
},
|
||||||
@ -164,7 +164,7 @@ namespace Kyoo.TheTvdb
|
|||||||
Overview = episode.Overview,
|
Overview = episode.Overview,
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Thumbnails.Thumbnail] = episode.Filename != null
|
[Images.Thumbnail] = episode.Filename != null
|
||||||
? $"https://www.thetvdb.com/banners/{episode.Filename}"
|
? $"https://www.thetvdb.com/banners/{episode.Filename}"
|
||||||
: null
|
: null
|
||||||
},
|
},
|
||||||
|
@ -34,7 +34,7 @@ namespace Kyoo.TheTvdb
|
|||||||
Name = "TheTVDB",
|
Name = "TheTVDB",
|
||||||
Images = new Dictionary<int, string>
|
Images = new Dictionary<int, string>
|
||||||
{
|
{
|
||||||
[Thumbnails.Logo] = "https://www.thetvdb.com/images/logo.png"
|
[Images.Logo] = "https://www.thetvdb.com/images/logo.png"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ namespace Kyoo.Controllers
|
|||||||
public override async Task<ICollection<Library>> Search(string query)
|
public override async Task<ICollection<Library>> Search(string query)
|
||||||
{
|
{
|
||||||
return await _database.Libraries
|
return await _database.Libraries
|
||||||
.Where(_database.Like<Library>(x => x.Name, $"%{query}%"))
|
.Where(_database.Like<Library>(x => x.Name + " " + x.Slug, $"%{query}%"))
|
||||||
.OrderBy(DefaultSort)
|
.OrderBy(DefaultSort)
|
||||||
.Take(20)
|
.Take(20)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
@ -54,8 +54,6 @@ namespace Kyoo.Controllers
|
|||||||
{
|
{
|
||||||
await base.Create(obj);
|
await base.Create(obj);
|
||||||
_database.Entry(obj).State = EntityState.Added;
|
_database.Entry(obj).State = EntityState.Added;
|
||||||
if (obj.Providers != null)
|
|
||||||
_database.AttachRange(obj.Providers);
|
|
||||||
await _database.SaveChangesAsync($"Trying to insert a duplicated library (slug {obj.Slug} already exists).");
|
await _database.SaveChangesAsync($"Trying to insert a duplicated library (slug {obj.Slug} already exists).");
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
@ -64,27 +62,30 @@ namespace Kyoo.Controllers
|
|||||||
protected override async Task Validate(Library resource)
|
protected override async Task Validate(Library resource)
|
||||||
{
|
{
|
||||||
await base.Validate(resource);
|
await base.Validate(resource);
|
||||||
if (resource.Providers != null)
|
|
||||||
{
|
|
||||||
resource.Providers = await resource.Providers
|
|
||||||
.SelectAsync(x => _providers.CreateIfNotExists(x))
|
|
||||||
.ToListAsync();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override async Task EditRelations(Library resource, Library changed, bool resetOld)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(resource.Slug))
|
if (string.IsNullOrEmpty(resource.Slug))
|
||||||
throw new ArgumentException("The library's slug must be set and not empty");
|
throw new ArgumentException("The library's slug must be set and not empty");
|
||||||
if (string.IsNullOrEmpty(resource.Name))
|
if (string.IsNullOrEmpty(resource.Name))
|
||||||
throw new ArgumentException("The library's name must be set and not empty");
|
throw new ArgumentException("The library's name must be set and not empty");
|
||||||
if (resource.Paths == null || !resource.Paths.Any())
|
if (resource.Paths == null || !resource.Paths.Any())
|
||||||
throw new ArgumentException("The library should have a least one path.");
|
throw new ArgumentException("The library should have a least one path.");
|
||||||
|
|
||||||
|
if (resource.Providers != null)
|
||||||
|
{
|
||||||
|
resource.Providers = await resource.Providers
|
||||||
|
.SelectAsync(x => _providers.CreateIfNotExists(x))
|
||||||
|
.ToListAsync();
|
||||||
|
_database.AttachRange(resource.Providers);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override async Task EditRelations(Library resource, Library changed, bool resetOld)
|
||||||
|
{
|
||||||
|
await Validate(changed);
|
||||||
|
|
||||||
if (changed.Providers != null || resetOld)
|
if (changed.Providers != null || resetOld)
|
||||||
{
|
{
|
||||||
await Validate(changed);
|
|
||||||
await Database.Entry(resource).Collection(x => x.Providers).LoadAsync();
|
await Database.Entry(resource).Collection(x => x.Providers).LoadAsync();
|
||||||
resource.Providers = changed.Providers;
|
resource.Providers = changed.Providers;
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,6 @@ namespace Kyoo.Controllers
|
|||||||
Pagination limit = default)
|
Pagination limit = default)
|
||||||
where T : class, IMetadata
|
where T : class, IMetadata
|
||||||
{
|
{
|
||||||
string discriminator = typeof(T).Name;
|
|
||||||
return ApplyFilters(_database.MetadataIds<T>()
|
return ApplyFilters(_database.MetadataIds<T>()
|
||||||
.Include(y => y.Provider),
|
.Include(y => y.Provider),
|
||||||
x => _database.MetadataIds<T>().FirstOrDefaultAsync(y => y.ResourceID == x),
|
x => _database.MetadataIds<T>().FirstOrDefaultAsync(y => y.ResourceID == x),
|
||||||
|
@ -113,9 +113,9 @@ namespace Kyoo.Controllers
|
|||||||
// TODO handle extensions
|
// TODO handle extensions
|
||||||
string imageName = imageID switch
|
string imageName = imageID switch
|
||||||
{
|
{
|
||||||
Thumbnails.Poster => "poster.jpg",
|
Images.Poster => "poster.jpg",
|
||||||
Thumbnails.Logo => "logo.jpg",
|
Images.Logo => "logo.jpg",
|
||||||
Thumbnails.Thumbnail => "thumbnail.jpg",
|
Images.Thumbnail => "thumbnail.jpg",
|
||||||
_ => $"{imageID}.jpg"
|
_ => $"{imageID}.jpg"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ namespace Kyoo.Api
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Episode episode = await _libraryManager.Get<Episode>(id);
|
Episode episode = await _libraryManager.Get<Episode>(id);
|
||||||
return _files.FileResult(await _thumbnails.GetImagePath(episode, Thumbnails.Thumbnail));
|
return _files.FileResult(await _thumbnails.GetImagePath(episode, Images.Thumbnail));
|
||||||
}
|
}
|
||||||
catch (ItemNotFoundException)
|
catch (ItemNotFoundException)
|
||||||
{
|
{
|
||||||
@ -210,7 +210,7 @@ namespace Kyoo.Api
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Episode episode = await _libraryManager.Get<Episode>(slug);
|
Episode episode = await _libraryManager.Get<Episode>(slug);
|
||||||
return _files.FileResult(await _thumbnails.GetImagePath(episode, Thumbnails.Thumbnail));
|
return _files.FileResult(await _thumbnails.GetImagePath(episode, Images.Thumbnail));
|
||||||
}
|
}
|
||||||
catch (ItemNotFoundException)
|
catch (ItemNotFoundException)
|
||||||
{
|
{
|
||||||
|
@ -94,7 +94,7 @@ namespace Kyoo.Api
|
|||||||
People people = await _libraryManager.GetOrDefault<People>(id);
|
People people = await _libraryManager.GetOrDefault<People>(id);
|
||||||
if (people == null)
|
if (people == null)
|
||||||
return NotFound();
|
return NotFound();
|
||||||
return _files.FileResult(await _thumbs.GetImagePath(people, Thumbnails.Poster));
|
return _files.FileResult(await _thumbs.GetImagePath(people, Images.Poster));
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("{slug}/poster")]
|
[HttpGet("{slug}/poster")]
|
||||||
@ -103,7 +103,7 @@ namespace Kyoo.Api
|
|||||||
People people = await _libraryManager.GetOrDefault<People>(slug);
|
People people = await _libraryManager.GetOrDefault<People>(slug);
|
||||||
if (people == null)
|
if (people == null)
|
||||||
return NotFound();
|
return NotFound();
|
||||||
return _files.FileResult(await _thumbs.GetImagePath(people, Thumbnails.Poster));
|
return _files.FileResult(await _thumbs.GetImagePath(people, Images.Poster));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -36,7 +36,7 @@ namespace Kyoo.Api
|
|||||||
Provider provider = await _libraryManager.GetOrDefault<Provider>(id);
|
Provider provider = await _libraryManager.GetOrDefault<Provider>(id);
|
||||||
if (provider == null)
|
if (provider == null)
|
||||||
return NotFound();
|
return NotFound();
|
||||||
return _files.FileResult(await _thumbnails.GetImagePath(provider, Thumbnails.Logo));
|
return _files.FileResult(await _thumbnails.GetImagePath(provider, Images.Logo));
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("{slug}/logo")]
|
[HttpGet("{slug}/logo")]
|
||||||
@ -45,7 +45,7 @@ namespace Kyoo.Api
|
|||||||
Provider provider = await _libraryManager.GetOrDefault<Provider>(slug);
|
Provider provider = await _libraryManager.GetOrDefault<Provider>(slug);
|
||||||
if (provider == null)
|
if (provider == null)
|
||||||
return NotFound();
|
return NotFound();
|
||||||
return _files.FileResult(await _thumbnails.GetImagePath(provider, Thumbnails.Logo));
|
return _files.FileResult(await _thumbnails.GetImagePath(provider, Images.Logo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -151,7 +151,7 @@ namespace Kyoo.Api
|
|||||||
if (season == null)
|
if (season == null)
|
||||||
return NotFound();
|
return NotFound();
|
||||||
await _libraryManager.Load(season, x => x.Show);
|
await _libraryManager.Load(season, x => x.Show);
|
||||||
return _files.FileResult(await _thumbs.GetImagePath(season, Thumbnails.Poster));
|
return _files.FileResult(await _thumbs.GetImagePath(season, Images.Poster));
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("{slug}/poster")]
|
[HttpGet("{slug}/poster")]
|
||||||
@ -161,7 +161,7 @@ namespace Kyoo.Api
|
|||||||
if (season == null)
|
if (season == null)
|
||||||
return NotFound();
|
return NotFound();
|
||||||
await _libraryManager.Load(season, x => x.Show);
|
await _libraryManager.Load(season, x => x.Show);
|
||||||
return _files.FileResult(await _thumbs.GetImagePath(season, Thumbnails.Poster));
|
return _files.FileResult(await _thumbs.GetImagePath(season, Images.Poster));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -417,7 +417,7 @@ namespace Kyoo.Api
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Show show = await _libraryManager.Get<Show>(slug);
|
Show show = await _libraryManager.Get<Show>(slug);
|
||||||
return _files.FileResult(await _thumbs.GetImagePath(show, Thumbnails.Poster));
|
return _files.FileResult(await _thumbs.GetImagePath(show, Images.Poster));
|
||||||
}
|
}
|
||||||
catch (ItemNotFoundException)
|
catch (ItemNotFoundException)
|
||||||
{
|
{
|
||||||
@ -431,7 +431,7 @@ namespace Kyoo.Api
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Show show = await _libraryManager.Get<Show>(slug);
|
Show show = await _libraryManager.Get<Show>(slug);
|
||||||
return _files.FileResult(await _thumbs.GetImagePath(show, Thumbnails.Logo));
|
return _files.FileResult(await _thumbs.GetImagePath(show, Images.Logo));
|
||||||
}
|
}
|
||||||
catch (ItemNotFoundException)
|
catch (ItemNotFoundException)
|
||||||
{
|
{
|
||||||
@ -446,7 +446,7 @@ namespace Kyoo.Api
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Show show = await _libraryManager.Get<Show>(slug);
|
Show show = await _libraryManager.Get<Show>(slug);
|
||||||
return _files.FileResult(await _thumbs.GetImagePath(show, Thumbnails.Thumbnail));
|
return _files.FileResult(await _thumbs.GetImagePath(show, Images.Thumbnail));
|
||||||
}
|
}
|
||||||
catch (ItemNotFoundException)
|
catch (ItemNotFoundException)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user