aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Controller')
-rw-r--r--MediaBrowser.Controller/Entities/Audio/Artist.cs38
-rw-r--r--MediaBrowser.Controller/Entities/User.cs10
-rw-r--r--MediaBrowser.Controller/IO/FileSystem.cs5
-rw-r--r--MediaBrowser.Controller/MediaInfo/FFMpegManager.cs5
-rw-r--r--MediaBrowser.Controller/Providers/BaseMetadataProvider.cs21
5 files changed, 57 insertions, 22 deletions
diff --git a/MediaBrowser.Controller/Entities/Audio/Artist.cs b/MediaBrowser.Controller/Entities/Audio/Artist.cs
index e0d80527c..07bb68b95 100644
--- a/MediaBrowser.Controller/Entities/Audio/Artist.cs
+++ b/MediaBrowser.Controller/Entities/Audio/Artist.cs
@@ -1,7 +1,11 @@
-using System.Runtime.Serialization;
+using System.Globalization;
+using System.Linq;
+using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Dto;
using System;
using System.Collections.Generic;
+using System.Runtime.Serialization;
+using MediaBrowser.Model.Entities;
namespace MediaBrowser.Controller.Entities.Audio
{
@@ -28,5 +32,37 @@ namespace MediaBrowser.Controller.Entities.Audio
[IgnoreDataMember]
public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; }
+
+ /// <summary>
+ /// Finds the music artist.
+ /// </summary>
+ /// <param name="artist">The artist.</param>
+ /// <param name="libraryManager">The library manager.</param>
+ /// <returns>MusicArtist.</returns>
+ public static MusicArtist FindMusicArtist(Artist artist, ILibraryManager libraryManager)
+ {
+ return FindMusicArtist(artist, libraryManager.RootFolder.RecursiveChildren.OfType<MusicArtist>());
+ }
+
+ /// <summary>
+ /// Finds the music artist.
+ /// </summary>
+ /// <param name="artist">The artist.</param>
+ /// <param name="allMusicArtists">All music artists.</param>
+ /// <returns>MusicArtist.</returns>
+ public static MusicArtist FindMusicArtist(Artist artist, IEnumerable<MusicArtist> allMusicArtists)
+ {
+ var musicBrainzId = artist.GetProviderId(MetadataProviders.Musicbrainz);
+
+ return allMusicArtists.FirstOrDefault(i =>
+ {
+ if (!string.IsNullOrWhiteSpace(musicBrainzId) && string.Equals(musicBrainzId, i.GetProviderId(MetadataProviders.Musicbrainz), StringComparison.OrdinalIgnoreCase))
+ {
+ return true;
+ }
+
+ return string.Compare(i.Name, artist.Name, CultureInfo.CurrentCulture, CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreCase | CompareOptions.IgnoreSymbols) == 0;
+ });
+ }
}
}
diff --git a/MediaBrowser.Controller/Entities/User.cs b/MediaBrowser.Controller/Entities/User.cs
index 82d81e517..9d8539906 100644
--- a/MediaBrowser.Controller/Entities/User.cs
+++ b/MediaBrowser.Controller/Entities/User.cs
@@ -30,10 +30,7 @@ namespace MediaBrowser.Controller.Entities
{
var path = Configuration.UseCustomLibrary ? GetRootFolderPath(Name) : ConfigurationManager.ApplicationPaths.DefaultUserViewsPath;
- if (!Directory.Exists(path))
- {
- Directory.CreateDirectory(path);
- }
+ Directory.CreateDirectory(path);
return path;
}
@@ -256,10 +253,7 @@ namespace MediaBrowser.Controller.Entities
{
_configurationDirectoryPath = GetConfigurationDirectoryPath(Name);
- if (!Directory.Exists(_configurationDirectoryPath))
- {
- Directory.CreateDirectory(_configurationDirectoryPath);
- }
+ Directory.CreateDirectory(_configurationDirectoryPath);
}
return _configurationDirectoryPath;
diff --git a/MediaBrowser.Controller/IO/FileSystem.cs b/MediaBrowser.Controller/IO/FileSystem.cs
index 3d425f13f..30fdb8d39 100644
--- a/MediaBrowser.Controller/IO/FileSystem.cs
+++ b/MediaBrowser.Controller/IO/FileSystem.cs
@@ -205,10 +205,7 @@ namespace MediaBrowser.Controller.IO
}
// Check if the target directory exists, if not, create it.
- if (!Directory.Exists(target))
- {
- Directory.CreateDirectory(target);
- }
+ Directory.CreateDirectory(target);
foreach (var file in Directory.EnumerateFiles(source))
{
diff --git a/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs b/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs
index bbe5ddbaa..87036df84 100644
--- a/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs
+++ b/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs
@@ -159,10 +159,7 @@ namespace MediaBrowser.Controller.MediaInfo
{
var parentPath = Path.GetDirectoryName(path);
- if (!Directory.Exists(parentPath))
- {
- Directory.CreateDirectory(parentPath);
- }
+ Directory.CreateDirectory(parentPath);
await _encoder.ExtractImage(inputPath, type, video.Video3DFormat, time, path, cancellationToken).ConfigureAwait(false);
chapter.ImagePath = path;
diff --git a/MediaBrowser.Controller/Providers/BaseMetadataProvider.cs b/MediaBrowser.Controller/Providers/BaseMetadataProvider.cs
index 2364debed..ad6be9481 100644
--- a/MediaBrowser.Controller/Providers/BaseMetadataProvider.cs
+++ b/MediaBrowser.Controller/Providers/BaseMetadataProvider.cs
@@ -233,27 +233,27 @@ namespace MediaBrowser.Controller.Providers
throw new ArgumentNullException("providerInfo");
}
- if (CompareDate(item) > providerInfo.LastRefreshed)
+ if (RefreshOnVersionChange && !String.Equals(ProviderVersion, providerInfo.ProviderVersion))
{
return true;
}
- if (RefreshOnFileSystemStampChange && item.LocationType == LocationType.FileSystem && HasFileSystemStampChanged(item, providerInfo))
+ if (RequiresInternet && DateTime.UtcNow > (providerInfo.LastRefreshed.AddDays(ConfigurationManager.Configuration.MetadataRefreshDays)))
{
return true;
}
- if (RefreshOnVersionChange && !String.Equals(ProviderVersion, providerInfo.ProviderVersion))
+ if (providerInfo.LastRefreshStatus != ProviderRefreshStatus.Success)
{
return true;
}
- if (RequiresInternet && DateTime.UtcNow > (providerInfo.LastRefreshed.AddDays(ConfigurationManager.Configuration.MetadataRefreshDays)))
+ if (NeedsRefreshBasedOnCompareDate(item, providerInfo))
{
return true;
}
- if (providerInfo.LastRefreshStatus != ProviderRefreshStatus.Success)
+ if (RefreshOnFileSystemStampChange && item.LocationType == LocationType.FileSystem && HasFileSystemStampChanged(item, providerInfo))
{
return true;
}
@@ -262,6 +262,17 @@ namespace MediaBrowser.Controller.Providers
}
/// <summary>
+ /// Needses the refresh based on compare date.
+ /// </summary>
+ /// <param name="item">The item.</param>
+ /// <param name="providerInfo">The provider info.</param>
+ /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
+ protected virtual bool NeedsRefreshBasedOnCompareDate(BaseItem item, BaseProviderInfo providerInfo)
+ {
+ return CompareDate(item) > providerInfo.LastRefreshed;
+ }
+
+ /// <summary>
/// Determines if the item's file system stamp has changed from the last time the provider refreshed
/// </summary>
/// <param name="item">The item.</param>