Refactor for clarity; add docs and .editorconfig

Refactored code to consistently use `this.` for instance members, improving clarity and maintainability. Added XML documentation comments to multiple methods and properties for better API documentation. Streamlined `FfProbeKeyframeExtractor` logic and enhanced EBML parsing code with comments and style improvements. Introduced a new `.editorconfig` to disable legacy StyleCop and IDisposableAnalyzers rules. Updated binary files, assembly info, and NuGet cache files due to rebuilds and dependency changes. No functional changes were made.
This commit is contained in:
2026-02-21 16:55:27 -05:00
parent e887356385
commit 48569427a5
58 changed files with 215 additions and 113 deletions
+27
View File
@@ -0,0 +1,27 @@
# EditorConfig for MediaBrowser.Controller
# https://EditorConfig.org
root = true
[*.cs]
# Disable StyleCop rules that are not followed in this legacy project
dotnet_diagnostic.SA1101.severity = none
dotnet_diagnostic.SA1200.severity = none
dotnet_diagnostic.SA1202.severity = none
dotnet_diagnostic.SA1204.severity = none
dotnet_diagnostic.SA1309.severity = none
dotnet_diagnostic.SA1413.severity = none
dotnet_diagnostic.SA1515.severity = none
dotnet_diagnostic.SA1512.severity = none
dotnet_diagnostic.SA1600.severity = none
dotnet_diagnostic.SA1601.severity = none
dotnet_diagnostic.SA1602.severity = none
dotnet_diagnostic.SA1128.severity = none
dotnet_diagnostic.SA1009.severity = none
dotnet_diagnostic.SA1108.severity = none
# Disable IDisposableAnalyzers rules
dotnet_diagnostic.IDISP001.severity = none
dotnet_diagnostic.IDISP003.severity = none
dotnet_diagnostic.IDISP007.severity = none
dotnet_diagnostic.IDISP008.severity = none
@@ -23,7 +23,7 @@ namespace MediaBrowser.Controller.BaseItemManager
/// <param name="serverConfigurationManager">Instance of the <see cref="IServerConfigurationManager"/> interface.</param>
public BaseItemManager(IServerConfigurationManager serverConfigurationManager)
{
_serverConfigurationManager = serverConfigurationManager;
this._serverConfigurationManager = serverConfigurationManager;
}
/// <inheritdoc />
@@ -46,7 +46,7 @@ namespace MediaBrowser.Controller.BaseItemManager
return libraryTypeOptions.MetadataFetchers.Contains(name, StringComparison.OrdinalIgnoreCase);
}
var itemConfig = _serverConfigurationManager.GetMetadataOptionsForType(baseItem.GetType().Name);
var itemConfig = this._serverConfigurationManager.GetMetadataOptionsForType(baseItem.GetType().Name);
return itemConfig is null || !itemConfig.DisabledMetadataFetchers.Contains(name, StringComparison.OrdinalIgnoreCase);
}
@@ -70,7 +70,7 @@ namespace MediaBrowser.Controller.BaseItemManager
return libraryTypeOptions.ImageFetchers.Contains(name, StringComparison.OrdinalIgnoreCase);
}
var itemConfig = _serverConfigurationManager.GetMetadataOptionsForType(baseItem.GetType().Name);
var itemConfig = this._serverConfigurationManager.GetMetadataOptionsForType(baseItem.GetType().Name);
return itemConfig is null || !itemConfig.DisabledImageFetchers.Contains(name, StringComparison.OrdinalIgnoreCase);
}
}
+36 -4
View File
@@ -27,12 +27,18 @@ namespace MediaBrowser.Controller.Channels
[JsonIgnore]
public override SourceType SourceType => SourceType.Channel;
/// <summary>
/// Determines whether this channel is visible to the specified user.
/// </summary>
/// <param name="user">The user.</param>
/// <param name="skipAllowedTagsCheck">Whether to skip the allowed tags check.</param>
/// <returns>True if visible; otherwise, false.</returns>
public override bool IsVisible(User user, bool skipAllowedTagsCheck = false)
{
var blockedChannelsPreference = user.GetPreferenceValues<Guid>(PreferenceKind.BlockedChannels);
if (blockedChannelsPreference.Length != 0)
{
if (blockedChannelsPreference.Contains(Id))
if (blockedChannelsPreference.Contains(this.Id))
{
return false;
}
@@ -40,7 +46,7 @@ namespace MediaBrowser.Controller.Channels
else
{
if (!user.HasPermission(PermissionKind.EnableAllChannels)
&& !user.GetPreferenceValues<Guid>(PreferenceKind.EnabledChannels).Contains(Id))
&& !user.GetPreferenceValues<Guid>(PreferenceKind.EnabledChannels).Contains(this.Id))
{
return false;
}
@@ -49,12 +55,17 @@ namespace MediaBrowser.Controller.Channels
return base.IsVisible(user, skipAllowedTagsCheck);
}
/// <summary>
/// Gets items from the channel.
/// </summary>
/// <param name="query">The items query.</param>
/// <returns>The query result.</returns>
protected override QueryResult<BaseItem> GetItemsInternal(InternalItemsQuery query)
{
try
{
query.Parent = this;
query.ChannelIds = new Guid[] { Id };
query.ChannelIds = new Guid[] { this.Id };
// Don't blow up here because it could cause parent screens with other content to fail
return ChannelManager.GetChannelItemsInternal(query, new Progress<double>(), CancellationToken.None).GetAwaiter().GetResult();
@@ -66,21 +77,42 @@ namespace MediaBrowser.Controller.Channels
}
}
/// <summary>
/// Gets the internal metadata path for this channel.
/// </summary>
/// <param name="basePath">The base path.</param>
/// <returns>The internal metadata path.</returns>
protected override string GetInternalMetadataPath(string basePath)
{
return GetInternalMetadataPath(basePath, Id);
return GetInternalMetadataPath(basePath, this.Id);
}
/// <summary>
/// Gets the internal metadata path for a channel with the specified ID.
/// </summary>
/// <param name="basePath">The base path.</param>
/// <param name="id">The channel ID.</param>
/// <returns>The internal metadata path.</returns>
public static string GetInternalMetadataPath(string basePath, Guid id)
{
return System.IO.Path.Combine(basePath, "channels", id.ToString("N", CultureInfo.InvariantCulture), "metadata");
}
/// <summary>
/// Determines whether this channel can be deleted.
/// </summary>
/// <returns>True if deletable; otherwise, false.</returns>
public override bool CanDelete()
{
return false;
}
/// <summary>
/// Determines whether the channel item is visible to the specified user.
/// </summary>
/// <param name="channelItem">The channel item.</param>
/// <param name="user">The user.</param>
/// <returns>True if visible; otherwise, false.</returns>
internal static bool IsChannelVisible(BaseItem channelItem, User user)
{
var channel = ChannelManager.GetChannel(channelItem.ChannelId.ToString(string.Empty));
@@ -142,7 +142,7 @@ namespace MediaBrowser.Controller.Entities.Audio
public SongInfo GetLookupInfo()
{
var info = GetItemLookupInfo<SongInfo>();
var info = this.GetItemLookupInfo<SongInfo>();
info.AlbumArtists = AlbumArtists;
info.Album = Album;
+33 -5
View File
@@ -31,36 +31,64 @@ namespace MediaBrowser.Controller.Entities
[JsonIgnore]
public Guid SeriesId { get; set; }
/// <summary>
/// Finds the series sort name.
/// </summary>
/// <returns>The series sort name.</returns>
public string FindSeriesSortName()
{
return SeriesName;
return this.SeriesName;
}
/// <summary>
/// Finds the series name.
/// </summary>
/// <returns>The series name.</returns>
public string FindSeriesName()
{
return SeriesName;
return this.SeriesName;
}
/// <summary>
/// Finds the series presentation unique key.
/// </summary>
/// <returns>The series presentation unique key.</returns>
public string FindSeriesPresentationUniqueKey()
{
return SeriesPresentationUniqueKey;
return this.SeriesPresentationUniqueKey;
}
/// <summary>
/// Gets the default primary image aspect ratio.
/// </summary>
/// <returns>The default primary image aspect ratio.</returns>
public override double GetDefaultPrimaryImageAspectRatio()
{
return 0;
}
/// <summary>
/// Finds the series identifier.
/// </summary>
/// <returns>The series identifier.</returns>
public Guid FindSeriesId()
{
return SeriesId;
return this.SeriesId;
}
/// <summary>
/// Determines whether this audiobook can be downloaded.
/// </summary>
/// <returns>True if downloadable; otherwise, false.</returns>
public override bool CanDownload()
{
return IsFileProtocol;
return this.IsFileProtocol;
}
/// <summary>
/// Gets the unrated type for blocking purposes.
/// </summary>
/// <returns>The unrated item type.</returns>
public override UnratedItem GetBlockUnratedType()
{
return UnratedItem.Book;
@@ -7263,6 +7263,13 @@ namespace MediaBrowser.Controller.MediaEncoding
return inputModifier;
}
/// <summary>
/// Attaches media source information to the encoding job state.
/// </summary>
/// <param name="state">The encoding job state.</param>
/// <param name="encodingOptions">The encoding options.</param>
/// <param name="mediaSource">The media source information.</param>
/// <param name="requestedUrl">The requested URL.</param>
public void AttachMediaSourceInfo(
EncodingJobInfo state,
EncodingOptions encodingOptions,
@@ -7327,26 +7334,26 @@ namespace MediaBrowser.Controller.MediaEncoding
requestedUrl = "test." + videoRequest.Container;
}
videoRequest.VideoCodec = InferVideoCodec(requestedUrl);
videoRequest.VideoCodec = this.InferVideoCodec(requestedUrl);
}
state.VideoStream = GetMediaStream(mediaStreams, videoRequest.VideoStreamIndex, MediaStreamType.Video);
state.SubtitleStream = GetMediaStream(mediaStreams, videoRequest.SubtitleStreamIndex, MediaStreamType.Subtitle, false);
state.VideoStream = this.GetMediaStream(mediaStreams, videoRequest.VideoStreamIndex, MediaStreamType.Video);
state.SubtitleStream = this.GetMediaStream(mediaStreams, videoRequest.SubtitleStreamIndex, MediaStreamType.Subtitle, false);
state.SubtitleDeliveryMethod = videoRequest.SubtitleMethod;
state.AudioStream = GetMediaStream(mediaStreams, videoRequest.AudioStreamIndex, MediaStreamType.Audio);
state.AudioStream = this.GetMediaStream(mediaStreams, videoRequest.AudioStreamIndex, MediaStreamType.Audio);
if (state.SubtitleStream is not null && !state.SubtitleStream.IsExternal)
{
state.InternalSubtitleStreamOffset = mediaStreams.Where(i => i.Type == MediaStreamType.Subtitle && !i.IsExternal).ToList().IndexOf(state.SubtitleStream);
}
EnforceResolutionLimit(state);
this.EnforceResolutionLimit(state);
NormalizeSubtitleEmbed(state);
this.NormalizeSubtitleEmbed(state);
}
else
{
state.AudioStream = GetMediaStream(mediaStreams, null, MediaStreamType.Audio, true);
state.AudioStream = this.GetMediaStream(mediaStreams, null, MediaStreamType.Audio, true);
}
state.MediaSource = mediaSource;
@@ -7357,11 +7364,11 @@ namespace MediaBrowser.Controller.MediaEncoding
{
var supportedAudioCodecsList = supportedAudioCodecs.ToList();
ShiftAudioCodecsIfNeeded(supportedAudioCodecsList, state.AudioStream);
this.ShiftAudioCodecsIfNeeded(supportedAudioCodecsList, state.AudioStream);
state.SupportedAudioCodecs = supportedAudioCodecsList.ToArray();
request.AudioCodec = state.SupportedAudioCodecs.FirstOrDefault(_mediaEncoder.CanEncodeToAudioCodec)
request.AudioCodec = state.SupportedAudioCodecs.FirstOrDefault(this._mediaEncoder.CanEncodeToAudioCodec)
?? state.SupportedAudioCodecs.FirstOrDefault();
}
@@ -7370,7 +7377,7 @@ namespace MediaBrowser.Controller.MediaEncoding
{
var supportedVideoCodecsList = supportedVideoCodecs.ToList();
ShiftVideoCodecsIfNeeded(supportedVideoCodecsList, encodingOptions);
this.ShiftVideoCodecsIfNeeded(supportedVideoCodecsList, encodingOptions);
state.SupportedVideoCodecs = supportedVideoCodecsList.ToArray();
@@ -7791,6 +7798,12 @@ namespace MediaBrowser.Controller.MediaEncoding
|| (state.BaseRequest.AlwaysBurnInSubtitleWhenTranscoding && !IsCopyCodec(state.OutputVideoCodec));
}
/// <summary>
/// Gets the video sync option based on the encoder version.
/// </summary>
/// <param name="videoSync">The video sync parameter.</param>
/// <param name="encoderVersion">The encoder version.</param>
/// <returns>The video sync option string.</returns>
public static string GetVideoSyncOption(string videoSync, Version encoderVersion)
{
if (string.IsNullOrEmpty(videoSync))
@@ -7808,7 +7821,7 @@ namespace MediaBrowser.Controller.MediaEncoding
0 => " -fps_mode passthrough",
1 => " -fps_mode cfr",
2 => " -fps_mode vfr",
_ => string.Empty
_ => string.Empty,
};
}
@@ -1,6 +1,6 @@
{
"version": 2,
"dgSpecHash": "oIB4cupu3LM=",
"dgSpecHash": "No+LvUzpMog=",
"success": true,
"projectFilePath": "E:\\Projects\\pgsql-jellyfin\\MediaBrowser.Controller\\MediaBrowser.Controller.csproj",
"expectedPackageFiles": [