Apply review suggestions

This commit is contained in:
Shadowghost 2023-01-27 15:49:08 +01:00
parent 15efb9935c
commit 5cdb0c7932
4 changed files with 46 additions and 187 deletions

View File

@ -3202,7 +3202,8 @@ namespace Emby.Server.Implementations.Data
return IsAlphaNumeric(value); return IsAlphaNumeric(value);
} }
private List<string> GetWhereClauses(InternalItemsQuery query, IStatement statement) #nullable enable
private List<string> GetWhereClauses(InternalItemsQuery query, IStatement? statement)
{ {
if (query.IsResumable ?? false) if (query.IsResumable ?? false)
{ {
@ -3622,12 +3623,8 @@ namespace Emby.Server.Implementations.Data
clauseBuilder.Append("(guid in (select itemid from People where Name = (select Name from TypedBaseItems where guid=") clauseBuilder.Append("(guid in (select itemid from People where Name = (select Name from TypedBaseItems where guid=")
.Append(paramName) .Append(paramName)
.Append("))) OR "); .Append("))) OR ");
query.PersonIds[i].TryWriteBytes(idBytes);
if (statement is not null) statement?.TryBind(paramName, idBytes);
{
query.PersonIds[i].TryWriteBytes(idBytes);
statement.TryBind(paramName, idBytes);
}
} }
// Remove last " OR " // Remove last " OR "
@ -3677,7 +3674,6 @@ namespace Emby.Server.Implementations.Data
if (statement is not null) if (statement is not null)
{ {
nameContains = FixUnicodeChars(nameContains); nameContains = FixUnicodeChars(nameContains);
statement.TryBind("@NameContains", "%" + GetCleanValue(nameContains) + "%"); statement.TryBind("@NameContains", "%" + GetCleanValue(nameContains) + "%");
} }
} }
@ -3803,13 +3799,8 @@ namespace Emby.Server.Implementations.Data
foreach (var artistId in query.ArtistIds) foreach (var artistId in query.ArtistIds)
{ {
var paramName = "@ArtistIds" + index; var paramName = "@ArtistIds" + index;
clauses.Add("(guid in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=" + paramName + ") and Type<=1))"); clauses.Add("(guid in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=" + paramName + ") and Type<=1))");
if (statement is not null) statement?.TryBind(paramName, artistId);
{
statement.TryBind(paramName, artistId);
}
index++; index++;
} }
@ -3824,13 +3815,8 @@ namespace Emby.Server.Implementations.Data
foreach (var artistId in query.AlbumArtistIds) foreach (var artistId in query.AlbumArtistIds)
{ {
var paramName = "@ArtistIds" + index; var paramName = "@ArtistIds" + index;
clauses.Add("(guid in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=" + paramName + ") and Type=1))"); clauses.Add("(guid in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=" + paramName + ") and Type=1))");
if (statement is not null) statement?.TryBind(paramName, artistId);
{
statement.TryBind(paramName, artistId);
}
index++; index++;
} }
@ -3845,13 +3831,8 @@ namespace Emby.Server.Implementations.Data
foreach (var artistId in query.ContributingArtistIds) foreach (var artistId in query.ContributingArtistIds)
{ {
var paramName = "@ArtistIds" + index; var paramName = "@ArtistIds" + index;
clauses.Add("((select CleanName from TypedBaseItems where guid=" + paramName + ") in (select CleanValue from ItemValues where ItemId=Guid and Type=0) AND (select CleanName from TypedBaseItems where guid=" + paramName + ") not in (select CleanValue from ItemValues where ItemId=Guid and Type=1))"); clauses.Add("((select CleanName from TypedBaseItems where guid=" + paramName + ") in (select CleanValue from ItemValues where ItemId=Guid and Type=0) AND (select CleanName from TypedBaseItems where guid=" + paramName + ") not in (select CleanValue from ItemValues where ItemId=Guid and Type=1))");
if (statement is not null) statement?.TryBind(paramName, artistId);
{
statement.TryBind(paramName, artistId);
}
index++; index++;
} }
@ -3866,13 +3847,8 @@ namespace Emby.Server.Implementations.Data
foreach (var albumId in query.AlbumIds) foreach (var albumId in query.AlbumIds)
{ {
var paramName = "@AlbumIds" + index; var paramName = "@AlbumIds" + index;
clauses.Add("Album in (select Name from typedbaseitems where guid=" + paramName + ")"); clauses.Add("Album in (select Name from typedbaseitems where guid=" + paramName + ")");
if (statement is not null) statement?.TryBind(paramName, albumId);
{
statement.TryBind(paramName, albumId);
}
index++; index++;
} }
@ -3887,13 +3863,8 @@ namespace Emby.Server.Implementations.Data
foreach (var artistId in query.ExcludeArtistIds) foreach (var artistId in query.ExcludeArtistIds)
{ {
var paramName = "@ExcludeArtistId" + index; var paramName = "@ExcludeArtistId" + index;
clauses.Add("(guid not in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=" + paramName + ") and Type<=1))"); clauses.Add("(guid not in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=" + paramName + ") and Type<=1))");
if (statement is not null) statement?.TryBind(paramName, artistId);
{
statement.TryBind(paramName, artistId);
}
index++; index++;
} }
@ -3908,13 +3879,8 @@ namespace Emby.Server.Implementations.Data
foreach (var genreId in query.GenreIds) foreach (var genreId in query.GenreIds)
{ {
var paramName = "@GenreId" + index; var paramName = "@GenreId" + index;
clauses.Add("(guid in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=" + paramName + ") and Type=2))"); clauses.Add("(guid in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=" + paramName + ") and Type=2))");
if (statement is not null) statement?.TryBind(paramName, genreId);
{
statement.TryBind(paramName, genreId);
}
index++; index++;
} }
@ -3929,11 +3895,7 @@ namespace Emby.Server.Implementations.Data
foreach (var item in query.Genres) foreach (var item in query.Genres)
{ {
clauses.Add("@Genre" + index + " in (select CleanValue from ItemValues where ItemId=Guid and Type=2)"); clauses.Add("@Genre" + index + " in (select CleanValue from ItemValues where ItemId=Guid and Type=2)");
if (statement is not null) statement?.TryBind("@Genre" + index, GetCleanValue(item));
{
statement.TryBind("@Genre" + index, GetCleanValue(item));
}
index++; index++;
} }
@ -3948,11 +3910,7 @@ namespace Emby.Server.Implementations.Data
foreach (var item in tags) foreach (var item in tags)
{ {
clauses.Add("@Tag" + index + " in (select CleanValue from ItemValues where ItemId=Guid and Type=4)"); clauses.Add("@Tag" + index + " in (select CleanValue from ItemValues where ItemId=Guid and Type=4)");
if (statement is not null) statement?.TryBind("@Tag" + index, GetCleanValue(item));
{
statement.TryBind("@Tag" + index, GetCleanValue(item));
}
index++; index++;
} }
@ -3967,11 +3925,7 @@ namespace Emby.Server.Implementations.Data
foreach (var item in excludeTags) foreach (var item in excludeTags)
{ {
clauses.Add("@ExcludeTag" + index + " not in (select CleanValue from ItemValues where ItemId=Guid and Type=4)"); clauses.Add("@ExcludeTag" + index + " not in (select CleanValue from ItemValues where ItemId=Guid and Type=4)");
if (statement is not null) statement?.TryBind("@ExcludeTag" + index, GetCleanValue(item));
{
statement.TryBind("@ExcludeTag" + index, GetCleanValue(item));
}
index++; index++;
} }
@ -3986,14 +3940,8 @@ namespace Emby.Server.Implementations.Data
foreach (var studioId in query.StudioIds) foreach (var studioId in query.StudioIds)
{ {
var paramName = "@StudioId" + index; var paramName = "@StudioId" + index;
clauses.Add("(guid in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=" + paramName + ") and Type=3))"); clauses.Add("(guid in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=" + paramName + ") and Type=3))");
statement?.TryBind(paramName, studioId);
if (statement is not null)
{
statement.TryBind(paramName, studioId);
}
index++; index++;
} }
@ -4008,11 +3956,7 @@ namespace Emby.Server.Implementations.Data
foreach (var item in query.OfficialRatings) foreach (var item in query.OfficialRatings)
{ {
clauses.Add("OfficialRating=@OfficialRating" + index); clauses.Add("OfficialRating=@OfficialRating" + index);
if (statement is not null) statement?.TryBind("@OfficialRating" + index, item);
{
statement.TryBind("@OfficialRating" + index, item);
}
index++; index++;
} }
@ -4021,25 +3965,19 @@ namespace Emby.Server.Implementations.Data
} }
var ratingClause = "("; var ratingClause = "(";
if (query.HasParentalRating.HasValue && query.HasParentalRating.Value) if (query.HasParentalRating ?? false)
{ {
ratingClause += "InheritedParentalRatingValue not null"; ratingClause += "InheritedParentalRatingValue not null";
if (query.MinParentalRating.HasValue) if (query.MinParentalRating.HasValue)
{ {
ratingClause += " AND InheritedParentalRatingValue >= @MinParentalRating"; ratingClause += " AND InheritedParentalRatingValue >= @MinParentalRating";
if (statement is not null) statement?.TryBind("@MinParentalRating", query.MinParentalRating.Value);
{
statement.TryBind("@MinParentalRating", query.MinParentalRating.Value);
}
} }
if (query.MaxParentalRating.HasValue) if (query.MaxParentalRating.HasValue)
{ {
ratingClause += " AND InheritedParentalRatingValue <= @MaxParentalRating"; ratingClause += " AND InheritedParentalRatingValue <= @MaxParentalRating";
if (statement is not null) statement?.TryBind("@MaxParentalRating", query.MaxParentalRating.Value);
{
statement.TryBind("@MaxParentalRating", query.MaxParentalRating.Value);
}
} }
} }
else if (query.BlockUnratedItems.Length > 0) else if (query.BlockUnratedItems.Length > 0)
@ -4049,7 +3987,7 @@ namespace Emby.Server.Implementations.Data
string blockedUnratedItems = string.Join(',', query.BlockUnratedItems.Select(_ => paramName + index++)); string blockedUnratedItems = string.Join(',', query.BlockUnratedItems.Select(_ => paramName + index++));
ratingClause += "(InheritedParentalRatingValue is null AND UnratedType not in (" + blockedUnratedItems + "))"; ratingClause += "(InheritedParentalRatingValue is null AND UnratedType not in (" + blockedUnratedItems + "))";
if (statement != null) if (statement is not null)
{ {
for (var ind = 0; ind < query.BlockUnratedItems.Length; ind++) for (var ind = 0; ind < query.BlockUnratedItems.Length; ind++)
{ {
@ -4065,10 +4003,7 @@ namespace Emby.Server.Implementations.Data
if (query.MinParentalRating.HasValue) if (query.MinParentalRating.HasValue)
{ {
ratingClause += "InheritedParentalRatingValue >= @MinParentalRating"; ratingClause += "InheritedParentalRatingValue >= @MinParentalRating";
if (statement != null) statement?.TryBind("@MinParentalRating", query.MinParentalRating.Value);
{
statement.TryBind("@MinParentalRating", query.MinParentalRating.Value);
}
} }
if (query.MaxParentalRating.HasValue) if (query.MaxParentalRating.HasValue)
@ -4079,10 +4014,7 @@ namespace Emby.Server.Implementations.Data
} }
ratingClause += "InheritedParentalRatingValue <= @MaxParentalRating"; ratingClause += "InheritedParentalRatingValue <= @MaxParentalRating";
if (statement != null) statement?.TryBind("@MaxParentalRating", query.MaxParentalRating.Value);
{
statement.TryBind("@MaxParentalRating", query.MaxParentalRating.Value);
}
} }
if (query.MinParentalRating.HasValue || query.MaxParentalRating.HasValue) if (query.MinParentalRating.HasValue || query.MaxParentalRating.HasValue)
@ -4098,18 +4030,12 @@ namespace Emby.Server.Implementations.Data
else if (query.MinParentalRating.HasValue) else if (query.MinParentalRating.HasValue)
{ {
ratingClause += "InheritedParentalRatingValue is null OR (InheritedParentalRatingValue >= @MinParentalRating"; ratingClause += "InheritedParentalRatingValue is null OR (InheritedParentalRatingValue >= @MinParentalRating";
if (statement != null) statement?.TryBind("@MinParentalRating", query.MinParentalRating.Value);
{
statement.TryBind("@MinParentalRating", query.MinParentalRating.Value);
}
if (query.MaxParentalRating.HasValue) if (query.MaxParentalRating.HasValue)
{ {
ratingClause += " AND InheritedParentalRatingValue <= @MaxParentalRating"; ratingClause += " AND InheritedParentalRatingValue <= @MaxParentalRating";
if (statement != null) statement?.TryBind("@MaxParentalRating", query.MaxParentalRating.Value);
{
statement.TryBind("@MaxParentalRating", query.MaxParentalRating.Value);
}
} }
ratingClause += ")"; ratingClause += ")";
@ -4117,12 +4043,9 @@ namespace Emby.Server.Implementations.Data
else if (query.MaxParentalRating.HasValue) else if (query.MaxParentalRating.HasValue)
{ {
ratingClause += "InheritedParentalRatingValue is null OR InheritedParentalRatingValue <= @MaxParentalRating"; ratingClause += "InheritedParentalRatingValue is null OR InheritedParentalRatingValue <= @MaxParentalRating";
if (statement != null) statement?.TryBind("@MaxParentalRating", query.MaxParentalRating.Value);
{
statement.TryBind("@MaxParentalRating", query.MaxParentalRating.Value);
}
} }
else if (query.HasParentalRating.HasValue && !query.HasParentalRating.Value) else if (!query.HasParentalRating ?? false)
{ {
ratingClause += "InheritedParentalRatingValue is null"; ratingClause += "InheritedParentalRatingValue is null";
} }
@ -4171,37 +4094,25 @@ namespace Emby.Server.Implementations.Data
if (!string.IsNullOrWhiteSpace(query.HasNoAudioTrackWithLanguage)) if (!string.IsNullOrWhiteSpace(query.HasNoAudioTrackWithLanguage))
{ {
whereClauses.Add("((select language from MediaStreams where MediaStreams.ItemId=A.Guid and MediaStreams.StreamType='Audio' and MediaStreams.Language=@HasNoAudioTrackWithLanguage limit 1) is null)"); whereClauses.Add("((select language from MediaStreams where MediaStreams.ItemId=A.Guid and MediaStreams.StreamType='Audio' and MediaStreams.Language=@HasNoAudioTrackWithLanguage limit 1) is null)");
if (statement is not null) statement?.TryBind("@HasNoAudioTrackWithLanguage", query.HasNoAudioTrackWithLanguage);
{
statement.TryBind("@HasNoAudioTrackWithLanguage", query.HasNoAudioTrackWithLanguage);
}
} }
if (!string.IsNullOrWhiteSpace(query.HasNoInternalSubtitleTrackWithLanguage)) if (!string.IsNullOrWhiteSpace(query.HasNoInternalSubtitleTrackWithLanguage))
{ {
whereClauses.Add("((select language from MediaStreams where MediaStreams.ItemId=A.Guid and MediaStreams.StreamType='Subtitle' and MediaStreams.IsExternal=0 and MediaStreams.Language=@HasNoInternalSubtitleTrackWithLanguage limit 1) is null)"); whereClauses.Add("((select language from MediaStreams where MediaStreams.ItemId=A.Guid and MediaStreams.StreamType='Subtitle' and MediaStreams.IsExternal=0 and MediaStreams.Language=@HasNoInternalSubtitleTrackWithLanguage limit 1) is null)");
if (statement is not null) statement?.TryBind("@HasNoInternalSubtitleTrackWithLanguage", query.HasNoInternalSubtitleTrackWithLanguage);
{
statement.TryBind("@HasNoInternalSubtitleTrackWithLanguage", query.HasNoInternalSubtitleTrackWithLanguage);
}
} }
if (!string.IsNullOrWhiteSpace(query.HasNoExternalSubtitleTrackWithLanguage)) if (!string.IsNullOrWhiteSpace(query.HasNoExternalSubtitleTrackWithLanguage))
{ {
whereClauses.Add("((select language from MediaStreams where MediaStreams.ItemId=A.Guid and MediaStreams.StreamType='Subtitle' and MediaStreams.IsExternal=1 and MediaStreams.Language=@HasNoExternalSubtitleTrackWithLanguage limit 1) is null)"); whereClauses.Add("((select language from MediaStreams where MediaStreams.ItemId=A.Guid and MediaStreams.StreamType='Subtitle' and MediaStreams.IsExternal=1 and MediaStreams.Language=@HasNoExternalSubtitleTrackWithLanguage limit 1) is null)");
if (statement is not null) statement?.TryBind("@HasNoExternalSubtitleTrackWithLanguage", query.HasNoExternalSubtitleTrackWithLanguage);
{
statement.TryBind("@HasNoExternalSubtitleTrackWithLanguage", query.HasNoExternalSubtitleTrackWithLanguage);
}
} }
if (!string.IsNullOrWhiteSpace(query.HasNoSubtitleTrackWithLanguage)) if (!string.IsNullOrWhiteSpace(query.HasNoSubtitleTrackWithLanguage))
{ {
whereClauses.Add("((select language from MediaStreams where MediaStreams.ItemId=A.Guid and MediaStreams.StreamType='Subtitle' and MediaStreams.Language=@HasNoSubtitleTrackWithLanguage limit 1) is null)"); whereClauses.Add("((select language from MediaStreams where MediaStreams.ItemId=A.Guid and MediaStreams.StreamType='Subtitle' and MediaStreams.Language=@HasNoSubtitleTrackWithLanguage limit 1) is null)");
if (statement is not null) statement?.TryBind("@HasNoSubtitleTrackWithLanguage", query.HasNoSubtitleTrackWithLanguage);
{
statement.TryBind("@HasNoSubtitleTrackWithLanguage", query.HasNoSubtitleTrackWithLanguage);
}
} }
if (query.HasSubtitles.HasValue) if (query.HasSubtitles.HasValue)
@ -4251,15 +4162,11 @@ namespace Emby.Server.Implementations.Data
if (query.Years.Length == 1) if (query.Years.Length == 1)
{ {
whereClauses.Add("ProductionYear=@Years"); whereClauses.Add("ProductionYear=@Years");
if (statement is not null) statement?.TryBind("@Years", query.Years[0].ToString(CultureInfo.InvariantCulture));
{
statement.TryBind("@Years", query.Years[0].ToString(CultureInfo.InvariantCulture));
}
} }
else if (query.Years.Length > 1) else if (query.Years.Length > 1)
{ {
var val = string.Join(',', query.Years); var val = string.Join(',', query.Years);
whereClauses.Add("ProductionYear in (" + val + ")"); whereClauses.Add("ProductionYear in (" + val + ")");
} }
@ -4267,10 +4174,7 @@ namespace Emby.Server.Implementations.Data
if (isVirtualItem.HasValue) if (isVirtualItem.HasValue)
{ {
whereClauses.Add("IsVirtualItem=@IsVirtualItem"); whereClauses.Add("IsVirtualItem=@IsVirtualItem");
if (statement is not null) statement?.TryBind("@IsVirtualItem", isVirtualItem.Value);
{
statement.TryBind("@IsVirtualItem", isVirtualItem.Value);
}
} }
if (query.IsSpecialSeason.HasValue) if (query.IsSpecialSeason.HasValue)
@ -4301,31 +4205,22 @@ namespace Emby.Server.Implementations.Data
if (queryMediaTypes.Length == 1) if (queryMediaTypes.Length == 1)
{ {
whereClauses.Add("MediaType=@MediaTypes"); whereClauses.Add("MediaType=@MediaTypes");
if (statement is not null) statement?.TryBind("@MediaTypes", queryMediaTypes[0]);
{
statement.TryBind("@MediaTypes", queryMediaTypes[0]);
}
} }
else if (queryMediaTypes.Length > 1) else if (queryMediaTypes.Length > 1)
{ {
var val = string.Join(',', queryMediaTypes.Select(i => "'" + i + "'")); var val = string.Join(',', queryMediaTypes.Select(i => "'" + i + "'"));
whereClauses.Add("MediaType in (" + val + ")"); whereClauses.Add("MediaType in (" + val + ")");
} }
if (query.ItemIds.Length > 0) if (query.ItemIds.Length > 0)
{ {
var includeIds = new List<string>(); var includeIds = new List<string>();
var index = 0; var index = 0;
foreach (var id in query.ItemIds) foreach (var id in query.ItemIds)
{ {
includeIds.Add("Guid = @IncludeId" + index); includeIds.Add("Guid = @IncludeId" + index);
if (statement is not null) statement?.TryBind("@IncludeId" + index, id);
{
statement.TryBind("@IncludeId" + index, id);
}
index++; index++;
} }
@ -4335,16 +4230,11 @@ namespace Emby.Server.Implementations.Data
if (query.ExcludeItemIds.Length > 0) if (query.ExcludeItemIds.Length > 0)
{ {
var excludeIds = new List<string>(); var excludeIds = new List<string>();
var index = 0; var index = 0;
foreach (var id in query.ExcludeItemIds) foreach (var id in query.ExcludeItemIds)
{ {
excludeIds.Add("Guid <> @ExcludeId" + index); excludeIds.Add("Guid <> @ExcludeId" + index);
if (statement is not null) statement?.TryBind("@ExcludeId" + index, id);
{
statement.TryBind("@ExcludeId" + index, id);
}
index++; index++;
} }
@ -4365,11 +4255,7 @@ namespace Emby.Server.Implementations.Data
var paramName = "@ExcludeProviderId" + index; var paramName = "@ExcludeProviderId" + index;
excludeIds.Add("(ProviderIds is null or ProviderIds not like " + paramName + ")"); excludeIds.Add("(ProviderIds is null or ProviderIds not like " + paramName + ")");
if (statement is not null) statement?.TryBind(paramName, "%" + pair.Key + "=" + pair.Value + "%");
{
statement.TryBind(paramName, "%" + pair.Key + "=" + pair.Value + "%");
}
index++; index++;
break; break;
@ -4408,11 +4294,7 @@ namespace Emby.Server.Implementations.Data
hasProviderIds.Add("ProviderIds like " + paramName); hasProviderIds.Add("ProviderIds like " + paramName);
// this replaces the placeholder with a value, here: %key=val% // this replaces the placeholder with a value, here: %key=val%
if (statement is not null) statement?.TryBind(paramName, "%" + pair.Key + "=" + pair.Value + "%");
{
statement.TryBind(paramName, "%" + pair.Key + "=" + pair.Value + "%");
}
index++; index++;
break; break;
@ -4489,11 +4371,7 @@ namespace Emby.Server.Implementations.Data
if (query.AncestorIds.Length == 1) if (query.AncestorIds.Length == 1)
{ {
whereClauses.Add("Guid in (select itemId from AncestorIds where AncestorId=@AncestorId)"); whereClauses.Add("Guid in (select itemId from AncestorIds where AncestorId=@AncestorId)");
statement?.TryBind("@AncestorId", query.AncestorIds[0]);
if (statement is not null)
{
statement.TryBind("@AncestorId", query.AncestorIds[0]);
}
} }
if (query.AncestorIds.Length > 1) if (query.AncestorIds.Length > 1)
@ -4506,20 +4384,13 @@ namespace Emby.Server.Implementations.Data
{ {
var inClause = "select guid from TypedBaseItems where PresentationUniqueKey=@AncestorWithPresentationUniqueKey"; var inClause = "select guid from TypedBaseItems where PresentationUniqueKey=@AncestorWithPresentationUniqueKey";
whereClauses.Add(string.Format(CultureInfo.InvariantCulture, "Guid in (select itemId from AncestorIds where AncestorId in ({0}))", inClause)); whereClauses.Add(string.Format(CultureInfo.InvariantCulture, "Guid in (select itemId from AncestorIds where AncestorId in ({0}))", inClause));
if (statement is not null) statement?.TryBind("@AncestorWithPresentationUniqueKey", query.AncestorWithPresentationUniqueKey);
{
statement.TryBind("@AncestorWithPresentationUniqueKey", query.AncestorWithPresentationUniqueKey);
}
} }
if (!string.IsNullOrWhiteSpace(query.SeriesPresentationUniqueKey)) if (!string.IsNullOrWhiteSpace(query.SeriesPresentationUniqueKey))
{ {
whereClauses.Add("SeriesPresentationUniqueKey=@SeriesPresentationUniqueKey"); whereClauses.Add("SeriesPresentationUniqueKey=@SeriesPresentationUniqueKey");
statement?.TryBind("@SeriesPresentationUniqueKey", query.SeriesPresentationUniqueKey);
if (statement is not null)
{
statement.TryBind("@SeriesPresentationUniqueKey", query.SeriesPresentationUniqueKey);
}
} }
if (query.ExcludeInheritedTags.Length > 0) if (query.ExcludeInheritedTags.Length > 0)
@ -4668,6 +4539,7 @@ namespace Emby.Server.Implementations.Data
return whereClauses; return whereClauses;
} }
#nullable disable
/// <summary> /// <summary>
/// Formats a where clause for the specified provider. /// Formats a where clause for the specified provider.

View File

@ -297,30 +297,17 @@ namespace Emby.Server.Implementations.Localization
} }
// Try splitting by : to handle "Germany: FSK 18" // Try splitting by : to handle "Germany: FSK 18"
var index = rating.IndexOf(':', StringComparison.Ordinal); if (rating.Contains(':', StringComparison.OrdinalIgnoreCase))
if (index != -1)
{ {
var trimmedRating = rating.AsSpan(index).TrimStart(':').Trim(); return GetRatingLevel(rating.AsSpan().RightPart(':').ToString());
if (!trimmedRating.IsEmpty)
{
return GetRatingLevel(trimmedRating.ToString());
}
} }
// Remove prefix country code to handle "DE-18" // Remove prefix country code to handle "DE-18"
index = rating.IndexOf('-', StringComparison.Ordinal); if (rating.Contains('-', StringComparison.OrdinalIgnoreCase))
if (index != -1)
{ {
var trimmedRating = rating.AsSpan(index).TrimStart('-').Trim(); return GetRatingLevel(rating.AsSpan().RightPart('-').ToString());
if (!trimmedRating.IsEmpty)
{
return GetRatingLevel(trimmedRating.ToString());
}
} }
// TODO: Further improve when necessary
return null; return null;
} }

View File

@ -6,6 +6,6 @@ MG6,6
9,9 9,9
KNT,12 KNT,12
12,12 12,12
BE_14,14 14,14
16,16 16,16
18,18 18,18

1 AL 0
6 9 9
7 KNT 12
8 12 12
9 BE_14 14 14
10 16 16
11 18 18

View File

@ -27,7 +27,7 @@ namespace Jellyfin.Server.Migrations.Routines
public Guid Id => Guid.Parse("{67445D54-B895-4B24-9F4C-35CE0690EA07}"); public Guid Id => Guid.Parse("{67445D54-B895-4B24-9F4C-35CE0690EA07}");
/// <inheritdoc/> /// <inheritdoc/>
public string Name => "RemoveDuplicateExtras"; public string Name => "MigrateRatingLevels";
/// <inheritdoc/> /// <inheritdoc/>
public bool PerformOnNewInstall => false; public bool PerformOnNewInstall => false;