diff --git a/MediaBrowser.LocalMetadata/BaseXmlProvider.cs b/MediaBrowser.LocalMetadata/BaseXmlProvider.cs
index a6553563f..b036a2cc8 100644
--- a/MediaBrowser.LocalMetadata/BaseXmlProvider.cs
+++ b/MediaBrowser.LocalMetadata/BaseXmlProvider.cs
@@ -7,12 +7,43 @@ using MediaBrowser.Model.IO;
namespace MediaBrowser.LocalMetadata
{
+ ///
+ /// The BaseXmlProvider.
+ ///
+ /// Type of provider.
public abstract class BaseXmlProvider : ILocalMetadataProvider, IHasItemChangeMonitor, IHasOrder
where T : BaseItem, new()
{
- protected IFileSystem FileSystem;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Instance of the interface.
+ protected BaseXmlProvider(IFileSystem fileSystem)
+ {
+ this.FileSystem = fileSystem;
+ }
- public Task> GetMetadata(ItemInfo info,
+ ///
+ public string Name => XmlProviderUtils.Name;
+
+ /// After Nfo
+ ///
+ public virtual int Order => 1;
+
+ ///
+ /// Gets the IFileSystem.
+ ///
+ protected IFileSystem FileSystem { get; }
+
+ ///
+ /// Gets metadata for item.
+ ///
+ /// The item info.
+ /// Instance of the interface.
+ /// The cancellation token.
+ /// The metadata for item.
+ public Task> GetMetadata(
+ ItemInfo info,
IDirectoryService directoryService,
CancellationToken cancellationToken)
{
@@ -46,15 +77,23 @@ namespace MediaBrowser.LocalMetadata
return Task.FromResult(result);
}
+ ///
+ /// Get metadata from path.
+ ///
+ /// Resulting metadata.
+ /// The path.
+ /// The cancellation token.
protected abstract void Fetch(MetadataResult result, string path, CancellationToken cancellationToken);
- protected BaseXmlProvider(IFileSystem fileSystem)
- {
- FileSystem = fileSystem;
- }
-
+ ///
+ /// Get metadata from xml file.
+ ///
+ /// Item inf.
+ /// Instance of the interface.
+ /// The file system metadata.
protected abstract FileSystemMetadata GetXmlFile(ItemInfo info, IDirectoryService directoryService);
+ ///
public bool HasChanged(BaseItem item, IDirectoryService directoryService)
{
var file = GetXmlFile(new ItemInfo(item), directoryService);
@@ -66,15 +105,5 @@ namespace MediaBrowser.LocalMetadata
return file.Exists && FileSystem.GetLastWriteTimeUtc(file) > item.DateLastSaved;
}
-
- public string Name => XmlProviderUtils.Name;
-
- //After Nfo
- public virtual int Order => 1;
- }
-
- static class XmlProviderUtils
- {
- public static string Name => "Emby Xml";
}
}
diff --git a/MediaBrowser.LocalMetadata/Images/CollectionFolderImageProvider.cs b/MediaBrowser.LocalMetadata/Images/CollectionFolderLocalImageProvider.cs
similarity index 63%
rename from MediaBrowser.LocalMetadata/Images/CollectionFolderImageProvider.cs
rename to MediaBrowser.LocalMetadata/Images/CollectionFolderLocalImageProvider.cs
index 3bab1243c..556bb6a0e 100644
--- a/MediaBrowser.LocalMetadata/Images/CollectionFolderImageProvider.cs
+++ b/MediaBrowser.LocalMetadata/Images/CollectionFolderLocalImageProvider.cs
@@ -5,30 +5,41 @@ using MediaBrowser.Model.IO;
namespace MediaBrowser.LocalMetadata.Images
{
+ ///
+ /// Collection folder local image provider.
+ ///
public class CollectionFolderLocalImageProvider : ILocalImageProvider, IHasOrder
{
private readonly IFileSystem _fileSystem;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Instance of the interface.
public CollectionFolderLocalImageProvider(IFileSystem fileSystem)
{
_fileSystem = fileSystem;
}
+ ///
public string Name => "Collection Folder Images";
+ /// Run after LocalImageProvider
+ ///
+ public int Order => 1;
+
+ ///
public bool Supports(BaseItem item)
{
return item is CollectionFolder && item.SupportsLocalMetadata;
}
- // Run after LocalImageProvider
- public int Order => 1;
-
+ ///
public List GetImages(BaseItem item, IDirectoryService directoryService)
{
var collectionFolder = (CollectionFolder)item;
- return new LocalImageProvider(_fileSystem).GetImages(item, collectionFolder.PhysicalLocations, true, directoryService);
+ return new LocalImageProvider(_fileSystem).GetImages(item, collectionFolder.PhysicalLocations, directoryService);
}
}
}
diff --git a/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs b/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs
index 2f4cca5ff..a1a0c1785 100644
--- a/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs
+++ b/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs
@@ -10,24 +10,35 @@ using MediaBrowser.Model.IO;
namespace MediaBrowser.LocalMetadata.Images
{
- public class EpisodeLocalLocalImageProvider : ILocalImageProvider, IHasOrder
+ ///
+ /// Episode local local local image provider.
+ ///
+ public class EpisodeLocalImageProvider : ILocalImageProvider, IHasOrder
{
private readonly IFileSystem _fileSystem;
- public EpisodeLocalLocalImageProvider(IFileSystem fileSystem)
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Instance of the interface.
+ public EpisodeLocalImageProvider(IFileSystem fileSystem)
{
_fileSystem = fileSystem;
}
+ ///
public string Name => "Local Images";
+ ///
public int Order => 0;
+ ///
public bool Supports(BaseItem item)
{
return item is Episode && item.SupportsLocalMetadata;
}
+ ///
public List GetImages(BaseItem item, IDirectoryService directoryService)
{
var parentPath = Path.GetDirectoryName(item.Path);
@@ -58,23 +69,15 @@ namespace MediaBrowser.LocalMetadata.Images
if (string.Equals(filenameWithoutExtension, currentNameWithoutExtension, StringComparison.OrdinalIgnoreCase))
{
- list.Add(new LocalImageInfo
- {
- FileInfo = i,
- Type = ImageType.Primary
- });
+ list.Add(new LocalImageInfo { FileInfo = i, Type = ImageType.Primary });
}
-
else if (string.Equals(thumbName, currentNameWithoutExtension, StringComparison.OrdinalIgnoreCase))
{
- list.Add(new LocalImageInfo
- {
- FileInfo = i,
- Type = ImageType.Primary
- });
+ list.Add(new LocalImageInfo { FileInfo = i, Type = ImageType.Primary });
}
}
}
+
return list;
}
}
diff --git a/MediaBrowser.LocalMetadata/Images/InternalMetadataFolderImageProvider.cs b/MediaBrowser.LocalMetadata/Images/InternalMetadataFolderImageProvider.cs
index 5137e4c68..509b5d700 100644
--- a/MediaBrowser.LocalMetadata/Images/InternalMetadataFolderImageProvider.cs
+++ b/MediaBrowser.LocalMetadata/Images/InternalMetadataFolderImageProvider.cs
@@ -9,12 +9,21 @@ using Microsoft.Extensions.Logging;
namespace MediaBrowser.LocalMetadata.Images
{
+ ///
+ /// Internal metadata folder image provider.
+ ///
public class InternalMetadataFolderImageProvider : ILocalImageProvider, IHasOrder
{
private readonly IServerConfigurationManager _config;
private readonly IFileSystem _fileSystem;
private readonly ILogger _logger;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Instance of the interface.
+ /// Instance of the interface.
+ /// Instance of the interface.
public InternalMetadataFolderImageProvider(
IServerConfigurationManager config,
IFileSystem fileSystem,
@@ -25,8 +34,14 @@ namespace MediaBrowser.LocalMetadata.Images
_logger = logger;
}
+ /// Make sure this is last so that all other locations are scanned first
+ ///
+ public int Order => 1000;
+
+ ///
public string Name => "Internal Images";
+ ///
public bool Supports(BaseItem item)
{
if (item is Photo)
@@ -52,9 +67,8 @@ namespace MediaBrowser.LocalMetadata.Images
return true;
}
- // Make sure this is last so that all other locations are scanned first
- public int Order => 1000;
+ ///
public List GetImages(BaseItem item, IDirectoryService directoryService)
{
var path = item.GetInternalMetadataPath();
@@ -66,7 +80,7 @@ namespace MediaBrowser.LocalMetadata.Images
try
{
- return new LocalImageProvider(_fileSystem).GetImages(item, path, false, directoryService);
+ return new LocalImageProvider(_fileSystem).GetImages(item, path, directoryService);
}
catch (IOException ex)
{
diff --git a/MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs b/MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs
index 16807f5a4..914db5305 100644
--- a/MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs
+++ b/MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs
@@ -13,19 +13,71 @@ using MediaBrowser.Model.IO;
namespace MediaBrowser.LocalMetadata.Images
{
+ ///
+ /// Local image provider.
+ ///
public class LocalImageProvider : ILocalImageProvider, IHasOrder
{
+ private static readonly string[] _commonImageFileNames =
+ {
+ "poster",
+ "folder",
+ "cover",
+ "default"
+ };
+
+ private static readonly string[] _musicImageFileNames =
+ {
+ "folder",
+ "poster",
+ "cover",
+ "default"
+ };
+
+ private static readonly string[] _personImageFileNames =
+ {
+ "folder",
+ "poster"
+ };
+
+ private static readonly string[] _seriesImageFileNames =
+ {
+ "poster",
+ "folder",
+ "cover",
+ "default",
+ "show"
+ };
+
+ private static readonly string[] _videoImageFileNames =
+ {
+ "poster",
+ "folder",
+ "cover",
+ "default",
+ "movie"
+ };
+
private readonly IFileSystem _fileSystem;
+ private readonly CultureInfo _usCulture = new CultureInfo("en-US");
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Instance of the interface.
public LocalImageProvider(IFileSystem fileSystem)
{
_fileSystem = fileSystem;
}
+ ///
public string Name => "Local Images";
+ ///
public int Order => 0;
+ ///
public bool Supports(BaseItem item)
{
if (item.SupportsLocalMetadata)
@@ -42,15 +94,10 @@ namespace MediaBrowser.LocalMetadata.Images
if (item.LocationType == LocationType.Virtual)
{
var season = item as Season;
-
- if (season != null)
+ var series = season?.Series;
+ if (series != null && series.IsFileProtocol)
{
- var series = season.Series;
-
- if (series != null && series.IsFileProtocol)
- {
- return true;
- }
+ return true;
}
}
@@ -85,6 +132,7 @@ namespace MediaBrowser.LocalMetadata.Images
.OrderBy(i => Array.IndexOf(BaseItem.SupportedImageExtensions, i.Extension ?? string.Empty));
}
+ ///
public List GetImages(BaseItem item, IDirectoryService directoryService)
{
var files = GetFiles(item, true, directoryService).ToList();
@@ -96,12 +144,26 @@ namespace MediaBrowser.LocalMetadata.Images
return list;
}
- public List GetImages(BaseItem item, string path, bool isPathInMediaFolder, IDirectoryService directoryService)
+ ///
+ /// Get images for item.
+ ///
+ /// The item.
+ /// The images path.
+ /// Instance of the interface.
+ /// The local image info.
+ public List GetImages(BaseItem item, string path, IDirectoryService directoryService)
{
- return GetImages(item, new[] { path }, isPathInMediaFolder, directoryService);
+ return GetImages(item, new[] { path }, directoryService);
}
- public List GetImages(BaseItem item, IEnumerable paths, bool arePathsInMediaFolders, IDirectoryService directoryService)
+ ///
+ /// Get images for item from multiple paths.
+ ///
+ /// The item.
+ /// The image paths.
+ /// Instance of the interface.
+ /// The local image info.
+ public List GetImages(BaseItem item, IEnumerable paths, IDirectoryService directoryService)
{
IEnumerable files = paths.SelectMany(i => _fileSystem.GetFiles(i, BaseItem.SupportedImageExtensions, true, false));
@@ -196,7 +258,7 @@ namespace MediaBrowser.LocalMetadata.Images
if (!isEpisode && !isSong && !isPerson)
{
- PopulateBackdrops(item, images, files, imagePrefix, isInMixedFolder, directoryService);
+ PopulateBackdrops(item, images, files, imagePrefix, isInMixedFolder);
}
if (item is IHasScreenshots)
@@ -205,46 +267,6 @@ namespace MediaBrowser.LocalMetadata.Images
}
}
- private static readonly string[] CommonImageFileNames = new[]
- {
- "poster",
- "folder",
- "cover",
- "default"
- };
-
- private static readonly string[] MusicImageFileNames = new[]
- {
- "folder",
- "poster",
- "cover",
- "default"
- };
-
- private static readonly string[] PersonImageFileNames = new[]
- {
- "folder",
- "poster"
- };
-
- private static readonly string[] SeriesImageFileNames = new[]
- {
- "poster",
- "folder",
- "cover",
- "default",
- "show"
- };
-
- private static readonly string[] VideoImageFileNames = new[]
- {
- "poster",
- "folder",
- "cover",
- "default",
- "movie"
- };
-
private void PopulatePrimaryImages(BaseItem item, List images, List files, string imagePrefix, bool isInMixedFolder)
{
string[] imageFileNames;
@@ -252,24 +274,24 @@ namespace MediaBrowser.LocalMetadata.Images
if (item is MusicAlbum || item is MusicArtist || item is PhotoAlbum)
{
// these prefer folder
- imageFileNames = MusicImageFileNames;
+ imageFileNames = _musicImageFileNames;
}
else if (item is Person)
{
// these prefer folder
- imageFileNames = PersonImageFileNames;
+ imageFileNames = _personImageFileNames;
}
else if (item is Series)
{
- imageFileNames = SeriesImageFileNames;
+ imageFileNames = _seriesImageFileNames;
}
else if (item is Video && !(item is Episode))
{
- imageFileNames = VideoImageFileNames;
+ imageFileNames = _videoImageFileNames;
}
else
{
- imageFileNames = CommonImageFileNames;
+ imageFileNames = _commonImageFileNames;
}
var fileNameWithoutExtension = item.FileNameWithoutExtension;
@@ -301,7 +323,7 @@ namespace MediaBrowser.LocalMetadata.Images
}
}
- private void PopulateBackdrops(BaseItem item, List images, List files, string imagePrefix, bool isInMixedFolder, IDirectoryService directoryService)
+ private void PopulateBackdrops(BaseItem item, List images, List files, string imagePrefix, bool isInMixedFolder)
{
if (!string.IsNullOrEmpty(item.Path))
{
@@ -328,13 +350,13 @@ namespace MediaBrowser.LocalMetadata.Images
if (extraFanartFolder != null)
{
- PopulateBackdropsFromExtraFanart(extraFanartFolder.FullName, images, directoryService);
+ PopulateBackdropsFromExtraFanart(extraFanartFolder.FullName, images);
}
PopulateBackdrops(images, files, imagePrefix, "backdrop", "backdrop", isInMixedFolder, ImageType.Backdrop);
}
- private void PopulateBackdropsFromExtraFanart(string path, List images, IDirectoryService directoryService)
+ private void PopulateBackdropsFromExtraFanart(string path, List images)
{
var imageFiles = _fileSystem.GetFiles(path, BaseItem.SupportedImageExtensions, false, false);
@@ -395,8 +417,6 @@ namespace MediaBrowser.LocalMetadata.Images
}
}
- private readonly CultureInfo _usCulture = new CultureInfo("en-US");
-
private void PopulateSeasonImagesFromSeriesFolder(Season season, List images, IDirectoryService directoryService)
{
var seasonNumber = season.IndexNumber;
@@ -410,7 +430,7 @@ namespace MediaBrowser.LocalMetadata.Images
var seriesFiles = GetFiles(series, false, directoryService).ToList();
// Try using the season name
- var prefix = season.Name.ToLowerInvariant().Replace(" ", string.Empty);
+ var prefix = season.Name.Replace(" ", string.Empty, StringComparison.Ordinal).ToLowerInvariant();
var filenamePrefixes = new List { prefix };
diff --git a/MediaBrowser.LocalMetadata/MediaBrowser.LocalMetadata.csproj b/MediaBrowser.LocalMetadata/MediaBrowser.LocalMetadata.csproj
index 24104d779..529e7065c 100644
--- a/MediaBrowser.LocalMetadata/MediaBrowser.LocalMetadata.csproj
+++ b/MediaBrowser.LocalMetadata/MediaBrowser.LocalMetadata.csproj
@@ -10,14 +10,28 @@
-
-
-
-
netstandard2.1
false
true
+ true
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ../jellyfin.ruleset
diff --git a/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs b/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs
index 4f1112396..e11ceb826 100644
--- a/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs
+++ b/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs
@@ -14,24 +14,21 @@ using Microsoft.Extensions.Logging;
namespace MediaBrowser.LocalMetadata.Parsers
{
///
- /// Provides a base class for parsing metadata xml
+ /// Provides a base class for parsing metadata xml.
///
- ///
+ /// Type of item xml parser.
public class BaseItemXmlParser
where T : BaseItem
{
- ///
- /// The logger
- ///
- protected ILogger> Logger { get; private set; }
- protected IProviderManager ProviderManager { get; private set; }
+ private readonly CultureInfo _usCulture = new CultureInfo("en-US");
- private Dictionary _validProviderIds;
+ private Dictionary? _validProviderIds;
///
/// Initializes a new instance of the class.
///
- /// The logger.
+ /// Instance of the interface.
+ /// Instance of the interface.
public BaseItemXmlParser(ILogger> logger, IProviderManager providerManager)
{
Logger = logger;
@@ -39,12 +36,22 @@ namespace MediaBrowser.LocalMetadata.Parsers
}
///
- /// Fetches metadata for an item from one xml file
+ /// Gets the logger.
+ ///
+ protected ILogger> Logger { get; private set; }
+
+ ///
+ /// Gets the provider manager.
+ ///
+ protected IProviderManager ProviderManager { get; private set; }
+
+ ///
+ /// Fetches metadata for an item from one xml file.
///
/// The item.
/// The metadata file.
/// The cancellation token.
- ///
+ /// Item is null.
public void Fetch(MetadataResult item, string metadataFile, CancellationToken cancellationToken)
{
if (item == null)
@@ -57,7 +64,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
throw new ArgumentException("The metadata file was empty or null.", nameof(metadataFile));
}
- var settings = new XmlReaderSettings()
+ var settings = new XmlReaderSettings
{
ValidationType = ValidationType.None,
CheckCharacters = false,
@@ -78,10 +85,10 @@ namespace MediaBrowser.LocalMetadata.Parsers
}
}
- //Additional Mappings
+ // Additional Mappings
_validProviderIds.Add("IMDB", "Imdb");
- //Fetch(item, metadataFile, settings, Encoding.GetEncoding("ISO-8859-1"), cancellationToken);
+ // Fetch(item, metadataFile, settings, Encoding.GetEncoding("ISO-8859-1"), cancellationToken);
Fetch(item, metadataFile, settings, Encoding.UTF8, cancellationToken);
}
@@ -97,34 +104,30 @@ namespace MediaBrowser.LocalMetadata.Parsers
{
item.ResetPeople();
- using (var fileStream = File.OpenRead(metadataFile))
- using (var streamReader = new StreamReader(fileStream, encoding))
- using (var reader = XmlReader.Create(streamReader, settings))
+ using var fileStream = File.OpenRead(metadataFile);
+ using var streamReader = new StreamReader(fileStream, encoding);
+ using var reader = XmlReader.Create(streamReader, settings);
+ reader.MoveToContent();
+ reader.Read();
+
+ // Loop through each element
+ while (!reader.EOF && reader.ReadState == ReadState.Interactive)
{
- reader.MoveToContent();
- reader.Read();
+ cancellationToken.ThrowIfCancellationRequested();
- // Loop through each element
- while (!reader.EOF && reader.ReadState == ReadState.Interactive)
+ if (reader.NodeType == XmlNodeType.Element)
{
- cancellationToken.ThrowIfCancellationRequested();
-
- if (reader.NodeType == XmlNodeType.Element)
- {
- FetchDataFromXmlNode(reader, item);
- }
- else
- {
- reader.Read();
- }
+ FetchDataFromXmlNode(reader, item);
+ }
+ else
+ {
+ reader.Read();
}
}
}
- private readonly CultureInfo _usCulture = new CultureInfo("en-US");
-
///
- /// Fetches metadata from one Xml Element
+ /// Fetches metadata from one Xml Element.
///
/// The reader.
/// The item result.
@@ -136,554 +139,568 @@ namespace MediaBrowser.LocalMetadata.Parsers
{
// DateCreated
case "Added":
- {
- var val = reader.ReadElementContentAsString();
+ {
+ var val = reader.ReadElementContentAsString();
- if (!string.IsNullOrWhiteSpace(val))
+ if (!string.IsNullOrWhiteSpace(val))
+ {
+ if (DateTime.TryParse(val, out var added))
{
- if (DateTime.TryParse(val, out var added))
- {
- item.DateCreated = added.ToUniversalTime();
- }
- else
- {
- Logger.LogWarning("Invalid Added value found: " + val);
- }
+ item.DateCreated = added.ToUniversalTime();
+ }
+ else
+ {
+ Logger.LogWarning("Invalid Added value found: " + val);
}
- break;
}
+ break;
+ }
+
case "OriginalTitle":
- {
- var val = reader.ReadElementContentAsString();
+ {
+ var val = reader.ReadElementContentAsString();
- if (!string.IsNullOrEmpty(val))
- {
- item.OriginalTitle = val;
- }
- break;
+ if (!string.IsNullOrEmpty(val))
+ {
+ item.OriginalTitle = val;
}
+ break;
+ }
+
case "LocalTitle":
item.Name = reader.ReadElementContentAsString();
break;
case "CriticRating":
+ {
+ var text = reader.ReadElementContentAsString();
+
+ if (!string.IsNullOrEmpty(text))
{
- var text = reader.ReadElementContentAsString();
-
- if (!string.IsNullOrEmpty(text))
+ if (float.TryParse(text, NumberStyles.Any, _usCulture, out var value))
{
- if (float.TryParse(text, NumberStyles.Any, _usCulture, out var value))
- {
- item.CriticRating = value;
- }
+ item.CriticRating = value;
}
-
- break;
}
+ break;
+ }
+
case "SortTitle":
- {
- var val = reader.ReadElementContentAsString();
+ {
+ var val = reader.ReadElementContentAsString();
- if (!string.IsNullOrWhiteSpace(val))
- {
- item.ForcedSortName = val;
- }
- break;
+ if (!string.IsNullOrWhiteSpace(val))
+ {
+ item.ForcedSortName = val;
}
+ break;
+ }
+
case "Overview":
case "Description":
+ {
+ var val = reader.ReadElementContentAsString();
+
+ if (!string.IsNullOrWhiteSpace(val))
{
- var val = reader.ReadElementContentAsString();
-
- if (!string.IsNullOrWhiteSpace(val))
- {
- item.Overview = val;
- }
-
- break;
+ item.Overview = val;
}
+ break;
+ }
+
case "Language":
- {
- var val = reader.ReadElementContentAsString();
+ {
+ var val = reader.ReadElementContentAsString();
- item.PreferredMetadataLanguage = val;
+ item.PreferredMetadataLanguage = val;
- break;
- }
+ break;
+ }
case "CountryCode":
- {
- var val = reader.ReadElementContentAsString();
+ {
+ var val = reader.ReadElementContentAsString();
- item.PreferredMetadataCountryCode = val;
+ item.PreferredMetadataCountryCode = val;
- break;
- }
+ break;
+ }
case "PlaceOfBirth":
+ {
+ var val = reader.ReadElementContentAsString();
+
+ if (!string.IsNullOrWhiteSpace(val))
{
- var val = reader.ReadElementContentAsString();
-
- if (!string.IsNullOrWhiteSpace(val))
+ if (item is Person person)
{
- var person = item as Person;
- if (person != null)
- {
- person.ProductionLocations = new string[] { val };
- }
+ person.ProductionLocations = new[] { val };
}
-
- break;
}
+ break;
+ }
+
case "LockedFields":
+ {
+ var val = reader.ReadElementContentAsString();
+
+ if (!string.IsNullOrWhiteSpace(val))
{
- var val = reader.ReadElementContentAsString();
-
- if (!string.IsNullOrWhiteSpace(val))
+ item.LockedFields = val.Split('|').Select(i =>
{
- item.LockedFields = val.Split('|').Select(i =>
+ if (Enum.TryParse(i, true, out MetadataField field))
{
- if (Enum.TryParse(i, true, out MetadataField field))
- {
- return (MetadataField?)field;
- }
+ return (MetadataField?)field;
+ }
- return null;
-
- }).Where(i => i.HasValue).Select(i => i.Value).ToArray();
- }
-
- break;
+ return null;
+ }).Where(i => i.HasValue).Select(i => i!.Value).ToArray();
}
+ break;
+ }
+
case "TagLines":
+ {
+ if (!reader.IsEmptyElement)
{
- if (!reader.IsEmptyElement)
+ using (var subtree = reader.ReadSubtree())
{
- using (var subtree = reader.ReadSubtree())
- {
- FetchFromTaglinesNode(subtree, item);
- }
+ FetchFromTaglinesNode(subtree, item);
}
- else
- {
- reader.Read();
- }
- break;
+ }
+ else
+ {
+ reader.Read();
}
+ break;
+ }
+
case "Countries":
+ {
+ if (!reader.IsEmptyElement)
{
- if (!reader.IsEmptyElement)
+ using (var subtree = reader.ReadSubtree())
{
- using (var subtree = reader.ReadSubtree())
- {
- FetchFromCountriesNode(subtree, item);
- }
+ FetchFromCountriesNode(subtree);
}
- else
- {
- reader.Read();
- }
- break;
}
+ else
+ {
+ reader.Read();
+ }
+
+ break;
+ }
case "ContentRating":
case "MPAARating":
- {
- var rating = reader.ReadElementContentAsString();
+ {
+ var rating = reader.ReadElementContentAsString();
- if (!string.IsNullOrWhiteSpace(rating))
- {
- item.OfficialRating = rating;
- }
- break;
+ if (!string.IsNullOrWhiteSpace(rating))
+ {
+ item.OfficialRating = rating;
}
+ break;
+ }
+
case "CustomRating":
- {
- var val = reader.ReadElementContentAsString();
+ {
+ var val = reader.ReadElementContentAsString();
- if (!string.IsNullOrWhiteSpace(val))
- {
- item.CustomRating = val;
- }
- break;
+ if (!string.IsNullOrWhiteSpace(val))
+ {
+ item.CustomRating = val;
}
+ break;
+ }
+
case "RunningTime":
- {
- var text = reader.ReadElementContentAsString();
+ {
+ var text = reader.ReadElementContentAsString();
- if (!string.IsNullOrWhiteSpace(text))
+ if (!string.IsNullOrWhiteSpace(text))
+ {
+ if (int.TryParse(text.Split(' ')[0], NumberStyles.Integer, _usCulture, out var runtime))
{
- if (int.TryParse(text.Split(' ')[0], NumberStyles.Integer, _usCulture, out var runtime))
- {
- item.RunTimeTicks = TimeSpan.FromMinutes(runtime).Ticks;
- }
+ item.RunTimeTicks = TimeSpan.FromMinutes(runtime).Ticks;
}
- break;
}
+ break;
+ }
+
case "AspectRatio":
- {
- var val = reader.ReadElementContentAsString();
+ {
+ var val = reader.ReadElementContentAsString();
- var hasAspectRatio = item as IHasAspectRatio;
- if (!string.IsNullOrWhiteSpace(val) && hasAspectRatio != null)
- {
- hasAspectRatio.AspectRatio = val;
- }
- break;
+ var hasAspectRatio = item as IHasAspectRatio;
+ if (!string.IsNullOrWhiteSpace(val) && hasAspectRatio != null)
+ {
+ hasAspectRatio.AspectRatio = val;
}
+ break;
+ }
+
case "LockData":
- {
- var val = reader.ReadElementContentAsString();
+ {
+ var val = reader.ReadElementContentAsString();
- if (!string.IsNullOrWhiteSpace(val))
- {
- item.IsLocked = string.Equals("true", val, StringComparison.OrdinalIgnoreCase);
- }
- break;
+ if (!string.IsNullOrWhiteSpace(val))
+ {
+ item.IsLocked = string.Equals("true", val, StringComparison.OrdinalIgnoreCase);
}
+ break;
+ }
+
case "Network":
+ {
+ foreach (var name in SplitNames(reader.ReadElementContentAsString()))
{
- foreach (var name in SplitNames(reader.ReadElementContentAsString()))
+ if (string.IsNullOrWhiteSpace(name))
{
- if (string.IsNullOrWhiteSpace(name))
- {
- continue;
- }
- item.AddStudio(name);
+ continue;
}
- break;
+
+ item.AddStudio(name);
}
+ break;
+ }
+
case "Director":
+ {
+ foreach (var p in SplitNames(reader.ReadElementContentAsString()).Select(v => new PersonInfo { Name = v.Trim(), Type = PersonType.Director }))
{
- foreach (var p in SplitNames(reader.ReadElementContentAsString()).Select(v => new PersonInfo { Name = v.Trim(), Type = PersonType.Director }))
+ if (string.IsNullOrWhiteSpace(p.Name))
{
- if (string.IsNullOrWhiteSpace(p.Name))
- {
- continue;
- }
- itemResult.AddPerson(p);
+ continue;
}
- break;
+
+ itemResult.AddPerson(p);
}
+
+ break;
+ }
+
case "Writer":
+ {
+ foreach (var p in SplitNames(reader.ReadElementContentAsString()).Select(v => new PersonInfo { Name = v.Trim(), Type = PersonType.Writer }))
{
- foreach (var p in SplitNames(reader.ReadElementContentAsString()).Select(v => new PersonInfo { Name = v.Trim(), Type = PersonType.Writer }))
+ if (string.IsNullOrWhiteSpace(p.Name))
{
- if (string.IsNullOrWhiteSpace(p.Name))
- {
- continue;
- }
- itemResult.AddPerson(p);
+ continue;
}
- break;
+
+ itemResult.AddPerson(p);
}
+ break;
+ }
+
case "Actors":
+ {
+ var actors = reader.ReadInnerXml();
+
+ if (actors.Contains("<", StringComparison.Ordinal))
{
-
- var actors = reader.ReadInnerXml();
-
- if (actors.Contains("<"))
- {
- // This is one of the mis-named "Actors" full nodes created by MB2
- // Create a reader and pass it to the persons node processor
- FetchDataFromPersonsNode(XmlReader.Create(new StringReader("" + actors + "")), itemResult);
- }
- else
- {
- // Old-style piped string
- foreach (var p in SplitNames(actors).Select(v => new PersonInfo { Name = v.Trim(), Type = PersonType.Actor }))
- {
- if (string.IsNullOrWhiteSpace(p.Name))
- {
- continue;
- }
- itemResult.AddPerson(p);
- }
- }
- break;
+ // This is one of the mis-named "Actors" full nodes created by MB2
+ // Create a reader and pass it to the persons node processor
+ using var xmlReader = XmlReader.Create(new StringReader($"{actors}"));
+ FetchDataFromPersonsNode(xmlReader, itemResult);
}
-
- case "GuestStars":
+ else
{
- foreach (var p in SplitNames(reader.ReadElementContentAsString()).Select(v => new PersonInfo { Name = v.Trim(), Type = PersonType.GuestStar }))
+ // Old-style piped string
+ foreach (var p in SplitNames(actors).Select(v => new PersonInfo { Name = v.Trim(), Type = PersonType.Actor }))
{
if (string.IsNullOrWhiteSpace(p.Name))
{
continue;
}
+
itemResult.AddPerson(p);
}
- break;
}
+ break;
+ }
+
+ case "GuestStars":
+ {
+ foreach (var p in SplitNames(reader.ReadElementContentAsString()).Select(v => new PersonInfo { Name = v.Trim(), Type = PersonType.GuestStar }))
+ {
+ if (string.IsNullOrWhiteSpace(p.Name))
+ {
+ continue;
+ }
+
+ itemResult.AddPerson(p);
+ }
+
+ break;
+ }
+
case "Trailer":
- {
- var val = reader.ReadElementContentAsString();
+ {
+ var val = reader.ReadElementContentAsString();
- if (!string.IsNullOrWhiteSpace(val))
- {
- item.AddTrailerUrl(val);
- }
- break;
+ if (!string.IsNullOrWhiteSpace(val))
+ {
+ item.AddTrailerUrl(val);
}
+ break;
+ }
+
case "DisplayOrder":
+ {
+ var val = reader.ReadElementContentAsString();
+
+ var hasDisplayOrder = item as IHasDisplayOrder;
+ if (hasDisplayOrder != null)
{
- var val = reader.ReadElementContentAsString();
-
- var hasDisplayOrder = item as IHasDisplayOrder;
- if (hasDisplayOrder != null)
- {
- if (!string.IsNullOrWhiteSpace(val))
- {
- hasDisplayOrder.DisplayOrder = val;
- }
- }
- break;
- }
-
- case "Trailers":
- {
- if (!reader.IsEmptyElement)
- {
- using (var subtree = reader.ReadSubtree())
- {
- FetchDataFromTrailersNode(subtree, item);
- }
- }
- else
- {
- reader.Read();
- }
- break;
- }
-
- case "ProductionYear":
- {
- var val = reader.ReadElementContentAsString();
-
if (!string.IsNullOrWhiteSpace(val))
{
- if (int.TryParse(val, out var productionYear) && productionYear > 1850)
- {
- item.ProductionYear = productionYear;
- }
+ hasDisplayOrder.DisplayOrder = val;
}
-
- break;
}
+ break;
+ }
+
+ case "Trailers":
+ {
+ if (!reader.IsEmptyElement)
+ {
+ using var subtree = reader.ReadSubtree();
+ FetchDataFromTrailersNode(subtree, item);
+ }
+ else
+ {
+ reader.Read();
+ }
+
+ break;
+ }
+
+ case "ProductionYear":
+ {
+ var val = reader.ReadElementContentAsString();
+
+ if (!string.IsNullOrWhiteSpace(val))
+ {
+ if (int.TryParse(val, out var productionYear) && productionYear > 1850)
+ {
+ item.ProductionYear = productionYear;
+ }
+ }
+
+ break;
+ }
+
case "Rating":
case "IMDBrating":
+ {
+ var rating = reader.ReadElementContentAsString();
+
+ if (!string.IsNullOrWhiteSpace(rating))
{
-
- var rating = reader.ReadElementContentAsString();
-
- if (!string.IsNullOrWhiteSpace(rating))
+ // All external meta is saving this as '.' for decimal I believe...but just to be sure
+ if (float.TryParse(rating.Replace(',', '.'), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var val))
{
- // All external meta is saving this as '.' for decimal I believe...but just to be sure
- if (float.TryParse(rating.Replace(',', '.'), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var val))
- {
- item.CommunityRating = val;
- }
+ item.CommunityRating = val;
}
- break;
}
+ break;
+ }
+
case "BirthDate":
case "PremiereDate":
case "FirstAired":
+ {
+ var firstAired = reader.ReadElementContentAsString();
+
+ if (!string.IsNullOrWhiteSpace(firstAired))
{
- var firstAired = reader.ReadElementContentAsString();
-
- if (!string.IsNullOrWhiteSpace(firstAired))
+ if (DateTime.TryParseExact(firstAired, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out var airDate) && airDate.Year > 1850)
{
- if (DateTime.TryParseExact(firstAired, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out var airDate) && airDate.Year > 1850)
- {
- item.PremiereDate = airDate.ToUniversalTime();
- item.ProductionYear = airDate.Year;
- }
+ item.PremiereDate = airDate.ToUniversalTime();
+ item.ProductionYear = airDate.Year;
}
-
- break;
}
+ break;
+ }
+
case "DeathDate":
case "EndDate":
+ {
+ var firstAired = reader.ReadElementContentAsString();
+
+ if (!string.IsNullOrWhiteSpace(firstAired))
{
- var firstAired = reader.ReadElementContentAsString();
-
- if (!string.IsNullOrWhiteSpace(firstAired))
+ if (DateTime.TryParseExact(firstAired, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out var airDate) && airDate.Year > 1850)
{
- if (DateTime.TryParseExact(firstAired, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out var airDate) && airDate.Year > 1850)
- {
- item.EndDate = airDate.ToUniversalTime();
- }
+ item.EndDate = airDate.ToUniversalTime();
}
-
- break;
}
+ break;
+ }
+
case "CollectionNumber":
var tmdbCollection = reader.ReadElementContentAsString();
if (!string.IsNullOrWhiteSpace(tmdbCollection))
{
item.SetProviderId(MetadataProvider.TmdbCollection, tmdbCollection);
}
+
break;
case "Genres":
+ {
+ if (!reader.IsEmptyElement)
{
- if (!reader.IsEmptyElement)
- {
- using (var subtree = reader.ReadSubtree())
- {
- FetchFromGenresNode(subtree, item);
- }
- }
- else
- {
- reader.Read();
- }
- break;
+ using var subtree = reader.ReadSubtree();
+ FetchFromGenresNode(subtree, item);
}
+ else
+ {
+ reader.Read();
+ }
+
+ break;
+ }
case "Tags":
+ {
+ if (!reader.IsEmptyElement)
{
- if (!reader.IsEmptyElement)
- {
- using (var subtree = reader.ReadSubtree())
- {
- FetchFromTagsNode(subtree, item);
- }
- }
- else
- {
- reader.Read();
- }
- break;
+ using var subtree = reader.ReadSubtree();
+ FetchFromTagsNode(subtree, item);
}
+ else
+ {
+ reader.Read();
+ }
+
+ break;
+ }
case "Persons":
+ {
+ if (!reader.IsEmptyElement)
{
- if (!reader.IsEmptyElement)
- {
- using (var subtree = reader.ReadSubtree())
- {
- FetchDataFromPersonsNode(subtree, itemResult);
- }
- }
- else
- {
- reader.Read();
- }
- break;
+ using var subtree = reader.ReadSubtree();
+ FetchDataFromPersonsNode(subtree, itemResult);
}
+ else
+ {
+ reader.Read();
+ }
+
+ break;
+ }
case "Studios":
+ {
+ if (!reader.IsEmptyElement)
{
- if (!reader.IsEmptyElement)
- {
- using (var subtree = reader.ReadSubtree())
- {
- FetchFromStudiosNode(subtree, item);
- }
- }
- else
- {
- reader.Read();
- }
- break;
+ using var subtree = reader.ReadSubtree();
+ FetchFromStudiosNode(subtree, item);
}
+ else
+ {
+ reader.Read();
+ }
+
+ break;
+ }
case "Shares":
+ {
+ if (!reader.IsEmptyElement)
{
- if (!reader.IsEmptyElement)
+ using var subtree = reader.ReadSubtree();
+ if (item is IHasShares hasShares)
{
- using (var subtree = reader.ReadSubtree())
- {
- var hasShares = item as IHasShares;
- if (hasShares != null)
- {
- FetchFromSharesNode(subtree, hasShares);
- }
- }
+ FetchFromSharesNode(subtree, hasShares);
}
- else
- {
- reader.Read();
- }
- break;
}
+ else
+ {
+ reader.Read();
+ }
+
+ break;
+ }
case "Format3D":
+ {
+ var val = reader.ReadElementContentAsString();
+
+ if (item is Video video)
{
- var val = reader.ReadElementContentAsString();
-
- var video = item as Video;
-
- if (video != null)
+ if (string.Equals("HSBS", val, StringComparison.OrdinalIgnoreCase))
{
- if (string.Equals("HSBS", val, StringComparison.OrdinalIgnoreCase))
- {
- video.Video3DFormat = Video3DFormat.HalfSideBySide;
- }
- else if (string.Equals("HTAB", val, StringComparison.OrdinalIgnoreCase))
- {
- video.Video3DFormat = Video3DFormat.HalfTopAndBottom;
- }
- else if (string.Equals("FTAB", val, StringComparison.OrdinalIgnoreCase))
- {
- video.Video3DFormat = Video3DFormat.FullTopAndBottom;
- }
- else if (string.Equals("FSBS", val, StringComparison.OrdinalIgnoreCase))
- {
- video.Video3DFormat = Video3DFormat.FullSideBySide;
- }
- else if (string.Equals("MVC", val, StringComparison.OrdinalIgnoreCase))
- {
- video.Video3DFormat = Video3DFormat.MVC;
- }
+ video.Video3DFormat = Video3DFormat.HalfSideBySide;
+ }
+ else if (string.Equals("HTAB", val, StringComparison.OrdinalIgnoreCase))
+ {
+ video.Video3DFormat = Video3DFormat.HalfTopAndBottom;
+ }
+ else if (string.Equals("FTAB", val, StringComparison.OrdinalIgnoreCase))
+ {
+ video.Video3DFormat = Video3DFormat.FullTopAndBottom;
+ }
+ else if (string.Equals("FSBS", val, StringComparison.OrdinalIgnoreCase))
+ {
+ video.Video3DFormat = Video3DFormat.FullSideBySide;
+ }
+ else if (string.Equals("MVC", val, StringComparison.OrdinalIgnoreCase))
+ {
+ video.Video3DFormat = Video3DFormat.MVC;
}
- break;
}
+ break;
+ }
+
default:
+ {
+ string readerName = reader.Name;
+ if (_validProviderIds!.TryGetValue(readerName, out string providerIdValue))
{
- string readerName = reader.Name;
- if (_validProviderIds.TryGetValue(readerName, out string providerIdValue))
+ var id = reader.ReadElementContentAsString();
+ if (!string.IsNullOrWhiteSpace(id))
{
- var id = reader.ReadElementContentAsString();
- if (!string.IsNullOrWhiteSpace(id))
- {
- item.SetProviderId(providerIdValue, id);
- }
+ item.SetProviderId(providerIdValue, id);
}
- else
- {
- reader.Skip();
- }
-
- break;
-
}
+ else
+ {
+ reader.Skip();
+ }
+
+ break;
+ }
}
}
+
private void FetchFromSharesNode(XmlReader reader, IHasShares item)
{
var list = new List();
@@ -699,30 +716,31 @@ namespace MediaBrowser.LocalMetadata.Parsers
switch (reader.Name)
{
case "Share":
+ {
+ if (reader.IsEmptyElement)
{
- if (reader.IsEmptyElement)
- {
- reader.Read();
- continue;
- }
-
- using (var subReader = reader.ReadSubtree())
- {
- var child = GetShare(subReader);
-
- if (child != null)
- {
- list.Add(child);
- }
- }
-
- break;
+ reader.Read();
+ continue;
}
+
+ using (var subReader = reader.ReadSubtree())
+ {
+ var child = GetShare(subReader);
+
+ if (child != null)
+ {
+ list.Add(child);
+ }
+ }
+
+ break;
+ }
+
default:
- {
- reader.Skip();
- break;
- }
+ {
+ reader.Skip();
+ break;
+ }
}
}
else
@@ -749,16 +767,16 @@ namespace MediaBrowser.LocalMetadata.Parsers
switch (reader.Name)
{
case "UserId":
- {
- share.UserId = reader.ReadElementContentAsString();
- break;
- }
+ {
+ share.UserId = reader.ReadElementContentAsString();
+ break;
+ }
case "CanEdit":
- {
- share.CanEdit = string.Equals(reader.ReadElementContentAsString(), true.ToString(), StringComparison.OrdinalIgnoreCase);
- break;
- }
+ {
+ share.CanEdit = string.Equals(reader.ReadElementContentAsString(), true.ToString(CultureInfo.InvariantCulture), StringComparison.OrdinalIgnoreCase);
+ break;
+ }
default:
reader.Skip();
@@ -774,7 +792,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
return share;
}
- private void FetchFromCountriesNode(XmlReader reader, T item)
+ private void FetchFromCountriesNode(XmlReader reader)
{
reader.MoveToContent();
reader.Read();
@@ -787,15 +805,16 @@ namespace MediaBrowser.LocalMetadata.Parsers
switch (reader.Name)
{
case "Country":
- {
- var val = reader.ReadElementContentAsString();
+ {
+ var val = reader.ReadElementContentAsString();
- if (!string.IsNullOrWhiteSpace(val))
- {
- }
- break;
+ if (!string.IsNullOrWhiteSpace(val))
+ {
}
+ break;
+ }
+
default:
reader.Skip();
break;
@@ -826,15 +845,17 @@ namespace MediaBrowser.LocalMetadata.Parsers
switch (reader.Name)
{
case "Tagline":
- {
- var val = reader.ReadElementContentAsString();
+ {
+ var val = reader.ReadElementContentAsString();
- if (!string.IsNullOrWhiteSpace(val))
- {
- item.Tagline = val;
- }
- break;
+ if (!string.IsNullOrWhiteSpace(val))
+ {
+ item.Tagline = val;
}
+
+ break;
+ }
+
default:
reader.Skip();
break;
@@ -865,16 +886,17 @@ namespace MediaBrowser.LocalMetadata.Parsers
switch (reader.Name)
{
case "Genre":
- {
- var genre = reader.ReadElementContentAsString();
+ {
+ var genre = reader.ReadElementContentAsString();
- if (!string.IsNullOrWhiteSpace(genre))
- {
- item.AddGenre(genre);
- }
- break;
+ if (!string.IsNullOrWhiteSpace(genre))
+ {
+ item.AddGenre(genre);
}
+ break;
+ }
+
default:
reader.Skip();
break;
@@ -902,16 +924,17 @@ namespace MediaBrowser.LocalMetadata.Parsers
switch (reader.Name)
{
case "Tag":
- {
- var tag = reader.ReadElementContentAsString();
+ {
+ var tag = reader.ReadElementContentAsString();
- if (!string.IsNullOrWhiteSpace(tag))
- {
- tags.Add(tag);
- }
- break;
+ if (!string.IsNullOrWhiteSpace(tag))
+ {
+ tags.Add(tag);
}
+ break;
+ }
+
default:
reader.Skip();
break;
@@ -945,26 +968,29 @@ namespace MediaBrowser.LocalMetadata.Parsers
{
case "Person":
case "Actor":
+ {
+ if (reader.IsEmptyElement)
{
- if (reader.IsEmptyElement)
- {
- reader.Read();
- continue;
- }
- using (var subtree = reader.ReadSubtree())
- {
- foreach (var person in GetPersonsFromXmlNode(subtree))
- {
- if (string.IsNullOrWhiteSpace(person.Name))
- {
- continue;
- }
- item.AddPerson(person);
- }
- }
- break;
+ reader.Read();
+ continue;
}
+ using (var subtree = reader.ReadSubtree())
+ {
+ foreach (var person in GetPersonsFromXmlNode(subtree))
+ {
+ if (string.IsNullOrWhiteSpace(person.Name))
+ {
+ continue;
+ }
+
+ item.AddPerson(person);
+ }
+ }
+
+ break;
+ }
+
default:
reader.Skip();
break;
@@ -990,16 +1016,17 @@ namespace MediaBrowser.LocalMetadata.Parsers
switch (reader.Name)
{
case "Trailer":
- {
- var val = reader.ReadElementContentAsString();
+ {
+ var val = reader.ReadElementContentAsString();
- if (!string.IsNullOrWhiteSpace(val))
- {
- item.AddTrailerUrl(val);
- }
- break;
+ if (!string.IsNullOrWhiteSpace(val))
+ {
+ item.AddTrailerUrl(val);
}
+ break;
+ }
+
default:
reader.Skip();
break;
@@ -1030,16 +1057,17 @@ namespace MediaBrowser.LocalMetadata.Parsers
switch (reader.Name)
{
case "Studio":
- {
- var studio = reader.ReadElementContentAsString();
+ {
+ var studio = reader.ReadElementContentAsString();
- if (!string.IsNullOrWhiteSpace(studio))
- {
- item.AddStudio(studio);
- }
- break;
+ if (!string.IsNullOrWhiteSpace(studio))
+ {
+ item.AddStudio(studio);
}
+ break;
+ }
+
default:
reader.Skip();
break;
@@ -1060,7 +1088,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
private IEnumerable GetPersonsFromXmlNode(XmlReader reader)
{
var name = string.Empty;
- var type = PersonType.Actor; // If type is not specified assume actor
+ var type = PersonType.Actor; // If type is not specified assume actor
var role = string.Empty;
int? sortOrder = null;
@@ -1079,40 +1107,44 @@ namespace MediaBrowser.LocalMetadata.Parsers
break;
case "Type":
- {
- var val = reader.ReadElementContentAsString();
+ {
+ var val = reader.ReadElementContentAsString();
- if (!string.IsNullOrWhiteSpace(val))
- {
- type = val;
- }
- break;
+ if (!string.IsNullOrWhiteSpace(val))
+ {
+ type = val;
}
+ break;
+ }
+
case "Role":
- {
- var val = reader.ReadElementContentAsString();
+ {
+ var val = reader.ReadElementContentAsString();
- if (!string.IsNullOrWhiteSpace(val))
- {
- role = val;
- }
- break;
+ if (!string.IsNullOrWhiteSpace(val))
+ {
+ role = val;
}
+
+ break;
+ }
+
case "SortOrder":
- {
- var val = reader.ReadElementContentAsString();
+ {
+ var val = reader.ReadElementContentAsString();
- if (!string.IsNullOrWhiteSpace(val))
+ if (!string.IsNullOrWhiteSpace(val))
+ {
+ if (int.TryParse(val, NumberStyles.Integer, _usCulture, out var intVal))
{
- if (int.TryParse(val, NumberStyles.Integer, _usCulture, out var intVal))
- {
- sortOrder = intVal;
- }
+ sortOrder = intVal;
}
- break;
}
+ break;
+ }
+
default:
reader.Skip();
break;
@@ -1124,23 +1156,19 @@ namespace MediaBrowser.LocalMetadata.Parsers
}
}
- var personInfo = new PersonInfo
- {
- Name = name.Trim(),
- Role = role,
- Type = type,
- SortOrder = sortOrder
- };
+ var personInfo = new PersonInfo { Name = name.Trim(), Role = role, Type = type, SortOrder = sortOrder };
return new[] { personInfo };
}
- protected LinkedChild GetLinkedChild(XmlReader reader)
+ ///
+ /// Get linked child.
+ ///
+ /// The xml reader.
+ /// The linked child.
+ protected LinkedChild? GetLinkedChild(XmlReader reader)
{
- var linkedItem = new LinkedChild
- {
- Type = LinkedChildType.Manual
- };
+ var linkedItem = new LinkedChild { Type = LinkedChildType.Manual };
reader.MoveToContent();
reader.Read();
@@ -1153,15 +1181,16 @@ namespace MediaBrowser.LocalMetadata.Parsers
switch (reader.Name)
{
case "Path":
- {
- linkedItem.Path = reader.ReadElementContentAsString();
- break;
- }
+ {
+ linkedItem.Path = reader.ReadElementContentAsString();
+ break;
+ }
+
case "ItemId":
- {
- linkedItem.LibraryItemId = reader.ReadElementContentAsString();
- break;
- }
+ {
+ linkedItem.LibraryItemId = reader.ReadElementContentAsString();
+ break;
+ }
default:
reader.Skip();
@@ -1183,7 +1212,12 @@ namespace MediaBrowser.LocalMetadata.Parsers
return null;
}
- protected Share GetShare(XmlReader reader)
+ ///
+ /// Get share.
+ ///
+ /// The xml reader.
+ /// The share.
+ protected Share? GetShare(XmlReader reader)
{
var item = new Share();
@@ -1198,21 +1232,22 @@ namespace MediaBrowser.LocalMetadata.Parsers
switch (reader.Name)
{
case "UserId":
- {
- item.UserId = reader.ReadElementContentAsString();
- break;
- }
+ {
+ item.UserId = reader.ReadElementContentAsString();
+ break;
+ }
case "CanEdit":
- {
- item.CanEdit = string.Equals(reader.ReadElementContentAsString(), "true", StringComparison.OrdinalIgnoreCase);
- break;
- }
+ {
+ item.CanEdit = string.Equals(reader.ReadElementContentAsString(), "true", StringComparison.OrdinalIgnoreCase);
+ break;
+ }
+
default:
- {
- reader.Skip();
- break;
- }
+ {
+ reader.Skip();
+ break;
+ }
}
}
else
@@ -1230,19 +1265,19 @@ namespace MediaBrowser.LocalMetadata.Parsers
return null;
}
-
///
- /// Used to split names of comma or pipe delimeted genres and people
+ /// Used to split names of comma or pipe delimited genres and people.
///
/// The value.
/// IEnumerable{System.String}.
private IEnumerable SplitNames(string value)
{
- value = value ?? string.Empty;
+ value ??= string.Empty;
// Only split by comma if there is no pipe in the string
// We have to be careful to not split names like Matthew, Jr.
- var separator = value.IndexOf('|') == -1 && value.IndexOf(';') == -1 ? new[] { ',' } : new[] { '|', ';' };
+ var separator = value.IndexOf('|', StringComparison.Ordinal) == -1
+ && value.IndexOf(';', StringComparison.Ordinal) == -1 ? new[] { ',' } : new[] { '|', ';' };
value = value.Trim().Trim(separator);
@@ -1250,7 +1285,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
}
///
- /// Provides an additional overload for string.split
+ /// Provides an additional overload for string.split.
///
/// The val.
/// The separators.
@@ -1260,6 +1295,5 @@ namespace MediaBrowser.LocalMetadata.Parsers
{
return val.Split(separators, options);
}
-
}
}
diff --git a/MediaBrowser.LocalMetadata/Parsers/BoxSetXmlParser.cs b/MediaBrowser.LocalMetadata/Parsers/BoxSetXmlParser.cs
index ca11a079d..ff846830b 100644
--- a/MediaBrowser.LocalMetadata/Parsers/BoxSetXmlParser.cs
+++ b/MediaBrowser.LocalMetadata/Parsers/BoxSetXmlParser.cs
@@ -7,8 +7,22 @@ using Microsoft.Extensions.Logging;
namespace MediaBrowser.LocalMetadata.Parsers
{
+ ///
+ /// The box set xml parser.
+ ///
public class BoxSetXmlParser : BaseItemXmlParser
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Instance of the interface.
+ /// Instance of the interface.
+ public BoxSetXmlParser(ILogger logger, IProviderManager providerManager)
+ : base(logger, providerManager)
+ {
+ }
+
+ ///
protected override void FetchDataFromXmlNode(XmlReader reader, MetadataResult item)
{
switch (reader.Name)
@@ -26,6 +40,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
{
reader.Read();
}
+
break;
default:
@@ -49,31 +64,32 @@ namespace MediaBrowser.LocalMetadata.Parsers
switch (reader.Name)
{
case "CollectionItem":
+ {
+ if (!reader.IsEmptyElement)
{
- if (!reader.IsEmptyElement)
+ using (var subReader = reader.ReadSubtree())
{
- using (var subReader = reader.ReadSubtree())
- {
- var child = GetLinkedChild(subReader);
+ var child = GetLinkedChild(subReader);
- if (child != null)
- {
- list.Add(child);
- }
+ if (child != null)
+ {
+ list.Add(child);
}
}
- else
- {
- reader.Read();
- }
-
- break;
}
- default:
+ else
{
- reader.Skip();
- break;
+ reader.Read();
}
+
+ break;
+ }
+
+ default:
+ {
+ reader.Skip();
+ break;
+ }
}
}
else
@@ -84,10 +100,5 @@ namespace MediaBrowser.LocalMetadata.Parsers
item.Item.LinkedChildren = list.ToArray();
}
-
- public BoxSetXmlParser(ILogger logger, IProviderManager providerManager)
- : base(logger, providerManager)
- {
- }
}
}
diff --git a/MediaBrowser.LocalMetadata/Parsers/PlaylistXmlParser.cs b/MediaBrowser.LocalMetadata/Parsers/PlaylistXmlParser.cs
index 54710cd82..78c0fa8ad 100644
--- a/MediaBrowser.LocalMetadata/Parsers/PlaylistXmlParser.cs
+++ b/MediaBrowser.LocalMetadata/Parsers/PlaylistXmlParser.cs
@@ -7,8 +7,22 @@ using Microsoft.Extensions.Logging;
namespace MediaBrowser.LocalMetadata.Parsers
{
+ ///
+ /// Playlist xml parser.
+ ///
public class PlaylistXmlParser : BaseItemXmlParser
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Instance of the interface.
+ /// Instance of the interface.
+ public PlaylistXmlParser(ILogger logger, IProviderManager providerManager)
+ : base(logger, providerManager)
+ {
+ }
+
+ ///
protected override void FetchDataFromXmlNode(XmlReader reader, MetadataResult result)
{
var item = result.Item;
@@ -16,11 +30,11 @@ namespace MediaBrowser.LocalMetadata.Parsers
switch (reader.Name)
{
case "PlaylistMediaType":
- {
- item.PlaylistMediaType = reader.ReadElementContentAsString();
+ {
+ item.PlaylistMediaType = reader.ReadElementContentAsString();
- break;
- }
+ break;
+ }
case "PlaylistItems":
@@ -35,6 +49,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
{
reader.Read();
}
+
break;
default:
@@ -58,30 +73,31 @@ namespace MediaBrowser.LocalMetadata.Parsers
switch (reader.Name)
{
case "PlaylistItem":
+ {
+ if (reader.IsEmptyElement)
{
- if (reader.IsEmptyElement)
- {
- reader.Read();
- continue;
- }
-
- using (var subReader = reader.ReadSubtree())
- {
- var child = GetLinkedChild(subReader);
-
- if (child != null)
- {
- list.Add(child);
- }
- }
-
- break;
+ reader.Read();
+ continue;
}
+
+ using (var subReader = reader.ReadSubtree())
+ {
+ var child = GetLinkedChild(subReader);
+
+ if (child != null)
+ {
+ list.Add(child);
+ }
+ }
+
+ break;
+ }
+
default:
- {
- reader.Skip();
- break;
- }
+ {
+ reader.Skip();
+ break;
+ }
}
}
else
@@ -92,10 +108,5 @@ namespace MediaBrowser.LocalMetadata.Parsers
item.LinkedChildren = list.ToArray();
}
-
- public PlaylistXmlParser(ILogger logger, IProviderManager providerManager)
- : base(logger, providerManager)
- {
- }
}
}
diff --git a/MediaBrowser.LocalMetadata/Providers/BoxSetXmlProvider.cs b/MediaBrowser.LocalMetadata/Providers/BoxSetXmlProvider.cs
index 2d115a591..cc705a9df 100644
--- a/MediaBrowser.LocalMetadata/Providers/BoxSetXmlProvider.cs
+++ b/MediaBrowser.LocalMetadata/Providers/BoxSetXmlProvider.cs
@@ -16,6 +16,12 @@ namespace MediaBrowser.LocalMetadata.Providers
private readonly ILogger _logger;
private readonly IProviderManager _providerManager;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Instance of the interface.
+ /// Instance of the interface.
+ /// Instance of the interface.
public BoxSetXmlProvider(IFileSystem fileSystem, ILogger logger, IProviderManager providerManager)
: base(fileSystem)
{
@@ -23,11 +29,13 @@ namespace MediaBrowser.LocalMetadata.Providers
_providerManager = providerManager;
}
+ ///
protected override void Fetch(MetadataResult result, string path, CancellationToken cancellationToken)
{
new BoxSetXmlParser(_logger, _providerManager).Fetch(result, path, cancellationToken);
}
+ ///
protected override FileSystemMetadata GetXmlFile(ItemInfo info, IDirectoryService directoryService)
{
return directoryService.GetFile(Path.Combine(info.Path, "collection.xml"));
diff --git a/MediaBrowser.LocalMetadata/Providers/PlaylistXmlProvider.cs b/MediaBrowser.LocalMetadata/Providers/PlaylistXmlProvider.cs
index d4e2bc8e5..36f3048ad 100644
--- a/MediaBrowser.LocalMetadata/Providers/PlaylistXmlProvider.cs
+++ b/MediaBrowser.LocalMetadata/Providers/PlaylistXmlProvider.cs
@@ -8,11 +8,20 @@ using Microsoft.Extensions.Logging;
namespace MediaBrowser.LocalMetadata.Providers
{
+ ///
+ /// Playlist xml provider.
+ ///
public class PlaylistXmlProvider : BaseXmlProvider
{
private readonly ILogger _logger;
private readonly IProviderManager _providerManager;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Instance of the interface.
+ /// Instance of the interface.
+ /// Instance of the interface.
public PlaylistXmlProvider(
IFileSystem fileSystem,
ILogger logger,
@@ -23,14 +32,16 @@ namespace MediaBrowser.LocalMetadata.Providers
_providerManager = providerManager;
}
+ ///
protected override void Fetch(MetadataResult result, string path, CancellationToken cancellationToken)
{
new PlaylistXmlParser(_logger, _providerManager).Fetch(result, path, cancellationToken);
}
+ ///
protected override FileSystemMetadata GetXmlFile(ItemInfo info, IDirectoryService directoryService)
{
- return directoryService.GetFile(PlaylistXmlSaver.GetSavePath(info.Path, FileSystem));
+ return directoryService.GetFile(PlaylistXmlSaver.GetSavePath(info.Path));
}
}
}
diff --git a/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs b/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs
index 071902393..db1cbfebe 100644
--- a/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs
+++ b/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs
@@ -17,10 +17,25 @@ using Microsoft.Extensions.Logging;
namespace MediaBrowser.LocalMetadata.Savers
{
+ ///
public abstract class BaseXmlSaver : IMetadataFileSaver
{
- private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
+ ///
+ /// Gets the date added format.
+ ///
+ public const string DateAddedFormat = "yyyy-MM-dd HH:mm:ss";
+ private static readonly CultureInfo _usCulture = new CultureInfo("en-US");
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Instance of the interface.
+ /// Instance of the interface.
+ /// Instance of the interface.
+ /// Instance of the interface.
+ /// Instance of the interface.
+ /// Instance of the interface.
public BaseXmlSaver(IFileSystem fileSystem, IServerConfigurationManager configurationManager, ILibraryManager libraryManager, IUserManager userManager, IUserDataManager userDataManager, ILogger logger)
{
FileSystem = fileSystem;
@@ -31,15 +46,40 @@ namespace MediaBrowser.LocalMetadata.Savers
Logger = logger;
}
+ ///
+ /// Gets the file system.
+ ///
protected IFileSystem FileSystem { get; private set; }
+
+ ///
+ /// Gets the configuration manager.
+ ///
protected IServerConfigurationManager ConfigurationManager { get; private set; }
+
+ ///
+ /// Gets the library manager.
+ ///
protected ILibraryManager LibraryManager { get; private set; }
+
+ ///
+ /// Gets the user manager.
+ ///
protected IUserManager UserManager { get; private set; }
+
+ ///
+ /// Gets the user data manager.
+ ///
protected IUserDataManager UserDataManager { get; private set; }
+
+ ///
+ /// Gets the logger.
+ ///
protected ILogger Logger { get; private set; }
+ ///
public string Name => XmlProviderUtils.Name;
+ ///
public string GetSavePath(BaseItem item)
{
return GetLocalSavePath(item);
@@ -70,20 +110,19 @@ namespace MediaBrowser.LocalMetadata.Savers
/// true if [is enabled for] [the specified item]; otherwise, false.
public abstract bool IsEnabledFor(BaseItem item, ItemUpdateType updateType);
+ ///
public void Save(BaseItem item, CancellationToken cancellationToken)
{
var path = GetSavePath(item);
- using (var memoryStream = new MemoryStream())
- {
- Save(item, memoryStream, path);
+ using var memoryStream = new MemoryStream();
+ Save(item, memoryStream);
- memoryStream.Position = 0;
+ memoryStream.Position = 0;
- cancellationToken.ThrowIfCancellationRequested();
+ cancellationToken.ThrowIfCancellationRequested();
- SaveToFile(memoryStream, path);
- }
+ SaveToFile(memoryStream, path);
}
private void SaveToFile(Stream stream, string path)
@@ -115,7 +154,7 @@ namespace MediaBrowser.LocalMetadata.Savers
}
}
- private void Save(BaseItem item, Stream stream, string xmlPath)
+ private void Save(BaseItem item, Stream stream)
{
var settings = new XmlWriterSettings
{
@@ -136,7 +175,7 @@ namespace MediaBrowser.LocalMetadata.Savers
if (baseItem != null)
{
- AddCommonNodes(baseItem, writer, LibraryManager, UserManager, UserDataManager, FileSystem, ConfigurationManager);
+ AddCommonNodes(baseItem, writer, LibraryManager);
}
WriteCustomElements(item, writer);
@@ -147,22 +186,27 @@ namespace MediaBrowser.LocalMetadata.Savers
}
}
+ ///
+ /// Write custom elements.
+ ///
+ /// The item.
+ /// The xml writer.
protected abstract void WriteCustomElements(BaseItem item, XmlWriter writer);
- public const string DateAddedFormat = "yyyy-MM-dd HH:mm:ss";
-
///
- /// Adds the common nodes.
+ /// Adds common notes.
///
- /// Task.
- public static void AddCommonNodes(BaseItem item, XmlWriter writer, ILibraryManager libraryManager, IUserManager userManager, IUserDataManager userDataRepo, IFileSystem fileSystem, IServerConfigurationManager config)
+ /// The item.
+ /// The xml writer.
+ /// Instance of the interface.
+ public static void AddCommonNodes(BaseItem item, XmlWriter writer, ILibraryManager libraryManager)
{
if (!string.IsNullOrEmpty(item.OfficialRating))
{
writer.WriteElementString("ContentRating", item.OfficialRating);
}
- writer.WriteElementString("Added", item.DateCreated.ToLocalTime().ToString("G"));
+ writer.WriteElementString("Added", item.DateCreated.ToLocalTime().ToString("G", CultureInfo.InvariantCulture));
writer.WriteElementString("LockData", item.IsLocked.ToString(CultureInfo.InvariantCulture).ToLowerInvariant());
@@ -173,7 +217,7 @@ namespace MediaBrowser.LocalMetadata.Savers
if (item.CriticRating.HasValue)
{
- writer.WriteElementString("CriticRating", item.CriticRating.Value.ToString(UsCulture));
+ writer.WriteElementString("CriticRating", item.CriticRating.Value.ToString(_usCulture));
}
if (!string.IsNullOrEmpty(item.Overview))
@@ -185,6 +229,7 @@ namespace MediaBrowser.LocalMetadata.Savers
{
writer.WriteElementString("OriginalTitle", item.OriginalTitle);
}
+
if (!string.IsNullOrEmpty(item.CustomRating))
{
writer.WriteElementString("CustomRating", item.CustomRating);
@@ -205,11 +250,11 @@ namespace MediaBrowser.LocalMetadata.Savers
{
if (item is Person)
{
- writer.WriteElementString("BirthDate", item.PremiereDate.Value.ToLocalTime().ToString("yyyy-MM-dd"));
+ writer.WriteElementString("BirthDate", item.PremiereDate.Value.ToLocalTime().ToString("yyyy-MM-dd", CultureInfo.InvariantCulture));
}
else if (!(item is Episode))
{
- writer.WriteElementString("PremiereDate", item.PremiereDate.Value.ToLocalTime().ToString("yyyy-MM-dd"));
+ writer.WriteElementString("PremiereDate", item.PremiereDate.Value.ToLocalTime().ToString("yyyy-MM-dd", CultureInfo.InvariantCulture));
}
}
@@ -217,11 +262,11 @@ namespace MediaBrowser.LocalMetadata.Savers
{
if (item is Person)
{
- writer.WriteElementString("DeathDate", item.EndDate.Value.ToLocalTime().ToString("yyyy-MM-dd"));
+ writer.WriteElementString("DeathDate", item.EndDate.Value.ToLocalTime().ToString("yyyy-MM-dd", CultureInfo.InvariantCulture));
}
else if (!(item is Episode))
{
- writer.WriteElementString("EndDate", item.EndDate.Value.ToLocalTime().ToString("yyyy-MM-dd"));
+ writer.WriteElementString("EndDate", item.EndDate.Value.ToLocalTime().ToString("yyyy-MM-dd", CultureInfo.InvariantCulture));
}
}
@@ -257,12 +302,12 @@ namespace MediaBrowser.LocalMetadata.Savers
if (item.CommunityRating.HasValue)
{
- writer.WriteElementString("Rating", item.CommunityRating.Value.ToString(UsCulture));
+ writer.WriteElementString("Rating", item.CommunityRating.Value.ToString(_usCulture));
}
if (item.ProductionYear.HasValue && !(item is Person))
{
- writer.WriteElementString("ProductionYear", item.ProductionYear.Value.ToString(UsCulture));
+ writer.WriteElementString("ProductionYear", item.ProductionYear.Value.ToString(_usCulture));
}
var hasAspectRatio = item as IHasAspectRatio;
@@ -278,6 +323,7 @@ namespace MediaBrowser.LocalMetadata.Savers
{
writer.WriteElementString("Language", item.PreferredMetadataLanguage);
}
+
if (!string.IsNullOrEmpty(item.PreferredMetadataCountryCode))
{
writer.WriteElementString("CountryCode", item.PreferredMetadataCountryCode);
@@ -288,9 +334,9 @@ namespace MediaBrowser.LocalMetadata.Savers
if (runTimeTicks.HasValue)
{
- var timespan = TimeSpan.FromTicks(runTimeTicks.Value);
+ var timespan = TimeSpan.FromTicks(runTimeTicks!.Value);
- writer.WriteElementString("RunningTime", Math.Floor(timespan.TotalMinutes).ToString(UsCulture));
+ writer.WriteElementString("RunningTime", Math.Floor(timespan.TotalMinutes).ToString(_usCulture));
}
if (item.ProviderIds != null)
@@ -363,7 +409,7 @@ namespace MediaBrowser.LocalMetadata.Savers
if (person.SortOrder.HasValue)
{
- writer.WriteElementString("SortOrder", person.SortOrder.Value.ToString(UsCulture));
+ writer.WriteElementString("SortOrder", person.SortOrder.Value.ToString(_usCulture));
}
writer.WriteEndElement();
@@ -393,6 +439,11 @@ namespace MediaBrowser.LocalMetadata.Savers
AddMediaInfo(item, writer);
}
+ ///
+ /// Add shares.
+ ///
+ /// The item.
+ /// The xml writer.
public static void AddShares(IHasShares item, XmlWriter writer)
{
writer.WriteStartElement("Shares");
@@ -415,13 +466,13 @@ namespace MediaBrowser.LocalMetadata.Savers
///
/// Appends the media info.
///
- ///
+ /// The item.
+ /// The xml writer.
+ /// Type of item.
public static void AddMediaInfo(T item, XmlWriter writer)
where T : BaseItem
{
- var video = item as Video;
-
- if (video != null)
+ if (item is Video video)
{
if (video.Video3DFormat.HasValue)
{
@@ -447,6 +498,13 @@ namespace MediaBrowser.LocalMetadata.Savers
}
}
+ ///
+ /// ADd linked children.
+ ///
+ /// The item.
+ /// The xml writer.
+ /// The plural node name.
+ /// The singular node name.
public static void AddLinkedChildren(Folder item, XmlWriter writer, string pluralNodeName, string singularNodeName)
{
var items = item.LinkedChildren
diff --git a/MediaBrowser.LocalMetadata/Savers/BoxSetXmlSaver.cs b/MediaBrowser.LocalMetadata/Savers/BoxSetXmlSaver.cs
index 1dc09bf18..b08387b0c 100644
--- a/MediaBrowser.LocalMetadata/Savers/BoxSetXmlSaver.cs
+++ b/MediaBrowser.LocalMetadata/Savers/BoxSetXmlSaver.cs
@@ -9,8 +9,26 @@ using Microsoft.Extensions.Logging;
namespace MediaBrowser.LocalMetadata.Savers
{
+ ///
+ /// Box set xml saver.
+ ///
public class BoxSetXmlSaver : BaseXmlSaver
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Instance of the interface.
+ /// Instance of the interface.
+ /// Instance of the interface.
+ /// Instance of the interface.
+ /// Instance of the interface.
+ /// Instance of the interface.
+ public BoxSetXmlSaver(IFileSystem fileSystem, IServerConfigurationManager configurationManager, ILibraryManager libraryManager, IUserManager userManager, IUserDataManager userDataManager, ILogger logger)
+ : base(fileSystem, configurationManager, libraryManager, userManager, userDataManager, logger)
+ {
+ }
+
+ ///
public override bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
{
if (!item.SupportsLocalMetadata)
@@ -21,18 +39,15 @@ namespace MediaBrowser.LocalMetadata.Savers
return item is BoxSet && updateType >= ItemUpdateType.MetadataDownload;
}
+ ///
protected override void WriteCustomElements(BaseItem item, XmlWriter writer)
{
}
+ ///
protected override string GetLocalSavePath(BaseItem item)
{
return Path.Combine(item.Path, "collection.xml");
}
-
- public BoxSetXmlSaver(IFileSystem fileSystem, IServerConfigurationManager configurationManager, ILibraryManager libraryManager, IUserManager userManager, IUserDataManager userDataManager, ILogger logger)
- : base(fileSystem, configurationManager, libraryManager, userManager, userDataManager, logger)
- {
- }
}
}
diff --git a/MediaBrowser.LocalMetadata/Savers/PlaylistXmlSaver.cs b/MediaBrowser.LocalMetadata/Savers/PlaylistXmlSaver.cs
index bbb0a3501..c2f106423 100644
--- a/MediaBrowser.LocalMetadata/Savers/PlaylistXmlSaver.cs
+++ b/MediaBrowser.LocalMetadata/Savers/PlaylistXmlSaver.cs
@@ -9,6 +9,9 @@ using Microsoft.Extensions.Logging;
namespace MediaBrowser.LocalMetadata.Savers
{
+ ///
+ /// Playlist xml saver.
+ ///
public class PlaylistXmlSaver : BaseXmlSaver
{
///
@@ -16,6 +19,21 @@ namespace MediaBrowser.LocalMetadata.Savers
///
public const string DefaultPlaylistFilename = "playlist.xml";
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Instance of the interface.
+ /// Instance of the interface.
+ /// Instance of the interface.
+ /// Instance of the interface.
+ /// Instance of the interface.
+ /// Instance of the interface.
+ public PlaylistXmlSaver(IFileSystem fileSystem, IServerConfigurationManager configurationManager, ILibraryManager libraryManager, IUserManager userManager, IUserDataManager userDataManager, ILogger logger)
+ : base(fileSystem, configurationManager, libraryManager, userManager, userDataManager, logger)
+ {
+ }
+
+ ///
public override bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
{
if (!item.SupportsLocalMetadata)
@@ -26,6 +44,7 @@ namespace MediaBrowser.LocalMetadata.Savers
return item is Playlist && updateType >= ItemUpdateType.MetadataImport;
}
+ ///
protected override void WriteCustomElements(BaseItem item, XmlWriter writer)
{
var game = (Playlist)item;
@@ -36,12 +55,18 @@ namespace MediaBrowser.LocalMetadata.Savers
}
}
+ ///
protected override string GetLocalSavePath(BaseItem item)
{
- return GetSavePath(item.Path, FileSystem);
+ return GetSavePath(item.Path);
}
- public static string GetSavePath(string itemPath, IFileSystem fileSystem)
+ ///
+ /// Get the save path.
+ ///
+ /// The item path.
+ /// The save path.
+ public static string GetSavePath(string itemPath)
{
var path = itemPath;
@@ -52,10 +77,5 @@ namespace MediaBrowser.LocalMetadata.Savers
return Path.Combine(path, DefaultPlaylistFilename);
}
-
- public PlaylistXmlSaver(IFileSystem fileSystem, IServerConfigurationManager configurationManager, ILibraryManager libraryManager, IUserManager userManager, IUserDataManager userDataManager, ILogger logger)
- : base(fileSystem, configurationManager, libraryManager, userManager, userDataManager, logger)
- {
- }
}
}
diff --git a/MediaBrowser.LocalMetadata/XmlProviderUtils.cs b/MediaBrowser.LocalMetadata/XmlProviderUtils.cs
new file mode 100644
index 000000000..e247b8bb8
--- /dev/null
+++ b/MediaBrowser.LocalMetadata/XmlProviderUtils.cs
@@ -0,0 +1,13 @@
+namespace MediaBrowser.LocalMetadata
+{
+ ///
+ /// The xml provider utils.
+ ///
+ public static class XmlProviderUtils
+ {
+ ///
+ /// Gets the name.
+ ///
+ public static string Name => "Emby Xml";
+ }
+}