diff --git a/src/Kyoo.Abstractions/Controllers/ITranscoder.cs b/src/Kyoo.Abstractions/Controllers/ITranscoder.cs
new file mode 100644
index 00000000..b87a8d5d
--- /dev/null
+++ b/src/Kyoo.Abstractions/Controllers/ITranscoder.cs
@@ -0,0 +1,63 @@
+// Kyoo - A portable and vast media library solution.
+// Copyright (c) Kyoo.
+//
+// See AUTHORS.md and LICENSE file in the project root for full license information.
+//
+// Kyoo is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// Kyoo is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Kyoo. If not, see .
+
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using JetBrains.Annotations;
+using Kyoo.Abstractions.Models;
+using Microsoft.AspNetCore.Mvc;
+
+namespace Kyoo.Abstractions.Controllers
+{
+ ///
+ /// Transcoder responsible of handling low level video details.
+ ///
+ public interface ITranscoder
+ {
+ ///
+ /// Retrieve tracks for a specific episode.
+ /// Subtitles, chapters and fonts should also be extracted and cached when calling this method.
+ ///
+ /// The episode to retrieve tracks for.
+ /// Should the cache be invalidated and subtitles and others be re-extracted?
+ /// The list of tracks available for this episode.
+ Task> ExtractInfos(Episode episode, bool reExtract);
+
+ ///
+ /// List fonts assosiated with this episode.
+ ///
+ /// Th episode to list fonts for.
+ /// The list of attachements for this epiosode.
+ Task> ListFonts(Episode episode);
+
+ ///
+ /// Get the specified font for this episode.
+ ///
+ /// The episode to list fonts for.
+ /// The slug of the specific font to retrive.
+ /// The with the given slug or null.
+ [ItemCanBeNull] Task GetFont(Episode episode, string slug);
+
+ ///
+ /// Transmux the selected episode to hls.
+ ///
+ /// The episode to transmux.
+ /// The master file (m3u8) of the transmuxed hls file.
+ IActionResult Transmux(Episode episode);
+ }
+}
diff --git a/src/Kyoo.Abstractions/Models/Font.cs b/src/Kyoo.Abstractions/Models/Font.cs
new file mode 100644
index 00000000..bd2d676f
--- /dev/null
+++ b/src/Kyoo.Abstractions/Models/Font.cs
@@ -0,0 +1,67 @@
+// Kyoo - A portable and vast media library solution.
+// Copyright (c) Kyoo.
+//
+// See AUTHORS.md and LICENSE file in the project root for full license information.
+//
+// Kyoo is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// Kyoo is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Kyoo. If not, see .
+
+using Kyoo.Abstractions.Models.Attributes;
+using Kyoo.Utils;
+using PathIO = System.IO.Path;
+
+namespace Kyoo.Abstractions.Models
+{
+ ///
+ /// A font of an .
+ ///
+ public class Font
+ {
+ ///
+ /// A human-readable identifier, used in the URL.
+ ///
+ public string Slug { get; set; }
+
+ ///
+ /// The name of the font file (with the extension).
+ ///
+ public string File { get; set; }
+
+ ///
+ /// The format of this font (the extension).
+ ///
+ public string Format { get; set; }
+
+ ///
+ /// The path of the font.
+ ///
+ [SerializeIgnore] public string Path { get; set; }
+
+ ///
+ /// Create a new empty .
+ ///
+ public Font() { }
+
+ ///
+ /// Create a new from a path.
+ ///
+ /// The path of the font.
+ public Font(string path)
+ {
+ Slug = Utility.ToSlug(PathIO.GetFileNameWithoutExtension(path));
+ Path = path;
+ File = PathIO.GetFileName(path);
+ Format = PathIO.GetExtension(path);
+ }
+ }
+}
diff --git a/src/Kyoo.Abstractions/Models/Resources/Track.cs b/src/Kyoo.Abstractions/Models/Resources/Track.cs
index 4c86f9f8..59b3746f 100644
--- a/src/Kyoo.Abstractions/Models/Resources/Track.cs
+++ b/src/Kyoo.Abstractions/Models/Resources/Track.cs
@@ -50,12 +50,6 @@ namespace Kyoo.Abstractions.Models
/// The stream is a subtitle.
///
Subtitle = 3,
-
- ///
- /// The stream is an attachment (a font, an image or something else).
- /// Only fonts are handled by kyoo but they are not saved to the database.
- ///
- Attachment = 4
}
///
diff --git a/src/Kyoo.Core/Controllers/FileSystems/LocalFileSystem.cs b/src/Kyoo.Core/Controllers/FileSystems/LocalFileSystem.cs
index 7f0f8bc5..42d77f92 100644
--- a/src/Kyoo.Core/Controllers/FileSystems/LocalFileSystem.cs
+++ b/src/Kyoo.Core/Controllers/FileSystems/LocalFileSystem.cs
@@ -153,17 +153,12 @@ namespace Kyoo.Core.Controllers
///
public Task GetExtraDirectory(T resource)
{
- if (!_options.CurrentValue.MetadataInShow)
- return Task.FromResult(null);
- return Task.FromResult(resource switch
+ string path = resource switch
{
- Show show => Combine(show.Path, "Extra"),
- Season season => Combine(season.Show.Path, "Extra"),
- // TODO: extras should not be on the same directory for every episodes/seasons/tracks. If this is fixed, fonts handling will break.
- Episode episode => Combine(episode.Show.Path, "Extra"),
- Track track => Combine(track.Episode.Show.Path, "Extra"),
- _ => null
- });
+ IResource res => Combine(_options.CurrentValue.MetadataPath, typeof(T).Name.ToLower(), res.Slug),
+ _ => Combine(_options.CurrentValue.MetadataPath, typeof(T).Name.ToLower())
+ };
+ return CreateDirectory(path);
}
///
diff --git a/src/Kyoo.Core/Controllers/RegexIdentifier.cs b/src/Kyoo.Core/Controllers/RegexIdentifier.cs
index f4931338..ba9bc19a 100644
--- a/src/Kyoo.Core/Controllers/RegexIdentifier.cs
+++ b/src/Kyoo.Core/Controllers/RegexIdentifier.cs
@@ -25,8 +25,8 @@ using System.Threading.Tasks;
using Kyoo.Abstractions.Controllers;
using Kyoo.Abstractions.Models;
using Kyoo.Abstractions.Models.Exceptions;
+using Kyoo.Core.Models;
using Kyoo.Core.Models.Options;
-using Kyoo.Core.Models.Watch;
using Kyoo.Utils;
using Microsoft.Extensions.Options;
diff --git a/src/Kyoo.Core/Controllers/ThumbnailsManager.cs b/src/Kyoo.Core/Controllers/ThumbnailsManager.cs
index 0d302ac5..cdde9452 100644
--- a/src/Kyoo.Core/Controllers/ThumbnailsManager.cs
+++ b/src/Kyoo.Core/Controllers/ThumbnailsManager.cs
@@ -129,18 +129,6 @@ namespace Kyoo.Core.Controllers
Images.Trailer => "trailer",
_ => $"{imageID}"
};
-
- switch (item)
- {
- case Season season:
- imageName = $"season-{season.SeasonNumber}-{imageName}";
- break;
- case Episode episode:
- directory = await _files.CreateDirectory(_files.Combine(directory, "Thumbnails"));
- imageName = $"{Path.GetFileNameWithoutExtension(episode.Path)}-{imageName}";
- break;
- }
-
return _files.Combine(directory, imageName);
}
diff --git a/src/Kyoo.Core/Controllers/Transcoder.cs b/src/Kyoo.Core/Controllers/Transcoder.cs
index d3480669..d577ec58 100644
--- a/src/Kyoo.Core/Controllers/Transcoder.cs
+++ b/src/Kyoo.Core/Controllers/Transcoder.cs
@@ -19,11 +19,14 @@
using System;
using System.Collections.Generic;
using System.IO;
+using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Kyoo.Abstractions.Controllers;
using Kyoo.Abstractions.Models;
using Kyoo.Core.Models.Options;
+using Kyoo.Core.Models.Watch;
+using Kyoo.Utils;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
@@ -48,16 +51,16 @@ namespace Kyoo.Core.Controllers
private const string TranscoderPath = "transcoder";
///
- /// Initialize the C library, setup the logger and return the size of a .
+ /// Initialize the C library, setup the logger and return the size of a .
///
- /// The size of a
+ /// The size of a
[DllImport(TranscoderPath, CallingConvention = CallingConvention.Cdecl)]
private static extern int init();
///
- /// Initialize the C library, setup the logger and return the size of a .
+ /// Initialize the C library, setup the logger and return the size of a .
///
- /// The size of a
+ /// The size of a
public static int Init() => init();
///
@@ -99,7 +102,7 @@ namespace Kyoo.Core.Controllers
/// The size of the returned array.
/// The number of tracks in the returned array.
/// Should the cache be invalidated and information re-extracted or not?
- /// A pointer to an array of
+ /// A pointer to an array of
[DllImport(TranscoderPath, CallingConvention = CallingConvention.Cdecl,
CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
private static extern IntPtr extract_infos(string path,
@@ -109,7 +112,7 @@ namespace Kyoo.Core.Controllers
bool reExtract);
///
- /// An helper method to free an array of .
+ /// An helper method to free an array of .
///
/// A pointer to the first element of the array
/// The number of items in the array.
@@ -128,7 +131,7 @@ namespace Kyoo.Core.Controllers
path = path.Replace('\\', '/');
outPath = outPath.Replace('\\', '/');
- int size = Marshal.SizeOf();
+ int size = Marshal.SizeOf();
IntPtr ptr = extract_infos(path, outPath, out uint arrayLength, out uint trackCount, reExtract);
IntPtr streamsPtr = ptr;
Track[] tracks;
@@ -140,8 +143,8 @@ namespace Kyoo.Core.Controllers
int j = 0;
for (int i = 0; i < arrayLength; i++)
{
- Models.Watch.Stream stream = Marshal.PtrToStructure(streamsPtr);
- if (stream!.Type != StreamType.Unknown)
+ FTrack stream = Marshal.PtrToStructure(streamsPtr);
+ if (stream!.Type != FTrackType.Unknown && stream.Type != FTrackType.Attachment)
{
tracks[j] = stream.ToTrack();
j++;
@@ -188,7 +191,7 @@ namespace Kyoo.Core.Controllers
_options = options;
_logger = logger;
- if (TranscoderAPI.Init() != Marshal.SizeOf())
+ if (TranscoderAPI.Init() != Marshal.SizeOf())
_logger.LogCritical("The transcoder library could not be initialized correctly");
}
@@ -204,6 +207,26 @@ namespace Kyoo.Core.Controllers
);
}
+ ///
+ public async Task> ListFonts(Episode episode)
+ {
+ string path = _files.Combine(await _files.GetExtraDirectory(episode), "Attachments");
+ return (await _files.ListFiles(path))
+ .Select(x => new Font(x))
+ .ToArray();
+ }
+
+ ///
+ public async Task GetFont(Episode episode, string slug)
+ {
+ string path = _files.Combine(await _files.GetExtraDirectory(episode), "Attachments");
+ string font = (await _files.ListFiles(path))
+ .FirstOrDefault(x => Utility.ToSlug(Path.GetFileName(x)) == slug);
+ if (font == null)
+ return null;
+ return new Font(path);
+ }
+
///
public IActionResult Transmux(Episode episode)
{
@@ -293,27 +316,4 @@ namespace Kyoo.Core.Controllers
#pragma warning restore 4014
}
}
-
- ///
- /// The transcoder used by the . This is on a different interface than the file system
- /// to offset the work.
- ///
- public interface ITranscoder
- {
- ///
- /// Retrieve tracks for a specific episode.
- /// Subtitles, chapters and fonts should also be extracted and cached when calling this method.
- ///
- /// The episode to retrieve tracks for.
- /// Should the cache be invalidated and subtitles and others be re-extracted?
- /// The list of tracks available for this episode.
- Task> ExtractInfos(Episode episode, bool reExtract);
-
- ///
- /// Transmux the selected episode to hls.
- ///
- /// The episode to transmux.
- /// The master file (m3u8) of the transmuxed hls file.
- IActionResult Transmux(Episode episode);
- }
}
diff --git a/src/Kyoo.Core/Models/Stream.cs b/src/Kyoo.Core/Models/FTrack.cs
similarity index 67%
rename from src/Kyoo.Core/Models/Stream.cs
rename to src/Kyoo.Core/Models/FTrack.cs
index ff6979d6..cb779e23 100644
--- a/src/Kyoo.Core/Models/Stream.cs
+++ b/src/Kyoo.Core/Models/FTrack.cs
@@ -21,11 +21,45 @@ using Kyoo.Abstractions.Models;
namespace Kyoo.Core.Models.Watch
{
+ ///
+ /// The list of available stream types.
+ /// Attachments are only used temporarily by the transcoder but are not stored in a database.
+ /// This is another enum used internally to communicate with ffmpeg.
+ ///
+ public enum FTrackType
+ {
+ ///
+ /// The type of the stream is not known.
+ ///
+ Unknown = StreamType.Unknown,
+
+ ///
+ /// The stream is a video.
+ ///
+ Video = StreamType.Video,
+
+ ///
+ /// The stream is an audio.
+ ///
+ Audio = StreamType.Audio,
+
+ ///
+ /// The stream is a subtitle.
+ ///
+ Subtitle = StreamType.Subtitle,
+
+ ///
+ /// The stream is an attachment (a font, an image or something else).
+ /// Only fonts are handled by kyoo but they are not saved to the database.
+ ///
+ Attachment
+ }
+
///
/// The unmanaged stream that the transcoder will return.
///
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
- public struct Stream
+ public struct FTrack
{
///
/// The title of the stream.
@@ -60,7 +94,7 @@ namespace Kyoo.Core.Models.Watch
///
/// The type of this stream.
///
- public StreamType Type;
+ public FTrackType Type;
///
/// Create a track from this stream.
@@ -76,7 +110,7 @@ namespace Kyoo.Core.Models.Watch
IsDefault = IsDefault,
IsForced = IsForced,
Path = Path,
- Type = Type,
+ Type = Type < FTrackType.Attachment ? (StreamType)Type : StreamType.Unknown,
IsExternal = false
};
}
diff --git a/src/Kyoo.Core/Models/FileExtensions.cs b/src/Kyoo.Core/Models/FileExtensions.cs
index e28c9007..5db0b582 100644
--- a/src/Kyoo.Core/Models/FileExtensions.cs
+++ b/src/Kyoo.Core/Models/FileExtensions.cs
@@ -20,7 +20,7 @@ using System.Collections.Generic;
using System.Collections.Immutable;
using System.IO;
-namespace Kyoo.Core.Models.Watch
+namespace Kyoo.Core.Models
{
///
/// A static class allowing one to identify files extensions.
diff --git a/src/Kyoo.Core/Tasks/Crawler.cs b/src/Kyoo.Core/Tasks/Crawler.cs
index 1a5d6e9e..791c280f 100644
--- a/src/Kyoo.Core/Tasks/Crawler.cs
+++ b/src/Kyoo.Core/Tasks/Crawler.cs
@@ -25,7 +25,7 @@ using System.Threading.Tasks;
using Kyoo.Abstractions.Controllers;
using Kyoo.Abstractions.Models;
using Kyoo.Abstractions.Models.Attributes;
-using Kyoo.Core.Models.Watch;
+using Kyoo.Core.Models;
using Microsoft.Extensions.Logging;
namespace Kyoo.Core.Tasks
diff --git a/src/Kyoo.Core/Tasks/RegisterEpisode.cs b/src/Kyoo.Core/Tasks/RegisterEpisode.cs
index 0a4d6085..7a9641c8 100644
--- a/src/Kyoo.Core/Tasks/RegisterEpisode.cs
+++ b/src/Kyoo.Core/Tasks/RegisterEpisode.cs
@@ -150,9 +150,7 @@ namespace Kyoo.Core.Tasks
if (!show.IsMovie)
episode = await _metadataProvider.Get(episode);
progress.Report(70);
- episode.Tracks = (await _transcoder.ExtractInfos(episode, false))
- .Where(x => x.Type != StreamType.Attachment)
- .ToArray();
+ episode.Tracks = await _transcoder.ExtractInfos(episode, false);
await _thumbnailsManager.DownloadImages(episode);
progress.Report(90);
diff --git a/src/Kyoo.Core/Views/Resources/EpisodeApi.cs b/src/Kyoo.Core/Views/Resources/EpisodeApi.cs
index ba11597a..0d8d2267 100644
--- a/src/Kyoo.Core/Views/Resources/EpisodeApi.cs
+++ b/src/Kyoo.Core/Views/Resources/EpisodeApi.cs
@@ -47,20 +47,34 @@ namespace Kyoo.Core.Api
///
private readonly ILibraryManager _libraryManager;
+ ///
+ /// The transcoder used to retrive fonts.
+ ///
+ private readonly ITranscoder _transcoder;
+
+ ///
+ /// The file system used to send fonts.
+ ///
+ private readonly IFileSystem _files;
+
///
/// Create a new .
///
///
/// The library manager used to modify or retrieve information in the data store.
///
+ /// The transcoder used to retrive fonts
/// The file manager used to send images.
/// The thumbnail manager used to retrieve images paths.
public EpisodeApi(ILibraryManager libraryManager,
+ ITranscoder transcoder,
IFileSystem files,
IThumbnailsManager thumbnails)
: base(libraryManager.EpisodeRepository, files, thumbnails)
{
_libraryManager = libraryManager;
+ _transcoder = transcoder;
+ _files = files;
}
///
@@ -158,5 +172,58 @@ namespace Kyoo.Core.Api
return BadRequest(new RequestError(ex.Message));
}
}
+
+ ///
+ /// List fonts
+ ///
+ ///
+ /// List available fonts for this episode.
+ ///
+ /// The ID or slug of the .
+ /// An object containing the name of the font followed by the url to retrieve it.
+ [HttpGet("{identifier:id}/fonts")]
+ [HttpGet("{identifier:id}/font", Order = AlternativeRoute)]
+ [PartialPermission(Kind.Read)]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status404NotFound)]
+ public async Task>> GetFonts(Identifier identifier)
+ {
+ Episode episode = await identifier.Match(
+ id => _libraryManager.GetOrDefault(id),
+ slug => _libraryManager.GetOrDefault(slug)
+ );
+ if (episode == null)
+ return NotFound();
+ return Ok(await _transcoder.ListFonts(episode));
+ }
+
+ ///
+ /// Get font
+ ///
+ ///
+ /// Get a font file that is used in subtitles of this episode.
+ ///
+ /// The ID or slug of the .
+ /// The slug of the font to retrieve.
+ /// A page of collections.
+ /// No show with the given ID/slug could be found or the font does not exist.
+ [HttpGet("{identifier:id}/fonts/{font}")]
+ [HttpGet("{identifier:id}/font/{font}", Order = AlternativeRoute)]
+ [PartialPermission(Kind.Read)]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status404NotFound)]
+ public async Task GetFont(Identifier identifier, string slug)
+ {
+ Episode episode = await identifier.Match(
+ id => _libraryManager.GetOrDefault(id),
+ slug => _libraryManager.GetOrDefault(slug)
+ );
+ if (episode == null)
+ return NotFound();
+ Font font = await _transcoder.GetFont(episode, slug);
+ if (font == null)
+ return NotFound();
+ return _files.FileResult(font.Path);
+ }
}
}
diff --git a/src/Kyoo.Core/Views/Resources/ShowApi.cs b/src/Kyoo.Core/Views/Resources/ShowApi.cs
index 8038fd85..6b8c186a 100644
--- a/src/Kyoo.Core/Views/Resources/ShowApi.cs
+++ b/src/Kyoo.Core/Views/Resources/ShowApi.cs
@@ -375,66 +375,5 @@ namespace Kyoo.Core.Api
return BadRequest(new RequestError(ex.Message));
}
}
-
- ///
- /// List fonts
- ///
- ///
- /// List available fonts for this show.
- ///
- /// The ID or slug of the .
- /// An object containing the name of the font followed by the url to retrieve it.
- [HttpGet("{identifier:id}/fonts")]
- [HttpGet("{identifier:id}/font", Order = AlternativeRoute)]
- [PartialPermission(Kind.Read)]
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status404NotFound)]
- public async Task>> GetFonts(Identifier identifier)
- {
- Show show = await identifier.Match(
- id => _libraryManager.GetOrDefault(id),
- slug => _libraryManager.GetOrDefault(slug)
- );
- if (show == null)
- return NotFound();
- string path = _files.Combine(await _files.GetExtraDirectory(show), "Attachments");
- return (await _files.ListFiles(path))
- .DistinctBy(Path.GetFileNameWithoutExtension)
- .ToDictionary(
- Path.GetFileNameWithoutExtension,
- x => $"{_baseURL}api/shows/{identifier}/fonts/{Path.GetFileName(x)}"
- );
- }
-
- ///
- /// Get font
- ///
- ///
- /// Get a font file that is used in subtitles of this show.
- ///
- /// The ID or slug of the .
- /// The name of the font to retrieve (with it's file extension).
- /// A page of collections.
- /// The font name is invalid.
- /// No show with the given ID/slug could be found or the font does not exist.
- [HttpGet("{identifier:id}/fonts/{font}")]
- [HttpGet("{identifier:id}/font/{font}", Order = AlternativeRoute)]
- [PartialPermission(Kind.Read)]
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(RequestError))]
- [ProducesResponseType(StatusCodes.Status404NotFound)]
- public async Task GetFont(Identifier identifier, string font)
- {
- if (font.Contains('/') || font.Contains('\\'))
- return BadRequest(new RequestError("Invalid font name."));
- Show show = await identifier.Match(
- id => _libraryManager.GetOrDefault(id),
- slug => _libraryManager.GetOrDefault(slug)
- );
- if (show == null)
- return NotFound();
- string path = _files.Combine(await _files.GetExtraDirectory(show), "Attachments", font);
- return _files.FileResult(path);
- }
}
}
diff --git a/src/Kyoo.Host.Generic/Contollers/FileSystemComposite.cs b/src/Kyoo.Host.Generic/Contollers/FileSystemComposite.cs
index 0a9eec86..d2445d23 100644
--- a/src/Kyoo.Host.Generic/Contollers/FileSystemComposite.cs
+++ b/src/Kyoo.Host.Generic/Contollers/FileSystemComposite.cs
@@ -44,12 +44,6 @@ namespace Kyoo.Host.Generic.Controllers
///
private readonly ICollection, FileSystemMetadataAttribute>> _fileSystems;
- ///
- /// The library manager used to load shows to retrieve their path
- /// (only if the option is set to metadata in show)
- ///
- private readonly ILibraryManager _libraryManager;
-
///
/// Options to check if the metadata should be kept in the show directory or in a kyoo's directory.
///
@@ -60,14 +54,11 @@ namespace Kyoo.Host.Generic.Controllers
/// metadata.
///
/// The list of filesystem mapped to their metadata.
- /// The library manager used to load shows to retrieve their path.
/// The options to use.
public FileSystemComposite(ICollection, FileSystemMetadataAttribute>> fileSystems,
- ILibraryManager libraryManager,
IOptionsMonitor options)
{
_fileSystems = fileSystems;
- _libraryManager = libraryManager;
_options = options;
}
@@ -178,41 +169,10 @@ namespace Kyoo.Host.Generic.Controllers
}
///
- public async Task GetExtraDirectory(T resource)
+ public Task GetExtraDirectory(T resource)
{
- switch (resource)
- {
- case Season season:
- await _libraryManager.Load(season, x => x.Show);
- break;
- case Episode episode:
- await _libraryManager.Load(episode, x => x.Show);
- break;
- case Track track:
- await _libraryManager.Load(track, x => x.Episode);
- await _libraryManager.Load(track.Episode, x => x.Show);
- break;
- }
-
- IFileSystem fs = resource switch
- {
- Show show => _GetFileSystemForPath(show.Path, out string _),
- Season season => _GetFileSystemForPath(season.Show.Path, out string _),
- Episode episode => _GetFileSystemForPath(episode.Show.Path, out string _),
- Track track => _GetFileSystemForPath(track.Episode.Show.Path, out string _),
- _ => _GetFileSystemForPath(_options.CurrentValue.MetadataPath, out string _)
- };
- string path = await fs.GetExtraDirectory(resource)
- ?? resource switch
- {
- IResource res => Combine(
- _options.CurrentValue.MetadataPath,
- typeof(T).Name.ToLower(),
- res.Slug
- ),
- _ => Combine(_options.CurrentValue.MetadataPath, typeof(T).Name.ToLower())
- };
- return await CreateDirectory(path);
+ IFileSystem fs = _GetFileSystemForPath(_options.CurrentValue.MetadataPath, out string path);
+ return fs.GetExtraDirectory(resource);
}
///
diff --git a/src/Kyoo.Transcoder b/src/Kyoo.Transcoder
index 7bae8def..913c8e98 160000
--- a/src/Kyoo.Transcoder
+++ b/src/Kyoo.Transcoder
@@ -1 +1 @@
-Subproject commit 7bae8def39ace7bab481efea4825c4802e9e1f31
+Subproject commit 913c8e986e220ea48749b815593cdd10b2acb8de