mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
#680 - improve name comparisons
This commit is contained in:
parent
d2ed436a6f
commit
92c76de2ba
@ -1,5 +1,6 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using MediaBrowser.Model.Dto;
|
using MediaBrowser.Model.Dto;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using System;
|
using System;
|
||||||
@ -91,6 +92,16 @@ namespace MediaBrowser.Model.LiveTv
|
|||||||
/// <value>The original primary image aspect ratio.</value>
|
/// <value>The original primary image aspect ratio.</value>
|
||||||
public double? OriginalPrimaryImageAspectRatio { get; set; }
|
public double? OriginalPrimaryImageAspectRatio { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating whether this instance has primary image.
|
||||||
|
/// </summary>
|
||||||
|
/// <value><c>true</c> if this instance has primary image; otherwise, <c>false</c>.</value>
|
||||||
|
[IgnoreDataMember]
|
||||||
|
public bool HasPrimaryImage
|
||||||
|
{
|
||||||
|
get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Primary); }
|
||||||
|
}
|
||||||
|
|
||||||
public ChannelInfoDto()
|
public ChannelInfoDto()
|
||||||
{
|
{
|
||||||
ImageTags = new Dictionary<ImageType, Guid>();
|
ImageTags = new Dictionary<ImageType, Guid>();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using MediaBrowser.Model.Dto;
|
using MediaBrowser.Model.Dto;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using System;
|
using System;
|
||||||
@ -190,6 +191,16 @@ namespace MediaBrowser.Model.LiveTv
|
|||||||
/// <value><c>true</c> if this instance is premiere; otherwise, <c>false</c>.</value>
|
/// <value><c>true</c> if this instance is premiere; otherwise, <c>false</c>.</value>
|
||||||
public bool IsPremiere { get; set; }
|
public bool IsPremiere { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating whether this instance has primary image.
|
||||||
|
/// </summary>
|
||||||
|
/// <value><c>true</c> if this instance has primary image; otherwise, <c>false</c>.</value>
|
||||||
|
[IgnoreDataMember]
|
||||||
|
public bool HasPrimaryImage
|
||||||
|
{
|
||||||
|
get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Primary); }
|
||||||
|
}
|
||||||
|
|
||||||
public ProgramInfoDto()
|
public ProgramInfoDto()
|
||||||
{
|
{
|
||||||
Genres = new List<string>();
|
Genres = new List<string>();
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using MediaBrowser.Model.Dto;
|
using MediaBrowser.Model.Dto;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using System;
|
using System;
|
||||||
@ -224,6 +225,16 @@ namespace MediaBrowser.Model.LiveTv
|
|||||||
/// <value>The user data.</value>
|
/// <value>The user data.</value>
|
||||||
public UserItemDataDto UserData { get; set; }
|
public UserItemDataDto UserData { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating whether this instance has primary image.
|
||||||
|
/// </summary>
|
||||||
|
/// <value><c>true</c> if this instance has primary image; otherwise, <c>false</c>.</value>
|
||||||
|
[IgnoreDataMember]
|
||||||
|
public bool HasPrimaryImage
|
||||||
|
{
|
||||||
|
get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Primary); }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the type.
|
/// Gets or sets the type.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
using MediaBrowser.Model.Entities;
|
||||||
|
|
||||||
namespace MediaBrowser.Model.LiveTv
|
namespace MediaBrowser.Model.LiveTv
|
||||||
{
|
{
|
||||||
@ -133,8 +135,25 @@ namespace MediaBrowser.Model.LiveTv
|
|||||||
/// <value><c>true</c> if this instance is post padding required; otherwise, <c>false</c>.</value>
|
/// <value><c>true</c> if this instance is post padding required; otherwise, <c>false</c>.</value>
|
||||||
public bool IsPostPaddingRequired { get; set; }
|
public bool IsPostPaddingRequired { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the image tags.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The image tags.</value>
|
||||||
|
public Dictionary<ImageType, Guid> ImageTags { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating whether this instance has primary image.
|
||||||
|
/// </summary>
|
||||||
|
/// <value><c>true</c> if this instance has primary image; otherwise, <c>false</c>.</value>
|
||||||
|
[IgnoreDataMember]
|
||||||
|
public bool HasPrimaryImage
|
||||||
|
{
|
||||||
|
get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Primary); }
|
||||||
|
}
|
||||||
|
|
||||||
public SeriesTimerInfoDto()
|
public SeriesTimerInfoDto()
|
||||||
{
|
{
|
||||||
|
ImageTags = new Dictionary<ImageType, Guid>();
|
||||||
Days = new List<DayOfWeek>();
|
Days = new List<DayOfWeek>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,6 +130,9 @@ namespace MediaBrowser.Model.LiveTv
|
|||||||
/// <value>The program information.</value>
|
/// <value>The program information.</value>
|
||||||
public ProgramInfoDto ProgramInfo { get; set; }
|
public ProgramInfoDto ProgramInfo { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Occurs when a property value changes.
|
||||||
|
/// </summary>
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using MediaBrowser.Common.IO;
|
using System.Text;
|
||||||
|
using MediaBrowser.Common.IO;
|
||||||
using MediaBrowser.Controller.Entities.TV;
|
using MediaBrowser.Controller.Entities.TV;
|
||||||
using MediaBrowser.Controller.FileOrganization;
|
using MediaBrowser.Controller.FileOrganization;
|
||||||
using MediaBrowser.Controller.IO;
|
using MediaBrowser.Controller.IO;
|
||||||
@ -429,9 +430,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
|
|||||||
{
|
{
|
||||||
var score = 0;
|
var score = 0;
|
||||||
|
|
||||||
// TODO: Improve this - should ignore spaces, periods, underscores, most likely all symbols and
|
if (IsNameMatch(sortedName, series.Name))
|
||||||
// possibly remove sorting words like "the", "and", etc.
|
|
||||||
if (string.Equals(sortedName, series.Name, StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
{
|
||||||
score++;
|
score++;
|
||||||
|
|
||||||
@ -452,6 +451,49 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
|
|||||||
return new Tuple<Series, int>(series, score);
|
return new Tuple<Series, int>(series, score);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool IsNameMatch(string name1, string name2)
|
||||||
|
{
|
||||||
|
name1 = GetComparableName(name1);
|
||||||
|
name2 = GetComparableName(name2);
|
||||||
|
|
||||||
|
return string.Equals(name1, name2, StringComparison.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetComparableName(string name)
|
||||||
|
{
|
||||||
|
// TODO: Improve this - should ignore spaces, periods, underscores, most likely all symbols and
|
||||||
|
// possibly remove sorting words like "the", "and", etc.
|
||||||
|
|
||||||
|
name = RemoveDiacritics(name);
|
||||||
|
|
||||||
|
name = " " + name.ToLower() + " ";
|
||||||
|
|
||||||
|
name = name.Replace(".", " ")
|
||||||
|
.Replace("_", " ")
|
||||||
|
.Replace("&", " ")
|
||||||
|
.Replace("!", " ")
|
||||||
|
.Replace(",", " ")
|
||||||
|
.Replace(" a ", string.Empty)
|
||||||
|
.Replace(" the ", string.Empty)
|
||||||
|
.Replace(" ", string.Empty);
|
||||||
|
|
||||||
|
return name.Trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes the diacritics.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text">The text.</param>
|
||||||
|
/// <returns>System.String.</returns>
|
||||||
|
private string RemoveDiacritics(string text)
|
||||||
|
{
|
||||||
|
return string.Concat(
|
||||||
|
text.Normalize(NormalizationForm.FormD)
|
||||||
|
.Where(ch => CharUnicodeInfo.GetUnicodeCategory(ch) !=
|
||||||
|
UnicodeCategory.NonSpacingMark)
|
||||||
|
).Normalize(NormalizationForm.FormC);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deletes the left over files.
|
/// Deletes the left over files.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user