Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,19 @@ private void ReleaseAndMaybeRemove(Guid key, SemaphoreSlim sem)
}
}

public static class StringExtensions
{
public static string FirstCharToUpperInvariant(this string input)
{
if (string.IsNullOrEmpty(input))
{
return input;
}

return char.ToUpperInvariant(input[0]) + input[1..];
}
}

public static class EnumMappingExtensions
{
public static StremioMediaType ToStremio(this BaseItemKind kind)
Expand Down
17 changes: 17 additions & 0 deletions Config/ConfigurationHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace Gelato.Config
{
internal static class ConfigurationHelper
{
public static CatalogConfig? GetCatalogConfig(string id, string type)
{
return GelatoPlugin.Instance!.Configuration.Catalogs.FirstOrDefault(c =>
c.Id == id && c.Type == type
);
}

public static PluginConfiguration GetConfig(Guid? userId = null)
{
return GelatoPlugin.Instance!.GetConfig(userId ?? Guid.Empty);
}
}
}
20 changes: 3 additions & 17 deletions GelatoManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,29 +102,15 @@ private static void SeedFolder(string path)

public Folder? TryGetMovieFolder(Guid userId)
{
return TryGetFolder(
GelatoPlugin.Instance!.Configuration.GetEffectiveConfig(userId).MoviePath
);
return TryGetConfigFolder(GelatoPlugin.Instance!.Configuration.GetEffectiveConfig(userId).MoviePath);
}

public Folder? TryGetSeriesFolder(Guid userId)
{
return TryGetFolder(
GelatoPlugin.Instance!.Configuration.GetEffectiveConfig(userId).SeriesPath
);
}

public Folder? TryGetMovieFolder(PluginConfiguration cfg)
{
return TryGetFolder(cfg.MoviePath);
}

public Folder? TryGetSeriesFolder(PluginConfiguration cfg)
{
return TryGetFolder(cfg.SeriesPath);
return TryGetConfigFolder(GelatoPlugin.Instance!.Configuration.GetEffectiveConfig(userId).SeriesPath);
}

private Folder? TryGetFolder(string path)
public Folder? TryGetConfigFolder(string path)
{
if (string.IsNullOrWhiteSpace(path))
{
Expand Down
15 changes: 13 additions & 2 deletions Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,19 @@ public PluginConfiguration GetConfig(Guid userId)
}
var stremio = _stremioFactory.Create(cfg);
cfg.Stremio = stremio;
cfg.MovieFolder = _manager.TryGetMovieFolder(cfg);
cfg.SeriesFolder = _manager.TryGetSeriesFolder(cfg);

cfg.MovieFolder = _manager.TryGetConfigFolder(cfg.MoviePath);
if (cfg.MovieFolder is null)
{
_log.LogError($"Unable to retrieve movie folder for user '{userId}', Gelato will not be able to function properly! Please add the path for defined in Gelato setting to a library, start a library scan and restart Jellyfin.");
}

cfg.SeriesFolder = _manager.TryGetConfigFolder(cfg.SeriesPath);
if (cfg.SeriesFolder is null)
{
_log.LogError($"Unable to retrieve series folder for user '{userId}', Gelato will not be able to function properly! Please add the path for defined in Gelato setting to a library, start a library scan and restart Jellyfin.");
}

return cfg;
}
);
Expand Down
Loading