mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
update smart match feature
This commit is contained in:
parent
b398b4eaab
commit
0e49ccfd07
@ -1,5 +1,4 @@
|
|||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
namespace MediaBrowser.Model.FileOrganization
|
namespace MediaBrowser.Model.FileOrganization
|
||||||
{
|
{
|
||||||
public class AutoOrganizeOptions
|
public class AutoOrganizeOptions
|
||||||
@ -14,12 +13,12 @@ namespace MediaBrowser.Model.FileOrganization
|
|||||||
/// Gets or sets a list of smart match entries.
|
/// Gets or sets a list of smart match entries.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The smart match entries.</value>
|
/// <value>The smart match entries.</value>
|
||||||
public List<SmartMatchInfo> SmartMatchInfos { get; set; }
|
public SmartMatchInfo[] SmartMatchInfos { get; set; }
|
||||||
|
|
||||||
public AutoOrganizeOptions()
|
public AutoOrganizeOptions()
|
||||||
{
|
{
|
||||||
TvOptions = new TvFileOrganizationOptions();
|
TvOptions = new TvFileOrganizationOptions();
|
||||||
SmartMatchInfos = new List<SmartMatchInfo>();
|
SmartMatchInfos = new SmartMatchInfo[]{};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,16 @@
|
|||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Model.FileOrganization
|
namespace MediaBrowser.Model.FileOrganization
|
||||||
{
|
{
|
||||||
public class SmartMatchInfo
|
public class SmartMatchInfo
|
||||||
{
|
{
|
||||||
public Guid Id { get; set; }
|
public string Id { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public FileOrganizerType OrganizerType { get; set; }
|
public FileOrganizerType OrganizerType { get; set; }
|
||||||
public List<string> MatchStrings { get; set; }
|
public string[] MatchStrings { get; set; }
|
||||||
|
|
||||||
public SmartMatchInfo()
|
public SmartMatchInfo()
|
||||||
{
|
{
|
||||||
MatchStrings = new List<string>();
|
MatchStrings = new string[] { };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -301,20 +301,25 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
|
|||||||
|
|
||||||
private void SaveSmartMatchString(string matchString, Series series, AutoOrganizeOptions options)
|
private void SaveSmartMatchString(string matchString, Series series, AutoOrganizeOptions options)
|
||||||
{
|
{
|
||||||
SmartMatchInfo info = options.SmartMatchInfos.Find(i => i.Id == series.Id);
|
var seriesIdString = series.Id.ToString("N");
|
||||||
|
SmartMatchInfo info = options.SmartMatchInfos.FirstOrDefault(i => string.Equals(i.Id, seriesIdString));
|
||||||
|
|
||||||
if (info == null)
|
if (info == null)
|
||||||
{
|
{
|
||||||
info = new SmartMatchInfo();
|
info = new SmartMatchInfo();
|
||||||
info.Id = series.Id;
|
info.Id = series.Id.ToString("N");
|
||||||
info.OrganizerType = FileOrganizerType.Episode;
|
info.OrganizerType = FileOrganizerType.Episode;
|
||||||
info.Name = series.Name;
|
info.Name = series.Name;
|
||||||
options.SmartMatchInfos.Add(info);
|
var list = options.SmartMatchInfos.ToList();
|
||||||
|
list.Add(info);
|
||||||
|
options.SmartMatchInfos = list.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!info.MatchStrings.Contains(matchString, StringComparer.OrdinalIgnoreCase))
|
if (!info.MatchStrings.Contains(matchString, StringComparer.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
info.MatchStrings.Add(matchString);
|
var list = info.MatchStrings.ToList();
|
||||||
|
list.Add(matchString);
|
||||||
|
info.MatchStrings = list.ToArray();
|
||||||
_config.SaveAutoOrganizeOptions(options);
|
_config.SaveAutoOrganizeOptions(options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -487,14 +492,14 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
|
|||||||
|
|
||||||
if (series == null)
|
if (series == null)
|
||||||
{
|
{
|
||||||
SmartMatchInfo info = options.SmartMatchInfos.Where(e => e.MatchStrings.Contains(seriesName, StringComparer.OrdinalIgnoreCase)).FirstOrDefault();
|
SmartMatchInfo info = options.SmartMatchInfos.FirstOrDefault(e => e.MatchStrings.Contains(seriesName, StringComparer.OrdinalIgnoreCase));
|
||||||
|
|
||||||
if (info != null)
|
if (info != null)
|
||||||
{
|
{
|
||||||
series = _libraryManager.RootFolder.GetRecursiveChildren(i => i is Series)
|
series = _libraryManager.RootFolder
|
||||||
|
.GetRecursiveChildren(i => i is Series)
|
||||||
.Cast<Series>()
|
.Cast<Series>()
|
||||||
.Where(i => i.Id == info.Id)
|
.FirstOrDefault(i => string.Equals(i.Id.ToString("N"), info.Id));
|
||||||
.FirstOrDefault();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,12 +140,12 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
|
|||||||
|
|
||||||
var options = GetAutoOrganizeptions();
|
var options = GetAutoOrganizeptions();
|
||||||
|
|
||||||
var items = options.SmartMatchInfos.Skip(query.StartIndex ?? 0).Take(query.Limit ?? Int32.MaxValue);
|
var items = options.SmartMatchInfos.Skip(query.StartIndex ?? 0).Take(query.Limit ?? Int32.MaxValue).ToArray();
|
||||||
|
|
||||||
return new QueryResult<SmartMatchInfo>()
|
return new QueryResult<SmartMatchInfo>()
|
||||||
{
|
{
|
||||||
Items = items.ToArray(),
|
Items = items,
|
||||||
TotalRecordCount = items.Count()
|
TotalRecordCount = options.SmartMatchInfos.Length
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,14 +165,19 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
|
|||||||
|
|
||||||
var options = GetAutoOrganizeptions();
|
var options = GetAutoOrganizeptions();
|
||||||
|
|
||||||
SmartMatchInfo info = options.SmartMatchInfos.Find(i => i.Id == Id);
|
SmartMatchInfo info = options.SmartMatchInfos.FirstOrDefault(i => string.Equals(i.Id, IdString));
|
||||||
|
|
||||||
if (info != null && info.MatchStrings.Contains(matchString))
|
if (info != null && info.MatchStrings.Contains(matchString))
|
||||||
{
|
{
|
||||||
info.MatchStrings.Remove(matchString);
|
var list = info.MatchStrings.ToList();
|
||||||
if (info.MatchStrings.Count == 0)
|
list.Remove(matchString);
|
||||||
|
info.MatchStrings = list.ToArray();
|
||||||
|
|
||||||
|
if (info.MatchStrings.Length == 0)
|
||||||
{
|
{
|
||||||
options.SmartMatchInfos.Remove(info);
|
var infos = options.SmartMatchInfos.ToList();
|
||||||
|
infos.Remove(info);
|
||||||
|
options.SmartMatchInfos = infos.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
_config.SaveAutoOrganizeOptions(options);
|
_config.SaveAutoOrganizeOptions(options);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user