Implemnting relational data loading inside the repositories

This commit is contained in:
Zoe Roux 2020-06-06 17:53:08 +02:00
parent b3847a5bc5
commit c5b0858d4a
18 changed files with 189 additions and 102 deletions

View File

@ -13,11 +13,21 @@ namespace Kyoo.Controllers
Task<Season> GetSeason(string showSlug, long seasonNumber);
Task<Episode> GetEpisode(string showSlug, long seasonNumber, long episodeNumber);
Task<Episode> GetMovieEpisode(string movieSlug);
Task<Track> GetTrack(long id);
Task<Track> GetTrack(long episodeID, string language, bool isForced);
Task<Genre> GetGenre(string slug);
Task<Studio> GetStudio(string slug);
Task<People> GetPeople(string slug);
// Get by relations
Task<IEnumerable<Season>> GetSeasons(long showID);
Task<IEnumerable<Season>> GetSeasons(string showSlug);
Task<IEnumerable<Episode>> GetEpisodes(long showID, long seasonNumber);
Task<IEnumerable<Episode>> GetEpisodes(string showSlug, long seasonNumber);
Task<IEnumerable<Episode>> GetEpisodes(long seasonID);
// Get all
Task<IEnumerable<Library>> GetLibraries();
Task<IEnumerable<Collection>> GetCollections();

View File

@ -22,11 +22,18 @@ namespace Kyoo.Controllers
public interface ISeasonRepository : IRepository<Season>
{
Task<Season> Get(string showSlug, long seasonNumber);
Task<IEnumerable<Season>> GetSeasons(long showID);
Task<IEnumerable<Season>> GetSeasons(string showSlug);
}
public interface IEpisodeRepository : IRepository<Episode>
{
Task<Episode> Get(string showSlug, long seasonNumber, long episodeNumber);
Task<IEnumerable<Episode>> GetEpisodes(long showID, long seasonNumber);
Task<IEnumerable<Episode>> GetEpisodes(string showSlug, long seasonNumber);
Task<IEnumerable<Episode>> GetEpisodes(long seasonID);
}
public interface ITrackRepository : IRepository<Track>

View File

@ -61,6 +61,11 @@ namespace Kyoo.Controllers
return _episodes.Get(movieSlug);
}
public Task<Track> GetTrack(long id)
{
return _tracks.Get(id);
}
public Task<Track> GetTrack(long episodeID, string language, bool isForced)
{
return _tracks.Get(episodeID, language, isForced);
@ -131,6 +136,31 @@ namespace Kyoo.Controllers
return _providers.GetAll();
}
public Task<IEnumerable<Season>> GetSeasons(long showID)
{
return _seasons.GetSeasons(showID);
}
public Task<IEnumerable<Season>> GetSeasons(string showSlug)
{
return _seasons.GetSeasons(showSlug);
}
public Task<IEnumerable<Episode>> GetEpisodes(long showID, long seasonNumber)
{
return _episodes.GetEpisodes(showID, seasonNumber);
}
public Task<IEnumerable<Episode>> GetEpisodes(string showSlug, long seasonNumber)
{
return _episodes.GetEpisodes(showSlug, seasonNumber);
}
public Task<IEnumerable<Episode>> GetEpisodes(long seasonID)
{
return _episodes.GetEpisodes(seasonID);
}
public Task<IEnumerable<Library>> SearchLibraries(string searchQuery)
{
return _libraries.Search(searchQuery);

View File

@ -119,5 +119,22 @@ namespace Kyoo.Controllers
_database.Episodes.Remove(obj);
await _database.SaveChangesAsync();
}
public async Task<IEnumerable<Episode>> GetEpisodes(long showID, long seasonNumber)
{
return await _database.Episodes.Where(x => x.ShowID == showID
&& x.SeasonNumber == seasonNumber).ToListAsync();
}
public async Task<IEnumerable<Episode>> GetEpisodes(string showSlug, long seasonNumber)
{
return await _database.Episodes.Where(x => x.Show.Slug == showSlug
&& x.SeasonNumber == seasonNumber).ToListAsync();
}
public async Task<IEnumerable<Episode>> GetEpisodes(long seasonID)
{
return await _database.Episodes.Where(x => x.SeasonID == seasonID).ToListAsync();
}
}
}

