parent
bd88e162ee
commit
5744ca3bba
@ -0,0 +1,5 @@
|
|||||||
|
namespace Recyclarr.Gui.Shared;
|
||||||
|
|
||||||
|
public partial class MainLayout
|
||||||
|
{
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
using ReactiveUI;
|
||||||
|
using TrashLib.Radarr.CustomFormat.Models;
|
||||||
|
|
||||||
|
namespace Recyclarr.Gui.ViewModels;
|
||||||
|
|
||||||
|
public class CustomFormatGroupViewModel : ReactiveObject
|
||||||
|
{
|
||||||
|
public string GroupName { get; set; }
|
||||||
|
public ICollection<CustomFormatGroupItem> CustomFormats { get; set; }
|
||||||
|
|
||||||
|
public CustomFormatGroupViewModel()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CustomFormatViewModel : ReactiveObject
|
||||||
|
{
|
||||||
|
public CustomFormatViewModel()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using TrashLib.Radarr.CustomFormat.Models;
|
||||||
|
|
||||||
|
namespace TrashLib.Radarr.CustomFormat.Guide;
|
||||||
|
|
||||||
|
public interface ICustomFormatGroupParser
|
||||||
|
{
|
||||||
|
IDictionary<string, ReadOnlyCollection<CustomFormatGroupItem>> Parse();
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
namespace TrashLib.Radarr.CustomFormat.Models;
|
||||||
|
|
||||||
|
public record CustomFormatGroupItem(string Name, string Anchor);
|
@ -0,0 +1,34 @@
|
|||||||
|
using Common.Extensions;
|
||||||
|
using TrashLib.Radarr.CustomFormat.Guide;
|
||||||
|
using TrashLib.Radarr.CustomFormat.Models;
|
||||||
|
|
||||||
|
namespace TrashLib.Radarr.CustomFormat.Processors;
|
||||||
|
|
||||||
|
public class CustomFormatLookup
|
||||||
|
{
|
||||||
|
private readonly ICustomFormatGroupParser _parser;
|
||||||
|
private readonly IRadarrGuideService _guide;
|
||||||
|
|
||||||
|
public CustomFormatLookup(ICustomFormatGroupParser parser, IRadarrGuideService guide)
|
||||||
|
{
|
||||||
|
_parser = parser;
|
||||||
|
_guide = guide;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static CustomFormatData? MatchDataWithCellEntry(ICollection<CustomFormatData> guideCfs,
|
||||||
|
CustomFormatGroupItem groupItem)
|
||||||
|
{
|
||||||
|
return guideCfs.FirstOrDefault(x => x.FileName.EqualsIgnoreCase(groupItem.Anchor)) ??
|
||||||
|
guideCfs.FirstOrDefault(x => x.Name.EqualsIgnoreCase(groupItem.Name));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dictionary<string, List<CustomFormatData>> MapAllCustomFormats()
|
||||||
|
{
|
||||||
|
var guideCfs = _guide.GetCustomFormatData();
|
||||||
|
var groups = _parser.Parse();
|
||||||
|
|
||||||
|
return groups.ToDictionary(
|
||||||
|
x => x.Key,
|
||||||
|
x => x.Value.Select(y => MatchDataWithCellEntry(guideCfs, y)).NotNull().ToList());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue