Adding a metadata editor for shows

This commit is contained in:
Zoe Roux 2020-04-19 04:27:20 +02:00
parent 2293eb9494
commit 114f105f37
5 changed files with 47 additions and 8 deletions

View File

@ -28,6 +28,7 @@ namespace Kyoo.Controllers
IEnumerable<Collection> SearchCollections(string searchQuery);
Library GetLibrary(string librarySlug);
IEnumerable<Library> GetLibraries();
IEnumerable<Studio> GetStudios();
Show GetShowBySlug(string slug);
Show GetShow(string path);
Season GetSeason(string showSlug, long seasonNumber);

View File

@ -127,5 +127,5 @@ namespace Kyoo.Models
}
}
public enum Status { Finished, Airing }
public enum Status { Finished, Airing, Planned }
}

View File

@ -210,6 +210,11 @@ namespace Kyoo.Controllers
return (from genre in _database.Genres where genre.Slug == slug select genre).FirstOrDefault();
}
public IEnumerable<Studio> GetStudios()
{
return _database.Studios;
}
public Studio GetStudio(long showID)
{
return (from show in _database.Shows where show.ID == showID select show.Studio).FirstOrDefault();
@ -371,20 +376,27 @@ namespace Kyoo.Controllers
try
{
Show show = _database.Entry(edited).IsKeySet
? _database.Shows.FirstOrDefault(x => x.ID == edited.ID)
: _database.Shows.FirstOrDefault(x => x.Slug == edited.Slug);
? _database.Shows.Include(x => x.GenreLinks).FirstOrDefault(x => x.ID == edited.ID)
: _database.Shows.Include(x => x.GenreLinks).FirstOrDefault(x => x.Slug == edited.Slug);
if (show == null)
throw new ItemNotFound($"No show could be found with the id {edited.ID} or the slug {edited.Slug}");
Utility.Complete(show, edited);
Studio tmp = _database.Studios.FirstOrDefault(x => x.Slug == edited.Studio.Slug);
if (tmp != null)
show.Studio = tmp;
if (edited.Studio != null)
{
if (edited.Studio.Slug == null)
edited.Studio.Slug = Utility.ToSlug(edited.Studio.Name);
Studio tmp = _database.Studios.FirstOrDefault(x => x.Slug == edited.Studio.Slug);
if (tmp != null)
show.Studio = tmp;
}
show.GenreLinks = edited.GenreLinks?.Select(x =>
{
if (x.Genre.Slug == null)
x.Genre.Slug = Utility.ToSlug(x.Genre.Name);
x.Genre = _database.Genres.FirstOrDefault(y => y.Slug == x.Genre.Slug) ?? x.Genre;
x.GenreID = x.Genre.ID;
return x;

View File

@ -0,0 +1,26 @@
using System.Collections.Generic;
using System.Linq;
using Kyoo.Controllers;
using Kyoo.Models;
using Microsoft.AspNetCore.Mvc;
namespace Kyoo.API
{
[Route("api/studios")]
[Route("api/studio")]
[ApiController]
public class StudioAPI : ControllerBase
{
private readonly ILibraryManager _libraryManager;
public StudioAPI(ILibraryManager libraryManager)
{
_libraryManager = libraryManager;
}
public ActionResult<IEnumerable<Studio>> Index()
{
return _libraryManager.GetStudios().ToList();
}
}
}

@ -1 +1 @@
Subproject commit 4288ecd02e4f5f467659eb031fb172372c8c7af4
Subproject commit bdac52cc189dd62e5cc8c60555b9f8395c2d6079