View File

@ -115,5 +115,15 @@ namespace Kyoo.Controllers
_database.Seasons.Remove(obj);
await _database.SaveChangesAsync();
}
public async Task<IEnumerable<Season>> GetSeasons(long showID)
{
return await _database.Seasons.Where(x => x.ShowID == showID).ToListAsync();
}
public async Task<IEnumerable<Season>> GetSeasons(string showSlug)
{
return await _database.Seasons.Where(x => x.Show.Slug == showSlug).ToListAsync();
}
}
}

View File

@ -62,7 +62,7 @@ namespace Kyoo.Tasks
edited.ID = old.ID;
edited.Slug = old.Slug;
edited.Path = old.Path;
await libraryManager.Edit(edited, true);
await libraryManager.EditShow(edited, true);
await _thumbnailsManager.Validate(edited, true);
}
if (old.Seasons != null)
@ -95,7 +95,7 @@ namespace Kyoo.Tasks
Library library = _database.LibraryLinks.First(x => x.Show == show && x.Library != null).Library;
Season edited = await _providerManager.GetSeason(show, old.SeasonNumber, library);
edited.ID = old.ID;
await libraryManager.Edit(edited, true);
await libraryManager.EditSeason(edited, true);
await _thumbnailsManager.Validate(edited, true);
}
if (old.Episodes != null)
@ -110,7 +110,7 @@ namespace Kyoo.Tasks
Library library = _database.LibraryLinks.First(x => x.Show == show && x.Library != null).Library;
Episode edited = await _providerManager.GetEpisode(show, old.Path, old.SeasonNumber, old.EpisodeNumber, old.AbsoluteNumber, library);
edited.ID = old.ID;
await libraryManager.Edit(edited, true);
await libraryManager.EditEpisode(edited, true);
await _thumbnailsManager.Validate(edited, true);
}

View File

@ -2,6 +2,7 @@
using Kyoo.Models;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
namespace Kyoo.Api
@ -19,9 +20,9 @@ namespace Kyoo.Api
[HttpGet("{collectionSlug}")]
[Authorize(Policy="Read")]
public ActionResult<Collection> GetShows(string collectionSlug)
public async Task<ActionResult<Collection>> GetShows(string collectionSlug)
{
Collection collection = _libraryManager.GetCollection(collectionSlug);
Collection collection = await _libraryManager.GetCollection(collectionSlug);
if (collection == null)
return NotFound();

View File

@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Kyoo.Controllers;
using Microsoft.AspNetCore.Authorization;
@ -20,9 +21,9 @@ namespace Kyoo.Api
[HttpGet("{showSlug}/season/{seasonNumber}")]
[Authorize(Policy="Read")]
public ActionResult<IEnumerable<Episode>> GetEpisodesForSeason(string showSlug, long seasonNumber)
public async Task<ActionResult<IEnumerable<Episode>>> GetEpisodesForSeason(string showSlug, long seasonNumber)
{
IEnumerable<Episode> episodes = _libraryManager.GetEpisodes(showSlug, seasonNumber);
IEnumerable<Episode> episodes = await _libraryManager.GetEpisodes(showSlug, seasonNumber);
if(episodes == null)
return NotFound();
@ -33,9 +34,9 @@ namespace Kyoo.Api
[HttpGet("{showSlug}/season/{seasonNumber}/episode/{episodeNumber}")]
[Authorize(Policy="Read")]
[JsonDetailed]
public ActionResult<Episode> GetEpisode(string showSlug, long seasonNumber, long episodeNumber)
public async Task<ActionResult<Episode>> GetEpisode(string showSlug, long seasonNumber, long episodeNumber)
{
Episode episode = _libraryManager.GetEpisode(showSlug, seasonNumber, episodeNumber);
Episode episode = await _libraryManager.GetEpisode(showSlug, seasonNumber, episodeNumber);
if (episode == null)
return NotFound();

View File

@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Kyoo.Controllers;
using Kyoo.Models;
using Microsoft.AspNetCore.Mvc;
@ -18,9 +19,9 @@ namespace Kyoo.API
_libraryManager = libraryManager;
}
public ActionResult<IEnumerable<Genre>> Index()
public async Task<ActionResult<IEnumerable<Genre>>> Index()
{
return _libraryManager.GetGenres().ToList();
return (await _libraryManager.GetGenres()).ToList();
}
}
}

