Add xmldocs

pull/7514/head
Shadowghost 3 years ago
parent cfd1db1638
commit 42fc02cab6

@ -19,7 +19,7 @@ using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.Library.Resolvers.Audio namespace Emby.Server.Implementations.Library.Resolvers.Audio
{ {
/// <summary> /// <summary>
/// Class MusicAlbumResolver. /// The music album resolver.
/// </summary> /// </summary>
public class MusicAlbumResolver : ItemResolver<MusicAlbum> public class MusicAlbumResolver : ItemResolver<MusicAlbum>
{ {
@ -93,12 +93,12 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
/// Determine if the supplied resolve args should be considered a music album. /// Determine if the supplied resolve args should be considered a music album.
/// </summary> /// </summary>
/// <param name="args">The args.</param> /// <param name="args">The args.</param>
/// <returns><c>true</c> if [is music album] [the specified args]; otherwise, <c>false</c>.</returns> /// <returns><c>true</c> if [is music album] [the specified args], <c>false</c> otherwise.</returns>
private bool IsMusicAlbum(ItemResolveArgs args) private bool IsMusicAlbum(ItemResolveArgs args)
{ {
// Args points to an album if parent is an Artist folder or it directly contains music
if (args.IsDirectory) if (args.IsDirectory)
{ {
// If args is a artist subfolder it's not a music album
foreach (var subfolder in _namingOptions.ArtistSubfolders) foreach (var subfolder in _namingOptions.ArtistSubfolders)
{ {
if (Path.GetDirectoryName(args.Path.AsSpan()).Equals(subfolder, StringComparison.OrdinalIgnoreCase)) if (Path.GetDirectoryName(args.Path.AsSpan()).Equals(subfolder, StringComparison.OrdinalIgnoreCase))
@ -108,6 +108,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
} }
} }
// If args contains music it's a music album
if (ContainsMusic(args.FileSystemChildren, true, args.DirectoryService)) if (ContainsMusic(args.FileSystemChildren, true, args.DirectoryService))
{ {
return true; return true;
@ -120,22 +121,23 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
/// <summary> /// <summary>
/// Determine if the supplied list contains what we should consider music. /// Determine if the supplied list contains what we should consider music.
/// </summary> /// </summary>
/// <returns><c>true</c> if the provided path list contains music, <c>false</c> otherwise.</returns>
private bool ContainsMusic( private bool ContainsMusic(
ICollection<FileSystemMetadata> list, ICollection<FileSystemMetadata> list,
bool allowSubfolders, bool allowSubfolders,
IDirectoryService directoryService) IDirectoryService directoryService)
{ {
// check for audio files before digging down into directories // Check for audio files before digging down into directories
var foundAudioFile = list.Any(fileSystemInfo => !fileSystemInfo.IsDirectory && AudioFileParser.IsAudioFile(fileSystemInfo.FullName, _namingOptions)); var foundAudioFile = list.Any(fileSystemInfo => !fileSystemInfo.IsDirectory && AudioFileParser.IsAudioFile(fileSystemInfo.FullName, _namingOptions));
if (foundAudioFile) if (foundAudioFile)
{ {
// at least one audio file exists // At least one audio file exists
return true; return true;
} }
if (!allowSubfolders) if (!allowSubfolders)
{ {
// not music since no audio file exists and we're not looking into subfolders // Not music since no audio file exists and we're not looking into subfolders
return false; return false;
} }

@ -13,7 +13,7 @@ using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.Library.Resolvers.Audio namespace Emby.Server.Implementations.Library.Resolvers.Audio
{ {
/// <summary> /// <summary>
/// Class MusicArtistResolver. /// The music artist resolver.
/// </summary> /// </summary>
public class MusicArtistResolver : ItemResolver<MusicArtist> public class MusicArtistResolver : ItemResolver<MusicArtist>
{ {
@ -23,8 +23,8 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="MusicArtistResolver"/> class. /// Initializes a new instance of the <see cref="MusicArtistResolver"/> class.
/// </summary> /// </summary>
/// <param name="logger">The logger for the created <see cref="MusicAlbumResolver"/> instances.</param> /// <param name="logger">Instance of the <see cref="MusicAlbumResolver"/> interface.</param>
/// <param name="namingOptions">The naming options.</param> /// <param name="namingOptions">The <see cref="NamingOptions"/>.</param>
public MusicArtistResolver( public MusicArtistResolver(
ILogger<MusicAlbumResolver> logger, ILogger<MusicAlbumResolver> logger,
NamingOptions namingOptions) NamingOptions namingOptions)
@ -40,10 +40,10 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
public override ResolverPriority Priority => ResolverPriority.Second; public override ResolverPriority Priority => ResolverPriority.Second;
/// <summary> /// <summary>
/// Resolves the specified args. /// Resolves the specified resolver arguments.
/// </summary> /// </summary>
/// <param name="args">The args.</param> /// <param name="args">The resolver arguments.</param>
/// <returns>MusicArtist.</returns> /// <returns>A <see cref="MusicArtist"/>.</returns>
protected override MusicArtist Resolve(ItemResolveArgs args) protected override MusicArtist Resolve(ItemResolveArgs args)
{ {
if (!args.IsDirectory) if (!args.IsDirectory)
@ -82,23 +82,24 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
var albumResolver = new MusicAlbumResolver(_logger, _namingOptions); var albumResolver = new MusicAlbumResolver(_logger, _namingOptions);
// If we contain an album assume we are an artist folder
var directories = args.FileSystemChildren.Where(i => i.IsDirectory); var directories = args.FileSystemChildren.Where(i => i.IsDirectory);
var result = Parallel.ForEach(directories, (fileSystemInfo, state) => var result = Parallel.ForEach(directories, (fileSystemInfo, state) =>
{ {
// If we contain a artist subfolder assume we are an artist folder
foreach (var subfolder in _namingOptions.ArtistSubfolders) foreach (var subfolder in _namingOptions.ArtistSubfolders)
{ {
if (fileSystemInfo.Name.Equals(subfolder, StringComparison.OrdinalIgnoreCase)) if (fileSystemInfo.Name.Equals(subfolder, StringComparison.OrdinalIgnoreCase))
{ {
// stop once we see a artist subfolder // Stop once we see an artist subfolder
state.Stop(); state.Stop();
} }
} }
// If we contain a music album assume we are an artist folder
if (albumResolver.IsMusicAlbum(fileSystemInfo.FullName, directoryService)) if (albumResolver.IsMusicAlbum(fileSystemInfo.FullName, directoryService))
{ {
// stop once we see a music album // Stop once we see a music album
state.Stop(); state.Stop();
} }
}); });

@ -18,9 +18,9 @@ namespace MediaBrowser.Controller.Providers
/// Fetches the metadata asynchronously. /// Fetches the metadata asynchronously.
/// </summary> /// </summary>
/// <param name="item">The item.</param> /// <param name="item">The item.</param>
/// <param name="options">The options.</param> /// <param name="options">The <see cref="MetadataRefreshOptions"/>.</param>
/// <param name="cancellationToken">The cancellation token.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/>.</param>
/// <returns>Task{ItemUpdateType}.</returns> /// <returns>A <see cref="Task"/> fetching the <see cref="ItemUpdateType"/>.</returns>
Task<ItemUpdateType> FetchAsync(TItemType item, MetadataRefreshOptions options, CancellationToken cancellationToken); Task<ItemUpdateType> FetchAsync(TItemType item, MetadataRefreshOptions options, CancellationToken cancellationToken);
} }
} }

@ -1,7 +1,5 @@
#nullable disable #nullable disable
#pragma warning disable CS1591
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -21,6 +19,9 @@ using TagLib;
namespace MediaBrowser.Providers.MediaInfo namespace MediaBrowser.Providers.MediaInfo
{ {
/// <summary>
/// Probes audio files for metadata.
/// </summary>
public class AudioFileProber public class AudioFileProber
{ {
private readonly IMediaEncoder _mediaEncoder; private readonly IMediaEncoder _mediaEncoder;
@ -28,6 +29,13 @@ namespace MediaBrowser.Providers.MediaInfo
private readonly ILibraryManager _libraryManager; private readonly ILibraryManager _libraryManager;
private readonly IMediaSourceManager _mediaSourceManager; private readonly IMediaSourceManager _mediaSourceManager;
/// <summary>
/// Initializes a new instance of the <see cref="AudioFileProber"/> class.
/// </summary>
/// <param name="mediaSourceManager">Instance of the <see cref="IMediaSourceManager"/> interface.</param>
/// <param name="mediaEncoder">Instance of the <see cref="IMediaEncoder"/> interface.</param>
/// <param name="itemRepo">Instance of the <see cref="IItemRepository"/> interface.</param>
/// <param name="libraryManager">Instance of the <see cref="ILibraryManager"/> interface.</param>
public AudioFileProber( public AudioFileProber(
IMediaSourceManager mediaSourceManager, IMediaSourceManager mediaSourceManager,
IMediaEncoder mediaEncoder, IMediaEncoder mediaEncoder,
@ -40,6 +48,14 @@ namespace MediaBrowser.Providers.MediaInfo
_mediaSourceManager = mediaSourceManager; _mediaSourceManager = mediaSourceManager;
} }
/// <summary>
/// Probes the specified item for metadata.
/// </summary>
/// <param name="item">The item to probe.</param>
/// <param name="options">The <see cref="MetadataRefreshOptions"/>.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/>.</param>
/// <typeparam name="T">The type of item to resolve.</typeparam>
/// <returns>A <see cref="Task"/> probing the item for metadata.</returns>
public async Task<ItemUpdateType> Probe<T>( public async Task<ItemUpdateType> Probe<T>(
T item, T item,
MetadataRefreshOptions options, MetadataRefreshOptions options,
@ -80,9 +96,9 @@ namespace MediaBrowser.Providers.MediaInfo
/// <summary> /// <summary>
/// Fetches the specified audio. /// Fetches the specified audio.
/// </summary> /// </summary>
/// <param name="audio">The audio.</param> /// <param name="audio">The <see cref="Audio"/>.</param>
/// <param name="mediaInfo">The media information.</param> /// <param name="mediaInfo">The <see cref="Model.MediaInfo.MediaInfo"/>.</param>
/// <param name="cancellationToken">The cancellation token.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/>.</param>
protected void Fetch(Audio audio, Model.MediaInfo.MediaInfo mediaInfo, CancellationToken cancellationToken) protected void Fetch(Audio audio, Model.MediaInfo.MediaInfo mediaInfo, CancellationToken cancellationToken)
{ {
audio.Container = mediaInfo.Container; audio.Container = mediaInfo.Container;
@ -91,18 +107,15 @@ namespace MediaBrowser.Providers.MediaInfo
audio.RunTimeTicks = mediaInfo.RunTimeTicks; audio.RunTimeTicks = mediaInfo.RunTimeTicks;
audio.Size = mediaInfo.Size; audio.Size = mediaInfo.Size;
// var extension = (Path.GetExtension(audio.Path) ?? string.Empty).TrimStart('.');
// audio.Container = extension;
FetchDataFromTags(audio); FetchDataFromTags(audio);
_itemRepo.SaveMediaStreams(audio.Id, mediaInfo.MediaStreams, cancellationToken); _itemRepo.SaveMediaStreams(audio.Id, mediaInfo.MediaStreams, cancellationToken);
} }
/// <summary> /// <summary>
/// Fetches data from the tags dictionary. /// Fetches data from the tags.
/// </summary> /// </summary>
/// <param name="audio">The audio.</param> /// <param name="audio">The <see cref="Audio"/>.</param>
private void FetchDataFromTags(Audio audio) private void FetchDataFromTags(Audio audio)
{ {
var file = TagLib.File.Create(audio.Path); var file = TagLib.File.Create(audio.Path);

@ -1,7 +1,5 @@
#nullable disable #nullable disable
#pragma warning disable CS1591
using System; using System;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@ -27,6 +25,9 @@ using Microsoft.Extensions.Logging;
namespace MediaBrowser.Providers.MediaInfo namespace MediaBrowser.Providers.MediaInfo
{ {
/// <summary>
/// The probe provider.
/// </summary>
public class ProbeProvider : ICustomMetadataProvider<Episode>, public class ProbeProvider : ICustomMetadataProvider<Episode>,
ICustomMetadataProvider<MusicVideo>, ICustomMetadataProvider<MusicVideo>,
ICustomMetadataProvider<Movie>, ICustomMetadataProvider<Movie>,
@ -46,6 +47,22 @@ namespace MediaBrowser.Providers.MediaInfo
private readonly AudioFileProber _audioProber; private readonly AudioFileProber _audioProber;
private readonly Task<ItemUpdateType> _cachedTask = Task.FromResult(ItemUpdateType.None); private readonly Task<ItemUpdateType> _cachedTask = Task.FromResult(ItemUpdateType.None);
/// <summary>
/// Initializes a new instance of the <see cref="ProbeProvider"/> class.
/// </summary>
/// <param name="mediaSourceManager">Instance of the <see cref="IMediaSourceManager"/> interface.</param>
/// <param name="mediaEncoder">Instance of the <see cref="IMediaEncoder"/> interface.</param>
/// <param name="itemRepo">Instance of the <see cref="IItemRepository"/> interface.</param>
/// <param name="blurayExaminer">Instance of the <see cref="IBlurayExaminer"/> interface.</param>
/// <param name="localization">Instance of the <see cref="ILocalizationManager"/> interface.</param>
/// <param name="encodingManager">Instance of the <see cref="IEncodingManager"/> interface.</param>
/// <param name="config">Instance of the <see cref="IServerConfigurationManager"/> interface.</param>
/// <param name="subtitleManager">Instance of the <see cref="ISubtitleManager"/> interface.</param>
/// <param name="chapterManager">Instance of the <see cref="IChapterManager"/> interface.</param>
/// <param name="libraryManager">Instance of the <see cref="ILibraryManager"/> interface.</param>
/// <param name="loggerFactory">Instance of the <see cref="ILoggerFactory"/>.</param>
/// <param name="fileSystem">Instance of the <see cref="IFileSystem"/> interface.</param>
/// <param name="namingOptions">The <see cref="NamingOptions"/>.</param>
public ProbeProvider( public ProbeProvider(
IMediaSourceManager mediaSourceManager, IMediaSourceManager mediaSourceManager,
IMediaEncoder mediaEncoder, IMediaEncoder mediaEncoder,
@ -81,11 +98,13 @@ namespace MediaBrowser.Providers.MediaInfo
_subtitleResolver); _subtitleResolver);
} }
public string Name => "filemetadataprober"; /// <inheritdoc />
public string Name => "Probe Provider";
// Run last /// <inheritdoc />
public int Order => 100; public int Order => 100;
/// <inheritdoc />
public bool HasChanged(BaseItem item, IDirectoryService directoryService) public bool HasChanged(BaseItem item, IDirectoryService directoryService)
{ {
var video = item as Video; var video = item as Video;
@ -127,41 +146,56 @@ namespace MediaBrowser.Providers.MediaInfo
return false; return false;
} }
/// <inheritdoc />
public Task<ItemUpdateType> FetchAsync(Episode item, MetadataRefreshOptions options, CancellationToken cancellationToken) public Task<ItemUpdateType> FetchAsync(Episode item, MetadataRefreshOptions options, CancellationToken cancellationToken)
{ {
return FetchVideoInfo(item, options, cancellationToken); return FetchVideoInfo(item, options, cancellationToken);
} }
/// <inheritdoc />
public Task<ItemUpdateType> FetchAsync(MusicVideo item, MetadataRefreshOptions options, CancellationToken cancellationToken) public Task<ItemUpdateType> FetchAsync(MusicVideo item, MetadataRefreshOptions options, CancellationToken cancellationToken)
{ {
return FetchVideoInfo(item, options, cancellationToken); return FetchVideoInfo(item, options, cancellationToken);
} }
/// <inheritdoc />
public Task<ItemUpdateType> FetchAsync(Movie item, MetadataRefreshOptions options, CancellationToken cancellationToken) public Task<ItemUpdateType> FetchAsync(Movie item, MetadataRefreshOptions options, CancellationToken cancellationToken)
{ {
return FetchVideoInfo(item, options, cancellationToken); return FetchVideoInfo(item, options, cancellationToken);
} }
/// <inheritdoc />
public Task<ItemUpdateType> FetchAsync(Trailer item, MetadataRefreshOptions options, CancellationToken cancellationToken) public Task<ItemUpdateType> FetchAsync(Trailer item, MetadataRefreshOptions options, CancellationToken cancellationToken)
{ {
return FetchVideoInfo(item, options, cancellationToken); return FetchVideoInfo(item, options, cancellationToken);
} }
/// <inheritdoc />
public Task<ItemUpdateType> FetchAsync(Video item, MetadataRefreshOptions options, CancellationToken cancellationToken) public Task<ItemUpdateType> FetchAsync(Video item, MetadataRefreshOptions options, CancellationToken cancellationToken)
{ {
return FetchVideoInfo(item, options, cancellationToken); return FetchVideoInfo(item, options, cancellationToken);
} }
/// <inheritdoc />
public Task<ItemUpdateType> FetchAsync(Audio item, MetadataRefreshOptions options, CancellationToken cancellationToken) public Task<ItemUpdateType> FetchAsync(Audio item, MetadataRefreshOptions options, CancellationToken cancellationToken)
{ {
return FetchAudioInfo(item, options, cancellationToken); return FetchAudioInfo(item, options, cancellationToken);
} }
/// <inheritdoc />
public Task<ItemUpdateType> FetchAsync(AudioBook item, MetadataRefreshOptions options, CancellationToken cancellationToken) public Task<ItemUpdateType> FetchAsync(AudioBook item, MetadataRefreshOptions options, CancellationToken cancellationToken)
{ {
return FetchAudioInfo(item, options, cancellationToken); return FetchAudioInfo(item, options, cancellationToken);
} }
/// <summary>
/// Fetches video information for an item.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="options">The <see cref="MetadataRefreshOptions"/>.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/>.</param>
/// <typeparam name="T">The type of item to resolve.</typeparam>
/// <returns>A <see cref="Task"/> fetching the <see cref="ItemUpdateType"/> for an item.</returns>
public Task<ItemUpdateType> FetchVideoInfo<T>(T item, MetadataRefreshOptions options, CancellationToken cancellationToken) public Task<ItemUpdateType> FetchVideoInfo<T>(T item, MetadataRefreshOptions options, CancellationToken cancellationToken)
where T : Video where T : Video
{ {
@ -208,6 +242,14 @@ namespace MediaBrowser.Providers.MediaInfo
.FirstOrDefault(i => !string.IsNullOrWhiteSpace(i) && !i.StartsWith('#')); .FirstOrDefault(i => !string.IsNullOrWhiteSpace(i) && !i.StartsWith('#'));
} }
/// <summary>
/// Fetches audio information for an item.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="options">The <see cref="MetadataRefreshOptions"/>.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/>.</param>
/// <typeparam name="T">The type of item to resolve.</typeparam>
/// <returns>A <see cref="Task"/> fetching the <see cref="ItemUpdateType"/> for an item.</returns>
public Task<ItemUpdateType> FetchAudioInfo<T>(T item, MetadataRefreshOptions options, CancellationToken cancellationToken) public Task<ItemUpdateType> FetchAudioInfo<T>(T item, MetadataRefreshOptions options, CancellationToken cancellationToken)
where T : Audio where T : Audio
{ {

@ -1,5 +1,3 @@
#pragma warning disable CS1591
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -15,8 +13,19 @@ using Microsoft.Extensions.Logging;
namespace MediaBrowser.Providers.Music namespace MediaBrowser.Providers.Music
{ {
/// <summary>
/// The album metadata service.
/// </summary>
public class AlbumMetadataService : MetadataService<MusicAlbum, AlbumInfo> public class AlbumMetadataService : MetadataService<MusicAlbum, AlbumInfo>
{ {
/// <summary>
/// Initializes a new instance of the <see cref="AlbumMetadataService"/> class.
/// </summary>
/// <param name="serverConfigurationManager">Instance of the <see cref="IServerConfigurationManager"/>.</param>
/// <param name="logger">Instance of the <see cref="ILogger"/> interface.</param>
/// <param name="providerManager">Instance of the <see cref="IProviderManager"/> interface.</param>
/// <param name="fileSystem">Instance of the <see cref="IFileSystem"/> interface.</param>
/// <param name="libraryManager">Instance of the <see cref="ILibraryManager"/> interface.</param>
public AlbumMetadataService( public AlbumMetadataService(
IServerConfigurationManager serverConfigurationManager, IServerConfigurationManager serverConfigurationManager,
ILogger<AlbumMetadataService> logger, ILogger<AlbumMetadataService> logger,

@ -1,5 +1,3 @@
#pragma warning disable CS1591
using System; using System;
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Entities.Audio;
@ -12,8 +10,19 @@ using Microsoft.Extensions.Logging;
namespace MediaBrowser.Providers.Music namespace MediaBrowser.Providers.Music
{ {
/// <summary>
/// The audio metadata service.
/// </summary>
public class AudioMetadataService : MetadataService<Audio, SongInfo> public class AudioMetadataService : MetadataService<Audio, SongInfo>
{ {
/// <summary>
/// Initializes a new instance of the <see cref="AudioMetadataService"/> class.
/// </summary>
/// <param name="serverConfigurationManager">Instance of the <see cref="IServerConfigurationManager"/>.</param>
/// <param name="logger">Instance of the <see cref="ILogger"/> interface.</param>
/// <param name="providerManager">Instance of the <see cref="IProviderManager"/> interface.</param>
/// <param name="fileSystem">Instance of the <see cref="IFileSystem"/> interface.</param>
/// <param name="libraryManager">Instance of the <see cref="ILibraryManager"/> interface.</param>
public AudioMetadataService( public AudioMetadataService(
IServerConfigurationManager serverConfigurationManager, IServerConfigurationManager serverConfigurationManager,
ILogger<AudioMetadataService> logger, ILogger<AudioMetadataService> logger,

Loading…
Cancel
Save