mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Review changes
This commit is contained in:
parent
81ac11828b
commit
1027792b16
@ -59,7 +59,7 @@ namespace Emby.Naming.Video
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool isStub = false;
|
bool isStub = false;
|
||||||
ReadOnlySpan<char> container = null;
|
ReadOnlySpan<char> container = ReadOnlySpan<char>.Empty;
|
||||||
string? stubType = null;
|
string? stubType = null;
|
||||||
|
|
||||||
if (!isDirectory)
|
if (!isDirectory)
|
||||||
@ -105,7 +105,7 @@ namespace Emby.Naming.Video
|
|||||||
|
|
||||||
return new VideoFileInfo(
|
return new VideoFileInfo(
|
||||||
path: path,
|
path: path,
|
||||||
container: container.ToString(),
|
container: container.IsEmpty ? null : container.ToString(),
|
||||||
isStub: isStub,
|
isStub: isStub,
|
||||||
name: name,
|
name: name,
|
||||||
year: year,
|
year: year,
|
||||||
|
@ -130,7 +130,7 @@ namespace Emby.Server.Implementations.Data
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool IsDbNull(this IResultSetValue result)
|
public static bool IsDbNull(this IResultSetValue result)
|
||||||
{
|
{
|
||||||
return result.SQLiteType == SQLiteType.Null;
|
return result.SQLiteType == SQLiteType.Null;
|
||||||
}
|
}
|
||||||
@ -158,12 +158,12 @@ namespace Emby.Server.Implementations.Data
|
|||||||
return result[index].ToBool();
|
return result[index].ToBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool TryGetBoolean(this IReadOnlyList<IResultSetValue> reader, int index, [NotNullWhen(true)] out bool? result)
|
public static bool TryGetBoolean(this IReadOnlyList<IResultSetValue> reader, int index, [NotNullWhen(true)] out bool result)
|
||||||
{
|
{
|
||||||
result = null;
|
|
||||||
var item = reader[index];
|
var item = reader[index];
|
||||||
if (item.IsDbNull())
|
if (item.IsDbNull())
|
||||||
{
|
{
|
||||||
|
result = default;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,12 +171,12 @@ namespace Emby.Server.Implementations.Data
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool TryGetInt32(this IReadOnlyList<IResultSetValue> reader, int index, [NotNullWhen(true)] out int? result)
|
public static bool TryGetInt32(this IReadOnlyList<IResultSetValue> reader, int index, [NotNullWhen(true)] out int result)
|
||||||
{
|
{
|
||||||
result = null;
|
|
||||||
var item = reader[index];
|
var item = reader[index];
|
||||||
if (item.IsDbNull())
|
if (item.IsDbNull())
|
||||||
{
|
{
|
||||||
|
result = default;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,12 +189,12 @@ namespace Emby.Server.Implementations.Data
|
|||||||
return result[index].ToInt64();
|
return result[index].ToInt64();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool TryGetInt64(this IReadOnlyList<IResultSetValue> reader, int index, [NotNullWhen(true)] out long? result)
|
public static bool TryGetInt64(this IReadOnlyList<IResultSetValue> reader, int index, [NotNullWhen(true)] out long result)
|
||||||
{
|
{
|
||||||
result = null;
|
|
||||||
var item = reader[index];
|
var item = reader[index];
|
||||||
if (item.IsDbNull())
|
if (item.IsDbNull())
|
||||||
{
|
{
|
||||||
|
result = default;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,12 +202,12 @@ namespace Emby.Server.Implementations.Data
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool TryGetSingle(this IReadOnlyList<IResultSetValue> reader, int index, [NotNullWhen(true)] out float? result)
|
public static bool TryGetSingle(this IReadOnlyList<IResultSetValue> reader, int index, [NotNullWhen(true)] out float result)
|
||||||
{
|
{
|
||||||
result = null;
|
|
||||||
var item = reader[index];
|
var item = reader[index];
|
||||||
if (item.IsDbNull())
|
if (item.IsDbNull())
|
||||||
{
|
{
|
||||||
|
result = default;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,12 +215,12 @@ namespace Emby.Server.Implementations.Data
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool TryGetDouble(this IReadOnlyList<IResultSetValue> reader, int index, [NotNullWhen(true)] out double? result)
|
public static bool TryGetDouble(this IReadOnlyList<IResultSetValue> reader, int index, [NotNullWhen(true)] out double result)
|
||||||
{
|
{
|
||||||
result = null;
|
|
||||||
var item = reader[index];
|
var item = reader[index];
|
||||||
if (item.IsDbNull())
|
if (item.IsDbNull())
|
||||||
{
|
{
|
||||||
|
result = default;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1346,7 +1346,7 @@ namespace Emby.Server.Implementations.Data
|
|||||||
}
|
}
|
||||||
|
|
||||||
var channelId = reader[index];
|
var channelId = reader[index];
|
||||||
if (channelId.SQLiteType != SQLiteType.Null)
|
if (!channelId.IsDbNull())
|
||||||
{
|
{
|
||||||
if (!Utf8Parser.TryParse(channelId.ToBlob(), out Guid value, out _, standardFormat: 'N'))
|
if (!Utf8Parser.TryParse(channelId.ToBlob(), out Guid value, out _, standardFormat: 'N'))
|
||||||
{
|
{
|
||||||
@ -1366,12 +1366,12 @@ namespace Emby.Server.Implementations.Data
|
|||||||
{
|
{
|
||||||
if (reader.TryGetBoolean(index++, out var isMovie))
|
if (reader.TryGetBoolean(index++, out var isMovie))
|
||||||
{
|
{
|
||||||
hasProgramAttributes.IsMovie = isMovie.Value;
|
hasProgramAttributes.IsMovie = isMovie;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reader.TryGetBoolean(index++, out var isSeries))
|
if (reader.TryGetBoolean(index++, out var isSeries))
|
||||||
{
|
{
|
||||||
hasProgramAttributes.IsSeries = isSeries.Value;
|
hasProgramAttributes.IsSeries = isSeries;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reader.TryGetString(index++, out var episodeTitle))
|
if (reader.TryGetString(index++, out var episodeTitle))
|
||||||
@ -1381,7 +1381,7 @@ namespace Emby.Server.Implementations.Data
|
|||||||
|
|
||||||
if (reader.TryGetBoolean(index++, out var isRepeat))
|
if (reader.TryGetBoolean(index++, out var isRepeat))
|
||||||
{
|
{
|
||||||
hasProgramAttributes.IsRepeat = isRepeat.Value;
|
hasProgramAttributes.IsRepeat = isRepeat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1412,7 +1412,7 @@ namespace Emby.Server.Implementations.Data
|
|||||||
{
|
{
|
||||||
if (reader.TryGetBoolean(index++, out var isLocked))
|
if (reader.TryGetBoolean(index++, out var isLocked))
|
||||||
{
|
{
|
||||||
item.IsLocked = isLocked.Value;
|
item.IsLocked = isLocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reader.TryGetString(index++, out var preferredMetadataLanguage))
|
if (reader.TryGetString(index++, out var preferredMetadataLanguage))
|
||||||
@ -1430,7 +1430,7 @@ namespace Emby.Server.Implementations.Data
|
|||||||
{
|
{
|
||||||
if (reader.TryGetInt32(index++, out var width))
|
if (reader.TryGetInt32(index++, out var width))
|
||||||
{
|
{
|
||||||
item.Width = width.Value;
|
item.Width = width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1438,7 +1438,7 @@ namespace Emby.Server.Implementations.Data
|
|||||||
{
|
{
|
||||||
if (reader.TryGetInt32(index++, out var height))
|
if (reader.TryGetInt32(index++, out var height))
|
||||||
{
|
{
|
||||||
item.Height = height.Value;
|
item.Height = height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1536,6 +1536,7 @@ namespace Emby.Server.Implementations.Data
|
|||||||
|
|
||||||
if (reader.TryGetString(index++, out var audioString))
|
if (reader.TryGetString(index++, out var audioString))
|
||||||
{
|
{
|
||||||
|
// TODO Span overload coming in the future https://github.com/dotnet/runtime/issues/1916
|
||||||
if (Enum.TryParse(audioString, true, out ProgramAudio audio))
|
if (Enum.TryParse(audioString, true, out ProgramAudio audio))
|
||||||
{
|
{
|
||||||
item.Audio = audio;
|
item.Audio = audio;
|
||||||
@ -1559,7 +1560,7 @@ namespace Emby.Server.Implementations.Data
|
|||||||
|
|
||||||
if (reader.TryGetBoolean(index++, out var isInMixedFolder))
|
if (reader.TryGetBoolean(index++, out var isInMixedFolder))
|
||||||
{
|
{
|
||||||
item.IsInMixedFolder = isInMixedFolder.Value;
|
item.IsInMixedFolder = isInMixedFolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HasField(query, ItemFields.DateLastSaved))
|
if (HasField(query, ItemFields.DateLastSaved))
|
||||||
@ -1669,7 +1670,7 @@ namespace Emby.Server.Implementations.Data
|
|||||||
|
|
||||||
if (reader.TryGetBoolean(index++, out var isVirtualItem))
|
if (reader.TryGetBoolean(index++, out var isVirtualItem))
|
||||||
{
|
{
|
||||||
item.IsVirtualItem = isVirtualItem.Value;
|
item.IsVirtualItem = isVirtualItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item is IHasSeries hasSeriesName)
|
if (item is IHasSeries hasSeriesName)
|
||||||
@ -1731,7 +1732,7 @@ namespace Emby.Server.Implementations.Data
|
|||||||
{
|
{
|
||||||
if (reader.TryGetInt32(index++, out var parentalRating))
|
if (reader.TryGetInt32(index++, out var parentalRating))
|
||||||
{
|
{
|
||||||
item.InheritedParentalRatingValue = parentalRating.Value;
|
item.InheritedParentalRatingValue = parentalRating;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ namespace Jellyfin.Naming.Tests.Video
|
|||||||
yield return new object[]
|
yield return new object[]
|
||||||
{
|
{
|
||||||
new VideoFileInfo(
|
new VideoFileInfo(
|
||||||
path: @"/server/Movies/Rain Man 1988 REMASTERED 1080p BluRay x264 AAC - Ozlem/Rain Man 1988 REMASTERED 1080p BluRay x264 AAC - Ozlem.mp4",
|
path: @"/server/Movies/Rain Man 1988 REMASTERED 1080p BluRay x264 AAC - JEFF/Rain Man 1988 REMASTERED 1080p BluRay x264 AAC - JEFF.mp4",
|
||||||
container: "mp4",
|
container: "mp4",
|
||||||
name: "Rain Man",
|
name: "Rain Man",
|
||||||
year: 1988)
|
year: 1988)
|
||||||
@ -200,6 +200,10 @@ namespace Jellyfin.Naming.Tests.Video
|
|||||||
Assert.NotNull(results[0]);
|
Assert.NotNull(results[0]);
|
||||||
Assert.NotNull(results[1]);
|
Assert.NotNull(results[1]);
|
||||||
Assert.Null(results[2]);
|
Assert.Null(results[2]);
|
||||||
|
foreach (var result in results)
|
||||||
|
{
|
||||||
|
Assert.Null(result?.Container);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ namespace Jellyfin.Providers.Tests.MediaInfo
|
|||||||
"/video/My.Video.With.Additional.Garbage.en.srt",
|
"/video/My.Video.With.Additional.Garbage.en.srt",
|
||||||
"/video/My.Video With Additional Garbage.srt"
|
"/video/My.Video With Additional Garbage.srt"
|
||||||
},
|
},
|
||||||
new List<MediaStream>
|
new[]
|
||||||
{
|
{
|
||||||
CreateMediaStream("/video/My.Video.srt", "srt", null, index++),
|
CreateMediaStream("/video/My.Video.srt", "srt", null, index++),
|
||||||
CreateMediaStream("/video/My.Video.vtt", "vtt", null, index++),
|
CreateMediaStream("/video/My.Video.vtt", "vtt", null, index++),
|
||||||
@ -58,12 +58,12 @@ namespace Jellyfin.Providers.Tests.MediaInfo
|
|||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
[MemberData(nameof(AddExternalSubtitleStreams_GivenMixedFilenames_ReturnsValidSubtitles_TestData))]
|
[MemberData(nameof(AddExternalSubtitleStreams_GivenMixedFilenames_ReturnsValidSubtitles_TestData))]
|
||||||
public void AddExternalSubtitleStreams_GivenMixedFilenames_ReturnsValidSubtitles(List<MediaStream> streams, string videoPath, int startIndex, string[] files, List<MediaStream> expectedResult)
|
public void AddExternalSubtitleStreams_GivenMixedFilenames_ReturnsValidSubtitles(List<MediaStream> streams, string videoPath, int startIndex, string[] files, MediaStream[] expectedResult)
|
||||||
{
|
{
|
||||||
new SubtitleResolver(Mock.Of<ILocalizationManager>()).AddExternalSubtitleStreams(streams, videoPath, startIndex, files);
|
new SubtitleResolver(Mock.Of<ILocalizationManager>()).AddExternalSubtitleStreams(streams, videoPath, startIndex, files);
|
||||||
|
|
||||||
Assert.Equal(expectedResult.Count, streams.Count);
|
Assert.Equal(expectedResult.Length, streams.Count);
|
||||||
for (var i = 0; i < expectedResult.Count; i++)
|
for (var i = 0; i < expectedResult.Length; i++)
|
||||||
{
|
{
|
||||||
var expected = expectedResult[i];
|
var expected = expectedResult[i];
|
||||||
var actual = streams[i];
|
var actual = streams[i];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user