Kavita/API/Extensions/SeriesExtensions.cs
Joseph Milazzo 81dfd63250
Feature/performance pdf (#426)
#  Added
- Added: Added series format information to the search typeahead to help identify duplicate series in libraries

# Fixed
- Fixed: Fixed accent color not looking well on light theme
- Fixed: Attempted to fix the memory issues with PDF reading on Docker. Uses a Memory Pool for streams and removes a bitmap operation for fixing books with transparent backgrounds (#424)

# Changed
- Changed: Refactored download logs to use the same download code as rest of Kavita 

# Dev stuff
- Added timeout for Regex's to make sure during matching, malicious filenames doesn't crash user system
- Refactored a missing GetCoverImage to use Series Format rather than old Library Type

==================================================
* Added Timeout for Regex matching to ensure malicious filenames don't crash system

* Refactored GetCoverImage to use series format rather than library type

* Refactored download logs to use the download service

* Fixed accent color not looking well on light theme

* Refactored series format into dedicated component and added to search results

* Switch to using MemoryManager for Streams to attempt to minimize GC pressure and reduced bitmap manipulation for transparency hack.
2021-07-24 16:17:13 -05:00

50 lines
2.5 KiB
C#

using System.Collections.Generic;
using System.Linq;
using API.Entities;
using API.Parser;
using API.Services.Tasks.Scanner;
namespace API.Extensions
{
public static class SeriesExtensions
{
/// <summary>
/// Checks against all the name variables of the Series if it matches anything in the list.
/// </summary>
/// <param name="series"></param>
/// <param name="list"></param>
/// <returns></returns>
public static bool NameInList(this Series series, IEnumerable<string> list)
{
return list.Any(name => Parser.Parser.Normalize(name) == series.NormalizedName || Parser.Parser.Normalize(name) == Parser.Parser.Normalize(series.Name)
|| name == series.Name || name == series.LocalizedName || name == series.OriginalName || Parser.Parser.Normalize(name) == Parser.Parser.Normalize(series.OriginalName));
}
/// <summary>
/// Checks against all the name variables of the Series if it matches anything in the list. Includes a check against the Format of the Series
/// </summary>
/// <param name="series"></param>
/// <param name="list"></param>
/// <returns></returns>
public static bool NameInList(this Series series, IEnumerable<ParsedSeries> list)
{
return list.Any(name => Parser.Parser.Normalize(name.Name) == series.NormalizedName || Parser.Parser.Normalize(name.Name) == Parser.Parser.Normalize(series.Name)
|| name.Name == series.Name || name.Name == series.LocalizedName || name.Name == series.OriginalName || Parser.Parser.Normalize(name.Name) == Parser.Parser.Normalize(series.OriginalName) && series.Format == name.Format);
}
/// <summary>
/// Checks against all the name variables of the Series if it matches the <see cref="ParserInfo"/>
/// </summary>
/// <param name="series"></param>
/// <param name="info"></param>
/// <returns></returns>
public static bool NameInParserInfo(this Series series, ParserInfo info)
{
if (info == null) return false;
return Parser.Parser.Normalize(info.Series) == series.NormalizedName || Parser.Parser.Normalize(info.Series) == Parser.Parser.Normalize(series.Name)
|| info.Series == series.Name || info.Series == series.LocalizedName || info.Series == series.OriginalName
|| Parser.Parser.Normalize(info.Series) == Parser.Parser.Normalize(series.OriginalName);
}
}
}