View File

@ -3,6 +3,7 @@ using Kyoo.Models;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
namespace Kyoo.Api
@ -22,15 +23,15 @@ namespace Kyoo.Api
}
[HttpGet]
public IEnumerable<Library> GetLibraries()
public async Task<IEnumerable<Library>> GetLibraries()
{
return _libraryManager.GetLibraries();
return await _libraryManager.GetLibraries();
}
[Route("/api/library/create")]
[HttpPost]
[Authorize(Policy="Admin")]
public IActionResult CreateLibrary([FromBody] Library library)
public async Task<IActionResult> CreateLibrary([FromBody] Library library)
{
if (!ModelState.IsValid)
return BadRequest(library);
@ -42,17 +43,16 @@ namespace Kyoo.Api
return BadRequest(new {error = "The library should have a least one path."});
if (_libraryManager.GetLibrary(library.Slug) != null)
return BadRequest(new {error = "Duplicated library slug"});
_libraryManager.Register(library);
_libraryManager.SaveChanges();
await _libraryManager.RegisterLibrary(library);
_taskManager.StartTask("scan", library.Slug);
return Ok();
}
[HttpGet("{librarySlug}")]
[Authorize(Policy="Read")]
public ActionResult<IEnumerable<Show>> GetShows(string librarySlug)
public async Task<ActionResult<IEnumerable<Show>>> GetShows(string librarySlug)
{
Library library = _libraryManager.GetLibrary(librarySlug);
Library library = await _libraryManager.GetLibrary(librarySlug);
if (library == null)
return NotFound();

View File

@ -1,4 +1,5 @@
using System.Linq;
using System.Threading.Tasks;
using Kyoo.Controllers;
using Kyoo.Models;
using Microsoft.AspNetCore.Authorization;
@ -19,9 +20,9 @@ namespace Kyoo.Api
[HttpGet("{peopleSlug}")]
[Authorize(Policy="Read")]
public ActionResult<Collection> GetPeople(string peopleSlug)
public async Task<ActionResult<Collection>> GetPeople(string peopleSlug)
{
People people = _libraryManager.GetPeople(peopleSlug);
People people = await _libraryManager.GetPeople(peopleSlug);
if (people == null)
return NotFound();

View File

@ -1,4 +1,5 @@
using Kyoo.Controllers;
using System.Threading.Tasks;
using Kyoo.Controllers;
using Kyoo.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@ -18,17 +19,17 @@ namespace Kyoo.Api
[HttpGet("{query}")]
[Authorize(Policy="Read")]
public ActionResult<SearchResult> Search(string query)
public async Task<ActionResult<SearchResult>> Search(string query)
{
SearchResult result = new SearchResult
{
Query = query,
Collections = _libraryManager.SearchCollections(query),
Shows = _libraryManager.SearchShows(query),
Episodes = _libraryManager.SearchEpisodes(query),
People = _libraryManager.SearchPeople(query),
Genres = _libraryManager.SearchGenres(query),
Studios = _libraryManager.SearchStudios(query)
Collections = await _libraryManager.SearchCollections(query),
Shows = await _libraryManager.SearchShows(query),
Episodes = await _libraryManager.SearchEpisodes(query),
People = await _libraryManager.SearchPeople(query),
Genres = await _libraryManager.SearchGenres(query),
Studios = await _libraryManager.SearchStudios(query)
};
return result;
}

View File

@ -43,9 +43,9 @@ namespace Kyoo.Api
[HttpGet("{slug}")]
[Authorize(Policy="Read")]
[JsonDetailed]
public ActionResult<Show> GetShow(string slug)
public async Task<ActionResult<Show>> GetShow(string slug)
{
Show show = _libraryManager.GetShow(slug);
Show show = await _libraryManager.GetShow(slug);
if (show == null)
return NotFound();
@ -55,7 +55,7 @@ namespace Kyoo.Api
[HttpPost("edit/{slug}")]
[Authorize(Policy="Write")]
public IActionResult EditShow(string slug, [FromBody] Show show)
public async Task<IActionResult> EditShow(string slug, [FromBody] Show show)
{
if (!ModelState.IsValid)
return BadRequest(show);
@ -66,7 +66,7 @@ namespace Kyoo.Api
show.ID = old.ID;
show.Slug = slug;
show.Path = old.Path;
_libraryManager.Edit(show, false);
await _libraryManager.EditShow(show, false);
return Ok();
}
@ -79,7 +79,6 @@ namespace Kyoo.Api
Show show = _database.Shows.Include(x => x.ExternalIDs).FirstOrDefault(x => x.Slug == slug);
if (show == null)
return NotFound();
show.ExternalIDs = _libraryManager.Validate(externalIDs);
_database.SaveChanges();
_taskManager.StartTask("re-scan", $"show/{slug}");
return Ok();
@ -96,7 +95,7 @@ namespace Kyoo.Api
[Authorize(Policy = "Write")]
public async Task<IActionResult> DownloadImages(string slug)
{
Show show = _libraryManager.GetShow(slug);
Show show = await _libraryManager.GetShow(slug);
if (show == null)
return NotFound();
await _thumbnailsManager.Validate(show, true);

View File

@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Kyoo.Controllers;
using Kyoo.Models;
using Microsoft.AspNetCore.Mvc;
@ -18,9 +19,9 @@ namespace Kyoo.API
_libraryManager = libraryManager;
}
public ActionResult<IEnumerable<Studio>> Index()
public async Task<ActionResult<IEnumerable<Studio>>> Index()
{
return _libraryManager.GetStudios().ToList();
return (await _libraryManager.GetStudios()).ToList();
}
}
}

View File

@ -14,31 +14,37 @@ namespace Kyoo.Api
public class SubtitleController : ControllerBase
{
private readonly ILibraryManager _libraryManager;
private readonly ITranscoder _transcoder;
//private readonly ITranscoder _transcoder;
public SubtitleController(ILibraryManager libraryManager, ITranscoder transcoder)
public SubtitleController(ILibraryManager libraryManager/*, ITranscoder transcoder*/)
{
_libraryManager = libraryManager;
_transcoder = transcoder;
// _transcoder = transcoder;
}
[HttpGet("{showSlug}-s{seasonNumber:int}e{episodeNumber:int}.{identifier}.{extension?}")]
[Authorize(Policy="Play")]
public IActionResult GetSubtitle(string showSlug, int seasonNumber, int episodeNumber, string identifier, string extension)
public async Task<IActionResult> GetSubtitle(string showSlug,
int seasonNumber,
int episodeNumber,
string identifier,
string extension)
{
string languageTag = identifier.Length == 3 ? identifier.Substring(0, 3) : null;
bool forced = identifier.Length > 4 && identifier.Substring(4) == "forced";
Track subtitle = null;
if (languageTag != null)
subtitle = _libraryManager.GetEpisode(showSlug, seasonNumber, episodeNumber)?.Tracks
subtitle = (await _libraryManager.GetEpisode(showSlug, seasonNumber, episodeNumber))?.Tracks
.FirstOrDefault(x => x.Language == languageTag && x.IsForced == forced);
if (subtitle == null)
{
string idString = identifier.IndexOf('-') != -1 ? identifier.Substring(0, identifier.IndexOf('-')) : identifier;
string idString = identifier.IndexOf('-') != -1
? identifier.Substring(0, identifier.IndexOf('-'))
: identifier;
long.TryParse(idString, out long id);
subtitle = _libraryManager.GetTracks().FirstOrDefault(x => x.ID == id);
subtitle = await _libraryManager.GetTrack(id);
}
if (subtitle == null)
@ -57,43 +63,43 @@ namespace Kyoo.Api
return PhysicalFile(subtitle.Path, mime);
}
[HttpGet("extract/{showSlug}-s{seasonNumber}e{episodeNumber}")]
[Authorize(Policy="Admin")]
public async Task<string> ExtractSubtitle(string showSlug, long seasonNumber, long episodeNumber)
{
Episode episode = _libraryManager.GetEpisode(showSlug, seasonNumber, episodeNumber);
episode.Tracks = null;
Track[] tracks = await _transcoder.ExtractSubtitles(episode.Path);
foreach (Track track in tracks)
{
track.EpisodeID = episode.ID;
_libraryManager.Register(track);
}
await _libraryManager.SaveChanges();
return "Done. " + tracks.Length + " track(s) extracted.";
}
[HttpGet("extract/{showSlug}")]
[Authorize(Policy="Admin")]
public async Task<string> ExtractSubtitle(string showSlug)
{
IEnumerable<Episode> episodes = _libraryManager.GetShow(showSlug).Episodes;
foreach (Episode episode in episodes)
{
episode.Tracks = null;
Track[] tracks = await _transcoder.ExtractSubtitles(episode.Path);
foreach (Track track in tracks)
{
track.EpisodeID = episode.ID;
_libraryManager.Register(track);
}
await _libraryManager.SaveChanges();
}
return "Done.";
}
// [HttpGet("extract/{showSlug}-s{seasonNumber}e{episodeNumber}")]
// [Authorize(Policy="Admin")]
// public async Task<string> ExtractSubtitle(string showSlug, long seasonNumber, long episodeNumber)
// {
// Episode episode = _libraryManager.GetEpisode(showSlug, seasonNumber, episodeNumber);
// episode.Tracks = null;
//
// Track[] tracks = await _transcoder.ExtractSubtitles(episode.Path);
// foreach (Track track in tracks)
// {
// track.EpisodeID = episode.ID;
// _libraryManager.Register(track);
// }
// await _libraryManager.SaveChanges();
// return "Done. " + tracks.Length + " track(s) extracted.";
// }
//
// [HttpGet("extract/{showSlug}")]
// [Authorize(Policy="Admin")]
// public async Task<string> ExtractSubtitle(string showSlug)
// {
// IEnumerable<Episode> episodes = _libraryManager.GetShow(showSlug).Episodes;
// foreach (Episode episode in episodes)
// {
// episode.Tracks = null;
//
// Track[] tracks = await _transcoder.ExtractSubtitles(episode.Path);
// foreach (Track track in tracks)
// {
// track.EpisodeID = episode.ID;
// _libraryManager.Register(track);
// }
// await _libraryManager.SaveChanges();
// }
//
// return "Done.";
// }
}

View File

@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using System.IO;
using System.Threading.Tasks;
using Kyoo.Controllers;
using Microsoft.AspNetCore.Authorization;
@ -20,9 +21,9 @@ namespace Kyoo.Api
[HttpGet("poster/{showSlug}")]
[Authorize(Policy="Read")]
public IActionResult GetShowThumb(string showSlug)
public async Task<IActionResult> GetShowThumb(string showSlug)
{
string path = _libraryManager.GetShow(showSlug)?.Path;
string path = (await _libraryManager.GetShow(showSlug))?.Path;
if (path == null)
return NotFound();
@ -35,9 +36,9 @@ namespace Kyoo.Api
[HttpGet("logo/{showSlug}")]
[Authorize(Policy="Read")]
public IActionResult GetShowLogo(string showSlug)
public async Task<IActionResult> GetShowLogo(string showSlug)
{
string path = _libraryManager.GetShow(showSlug)?.Path;
string path = (await _libraryManager.GetShow(showSlug))?.Path;
if (path == null)
return NotFound();
@ -50,9 +51,9 @@ namespace Kyoo.Api
[HttpGet("backdrop/{showSlug}")]
[Authorize(Policy="Read")]
public IActionResult GetShowBackdrop(string showSlug)
public async Task<IActionResult> GetShowBackdrop(string showSlug)
{
string path = _libraryManager.GetShow(showSlug)?.Path;
string path = (await _libraryManager.GetShow(showSlug))?.Path;
if (path == null)
return NotFound();
@ -76,9 +77,9 @@ namespace Kyoo.Api
[HttpGet("thumb/{showSlug}-s{seasonNumber}e{episodeNumber}")]
[Authorize(Policy="Read")]
public IActionResult GetEpisodeThumb(string showSlug, long seasonNumber, long episodeNumber)
public async Task<IActionResult> GetEpisodeThumb(string showSlug, long seasonNumber, long episodeNumber)
{
string path = _libraryManager.GetEpisode(showSlug, seasonNumber, episodeNumber)?.Path;
string path = (await _libraryManager.GetEpisode(showSlug, seasonNumber, episodeNumber))?.Path;
if (path == null)
return NotFound();

View File

@ -27,9 +27,9 @@ namespace Kyoo.Api
[HttpGet("{showSlug}-s{seasonNumber}e{episodeNumber}")]
[Authorize(Policy="Play")]
public IActionResult Index(string showSlug, long seasonNumber, long episodeNumber)
public async Task<IActionResult> Index(string showSlug, long seasonNumber, long episodeNumber)
{
Episode episode = _libraryManager.GetEpisode(showSlug, seasonNumber, episodeNumber);
Episode episode = await _libraryManager.GetEpisode(showSlug, seasonNumber, episodeNumber);
if (episode != null && System.IO.File.Exists(episode.Path))
return PhysicalFile(episode.Path, "video/x-matroska", true);
@ -40,7 +40,7 @@ namespace Kyoo.Api
[Authorize(Policy="Play")]
public async Task<IActionResult> Transmux(string showSlug, long seasonNumber, long episodeNumber)
{
Episode episode = _libraryManager.GetEpisode(showSlug, seasonNumber, episodeNumber);
Episode episode = await _libraryManager.GetEpisode(showSlug, seasonNumber, episodeNumber);
if (episode == null || !System.IO.File.Exists(episode.Path))
return NotFound();
@ -63,7 +63,7 @@ namespace Kyoo.Api
[Authorize(Policy="Play")]
public async Task<IActionResult> Transcode(string showSlug, long seasonNumber, long episodeNumber)
{
Episode episode = _libraryManager.GetEpisode(showSlug, seasonNumber, episodeNumber);
Episode episode = await _libraryManager.GetEpisode(showSlug, seasonNumber, episodeNumber);
if (episode == null || !System.IO.File.Exists(episode.Path))
return NotFound();
@ -85,9 +85,9 @@ namespace Kyoo.Api
[HttpGet("{movieSlug}")]
[Authorize(Policy="Play")]
public IActionResult Index(string movieSlug)
public async Task<IActionResult> Index(string movieSlug)
{
Episode episode = _libraryManager.GetMovieEpisode(movieSlug);
Episode episode = await _libraryManager.GetMovieEpisode(movieSlug);
if (episode != null && System.IO.File.Exists(episode.Path))
return PhysicalFile(episode.Path, "video/webm", true);
@ -98,7 +98,7 @@ namespace Kyoo.Api
[Authorize(Policy="Play")]
public async Task<IActionResult> Transmux(string movieSlug)
{
Episode episode = _libraryManager.GetMovieEpisode(movieSlug);
Episode episode = await _libraryManager.GetMovieEpisode(movieSlug);
if (episode == null || !System.IO.File.Exists(episode.Path))
return NotFound();
@ -112,7 +112,7 @@ namespace Kyoo.Api
[Authorize(Policy="Play")]
public async Task<IActionResult> Transcode(string movieSlug)
{
Episode episode = _libraryManager.GetMovieEpisode(movieSlug);
Episode episode = await _libraryManager.GetMovieEpisode(movieSlug);
if (episode == null || !System.IO.File.Exists(episode.Path))
return NotFound();

View File

@ -1,4 +1,5 @@
using Kyoo.Controllers;
using System.Threading.Tasks;
using Kyoo.Controllers;
using Kyoo.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@ -18,9 +19,9 @@ namespace Kyoo.Api
[HttpGet("{showSlug}-s{seasonNumber}e{episodeNumber}")]
[Authorize(Policy="Read")]
public ActionResult<WatchItem> Index(string showSlug, long seasonNumber, long episodeNumber)
public async Task<ActionResult<WatchItem>> Index(string showSlug, long seasonNumber, long episodeNumber)
{
Episode item = _libraryManager.GetEpisode(showSlug, seasonNumber, episodeNumber);
Episode item = await _libraryManager.GetEpisode(showSlug, seasonNumber, episodeNumber);
if(item == null)
return NotFound();
@ -30,9 +31,9 @@ namespace Kyoo.Api
[HttpGet("{movieSlug}")]
[Authorize(Policy="Read")]
public ActionResult<WatchItem> Index(string movieSlug)
public async Task<ActionResult<WatchItem>> Index(string movieSlug)
{
Episode item = _libraryManager.GetMovieEpisode(movieSlug);
Episode item = await _libraryManager.GetMovieEpisode(movieSlug);
if(item == null)
return NotFound();