mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-22 18:23:45 +00:00
removed static logger
This commit is contained in:
@@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using MediaBrowser.Model.Logging;
|
||||
|
||||
namespace MediaBrowser.Controller.Drawing
|
||||
{
|
||||
@@ -36,9 +37,10 @@ namespace MediaBrowser.Controller.Drawing
|
||||
/// Gets the dimensions of an image.
|
||||
/// </summary>
|
||||
/// <param name="path">The path of the image to get the dimensions of.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <returns>The dimensions of the specified image.</returns>
|
||||
/// <exception cref="ArgumentException">The image was of an unrecognised format.</exception>
|
||||
public static Size GetDimensions(string path)
|
||||
public static Size GetDimensions(string path, ILogger logger)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -52,7 +54,7 @@ namespace MediaBrowser.Controller.Drawing
|
||||
}
|
||||
catch
|
||||
{
|
||||
Logger.LogInfo("Failed to read image header for {0}. Doing it the slow way.", path);
|
||||
logger.Info("Failed to read image header for {0}. Doing it the slow way.", path);
|
||||
|
||||
using (var fs = File.OpenRead(path))
|
||||
{
|
||||
|
||||
@@ -276,7 +276,7 @@ namespace MediaBrowser.Controller.Drawing
|
||||
// Cache file doesn't exist no biggie
|
||||
}
|
||||
|
||||
var size = ImageHeader.GetDimensions(imagePath);
|
||||
var size = ImageHeader.GetDimensions(imagePath, Logger);
|
||||
|
||||
var imageSize = new ImageSize { Width = size.Width, Height = size.Height };
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Model.Logging;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
@@ -93,6 +94,11 @@ namespace MediaBrowser.Controller.Entities
|
||||
/// <value>The date modified.</value>
|
||||
public DateTime DateModified { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
protected static ILogger Logger = LogManager.GetLogger("BaseItem");
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="System.String" /> that represents this instance.
|
||||
/// </summary>
|
||||
@@ -268,7 +274,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Logger.LogException("Error creating resolve args for ", ex, Path);
|
||||
Logger.ErrorException("Error creating resolve args for ", ex, Path);
|
||||
|
||||
throw;
|
||||
}
|
||||
@@ -581,7 +587,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Logger.LogException("Error getting ResolveArgs for {0}", ex, Path);
|
||||
Logger.ErrorException("Error getting ResolveArgs for {0}", ex, Path);
|
||||
return new List<Video> { };
|
||||
}
|
||||
|
||||
@@ -606,7 +612,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Logger.LogException("Error loading trailers for {0}", ex, Name);
|
||||
Logger.ErrorException("Error loading trailers for {0}", ex, Name);
|
||||
return new List<Video> { };
|
||||
}
|
||||
|
||||
@@ -975,7 +981,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
var changed = copy.DateModified != DateModified;
|
||||
if (changed)
|
||||
{
|
||||
Logger.LogDebugInfo(Name + " changed - original creation: " + DateCreated + " new creation: " + copy.DateCreated + " original modified: " + DateModified + " new modified: " + copy.DateModified);
|
||||
Logger.Debug(Name + " changed - original creation: " + DateCreated + " new creation: " + copy.DateCreated + " original modified: " + DateModified + " new modified: " + copy.DateModified);
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Logger.LogException("Error creating FolderIds for {0}", ex, Path);
|
||||
Logger.ErrorException("Error creating FolderIds for {0}", ex, Path);
|
||||
|
||||
folderIds = new Guid[] {};
|
||||
}
|
||||
|
||||
@@ -306,7 +306,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
|
||||
// Even though this implementation means multiple iterations over the target list - it allows us to defer
|
||||
// the retrieval of the individual children for each index value until they are requested.
|
||||
using (new Profiler(indexName + " Index Build for " + Name))
|
||||
using (new Profiler(indexName + " Index Build for " + Name, Logger))
|
||||
{
|
||||
// Put this in a local variable to avoid an implicitly captured closure
|
||||
var currentIndexName = indexName;
|
||||
@@ -325,12 +325,12 @@ namespace MediaBrowser.Controller.Entities
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Logger.LogException("Error getting person {0}", ex, i);
|
||||
Logger.ErrorException("Error getting person {0}", ex, i);
|
||||
return null;
|
||||
}
|
||||
catch (AggregateException ex)
|
||||
{
|
||||
Logger.LogException("Error getting person {0}", ex, i);
|
||||
Logger.ErrorException("Error getting person {0}", ex, i);
|
||||
return null;
|
||||
}
|
||||
})
|
||||
@@ -351,7 +351,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
// Even though this implementation means multiple iterations over the target list - it allows us to defer
|
||||
// the retrieval of the individual children for each index value until they are requested.
|
||||
using (new Profiler("Studio Index Build for " + Name))
|
||||
using (new Profiler("Studio Index Build for " + Name, Logger))
|
||||
{
|
||||
var indexName = LocalizedStrings.Instance.GetString("StudioDispPref");
|
||||
|
||||
@@ -367,12 +367,12 @@ namespace MediaBrowser.Controller.Entities
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Logger.LogException("Error getting studio {0}", ex, i);
|
||||
Logger.ErrorException("Error getting studio {0}", ex, i);
|
||||
return null;
|
||||
}
|
||||
catch (AggregateException ex)
|
||||
{
|
||||
Logger.LogException("Error getting studio {0}", ex, i);
|
||||
Logger.ErrorException("Error getting studio {0}", ex, i);
|
||||
return null;
|
||||
}
|
||||
})
|
||||
@@ -390,7 +390,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
// Even though this implementation means multiple iterations over the target list - it allows us to defer
|
||||
// the retrieval of the individual children for each index value until they are requested.
|
||||
using (new Profiler("Genre Index Build for " + Name))
|
||||
using (new Profiler("Genre Index Build for " + Name, Logger))
|
||||
{
|
||||
var indexName = LocalizedStrings.Instance.GetString("GenreDispPref");
|
||||
|
||||
@@ -407,12 +407,12 @@ namespace MediaBrowser.Controller.Entities
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Logger.LogException("Error getting genre {0}", ex, i);
|
||||
Logger.ErrorException("Error getting genre {0}", ex, i);
|
||||
return null;
|
||||
}
|
||||
catch (AggregateException ex)
|
||||
{
|
||||
Logger.LogException("Error getting genre {0}", ex, i);
|
||||
Logger.ErrorException("Error getting genre {0}", ex, i);
|
||||
return null;
|
||||
}
|
||||
})
|
||||
@@ -431,7 +431,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
// Even though this implementation means multiple iterations over the target list - it allows us to defer
|
||||
// the retrieval of the individual children for each index value until they are requested.
|
||||
using (new Profiler("Production Year Index Build for " + Name))
|
||||
using (new Profiler("Production Year Index Build for " + Name, Logger))
|
||||
{
|
||||
var indexName = LocalizedStrings.Instance.GetString("YearDispPref");
|
||||
|
||||
@@ -448,12 +448,12 @@ namespace MediaBrowser.Controller.Entities
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Logger.LogException("Error getting year {0}", ex, i);
|
||||
Logger.ErrorException("Error getting year {0}", ex, i);
|
||||
return null;
|
||||
}
|
||||
catch (AggregateException ex)
|
||||
{
|
||||
Logger.LogException("Error getting year {0}", ex, i);
|
||||
Logger.ErrorException("Error getting year {0}", ex, i);
|
||||
return null;
|
||||
}
|
||||
})
|
||||
@@ -639,7 +639,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
}
|
||||
catch (OperationCanceledException ex)
|
||||
{
|
||||
Logger.LogInfo("ValidateChildren cancelled for " + Name);
|
||||
Logger.Info("ValidateChildren cancelled for " + Name);
|
||||
|
||||
// If the outer cancelletion token in the cause for the cancellation, throw it
|
||||
if (cancellationToken.IsCancellationRequested && ex.CancellationToken == cancellationToken)
|
||||
@@ -734,7 +734,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
|
||||
foreach (var item in changedArgs.ItemsRemoved)
|
||||
{
|
||||
Logger.LogInfo("** " + item.Name + " Removed from library.");
|
||||
Logger.Info("** " + item.Name + " Removed from library.");
|
||||
}
|
||||
|
||||
var childrenReplaced = false;
|
||||
@@ -749,7 +749,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
|
||||
foreach (var item in changedArgs.ItemsAdded)
|
||||
{
|
||||
Logger.LogInfo("** " + item.Name + " Added to library.");
|
||||
Logger.Info("** " + item.Name + " Added to library.");
|
||||
|
||||
if (!childrenReplaced)
|
||||
{
|
||||
@@ -762,7 +762,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
await Task.WhenAll(saveTasks).ConfigureAwait(false);
|
||||
|
||||
//and save children in repo...
|
||||
Logger.LogInfo("*** Saving " + newChildren.Count + " children for " + Name);
|
||||
Logger.Info("*** Saving " + newChildren.Count + " children for " + Name);
|
||||
await Kernel.Instance.ItemRepository.SaveChildren(Id, newChildren, CancellationToken.None).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
@@ -860,7 +860,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Logger.LogException("Error getting ResolveArgs for {0}", ex, Path);
|
||||
Logger.ErrorException("Error getting ResolveArgs for {0}", ex, Path);
|
||||
return new List<BaseItem> { };
|
||||
}
|
||||
|
||||
@@ -1028,7 +1028,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Logger.LogException("Error getting ResolveArgs for {0}", ex, Path);
|
||||
Logger.ErrorException("Error getting ResolveArgs for {0}", ex, Path);
|
||||
}
|
||||
|
||||
//this should be functionally equivilent to what was here since it is IEnum and works on a thread-safe copy
|
||||
@@ -1040,7 +1040,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Logger.LogException("Error getting ResolveArgs for {0}", ex, Path);
|
||||
Logger.ErrorException("Error getting ResolveArgs for {0}", ex, Path);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -161,7 +161,7 @@ namespace MediaBrowser.Controller.Entities.Movies
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Logger.LogException("Error getting ResolveArgs for {0}", ex, Path);
|
||||
Logger.ErrorException("Error getting ResolveArgs for {0}", ex, Path);
|
||||
return new List<Video> { };
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ namespace MediaBrowser.Controller.Entities.Movies
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Logger.LogException("Error loading trailers for {0}", ex, Name);
|
||||
Logger.ErrorException("Error loading trailers for {0}", ex, Name);
|
||||
return new List<Video> { };
|
||||
}
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
get
|
||||
{
|
||||
// Lazy load
|
||||
LazyInitializer.EnsureInitialized(ref _configuration, ref _configurationInitialized, ref _configurationSyncLock, () => XmlSerializer.GetXmlConfiguration<UserConfiguration>(ConfigurationFilePath));
|
||||
LazyInitializer.EnsureInitialized(ref _configuration, ref _configurationInitialized, ref _configurationSyncLock, () => XmlSerializer.GetXmlConfiguration<UserConfiguration>(ConfigurationFilePath, Logger));
|
||||
return _configuration;
|
||||
}
|
||||
private set
|
||||
@@ -208,7 +208,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
/// <returns>Task.</returns>
|
||||
public async Task ValidateMediaLibrary(IProgress<TaskProgress> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
Logger.LogInfo("Validating media library for {0}", Name);
|
||||
Logger.Info("Validating media library for {0}", Name);
|
||||
await RootFolder.RefreshMetadata(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
@@ -224,7 +224,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
/// <returns>Task.</returns>
|
||||
public async Task ValidateCollectionFolders(IProgress<TaskProgress> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
Logger.LogInfo("Validating collection folders for {0}", Name);
|
||||
Logger.Info("Validating collection folders for {0}", Name);
|
||||
await RootFolder.RefreshMetadata(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
@@ -70,9 +70,14 @@ namespace MediaBrowser.Controller.IO
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DirectoryWatchers" /> class.
|
||||
/// </summary>
|
||||
public DirectoryWatchers()
|
||||
public DirectoryWatchers(ILogger logger)
|
||||
{
|
||||
Logger = LogManager.GetLogger(GetType().Name);
|
||||
if (logger == null)
|
||||
{
|
||||
throw new ArgumentNullException("logger");
|
||||
}
|
||||
|
||||
Logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using MediaBrowser.Common.Logging;
|
||||
using MediaBrowser.Common.Win32;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -14,6 +15,11 @@ namespace MediaBrowser.Controller.IO
|
||||
/// </summary>
|
||||
public static class FileData
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
private static readonly ILogger Logger = LogManager.GetLogger("FileData");
|
||||
|
||||
/// <summary>
|
||||
/// Gets all file system entries within a foler
|
||||
/// </summary>
|
||||
@@ -87,7 +93,7 @@ namespace MediaBrowser.Controller.IO
|
||||
if (string.IsNullOrWhiteSpace(newPath))
|
||||
{
|
||||
//invalid shortcut - could be old or target could just be unavailable
|
||||
Logger.LogWarning("Encountered invalid shortuct: "+lpFindFileData.Path);
|
||||
Logger.Warn("Encountered invalid shortuct: "+lpFindFileData.Path);
|
||||
continue;
|
||||
}
|
||||
var data = FileSystem.GetFileData(newPath);
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace MediaBrowser.Controller.IO
|
||||
public FileSystemManager(Kernel kernel)
|
||||
: base(kernel)
|
||||
{
|
||||
DirectoryWatchers = new DirectoryWatchers();
|
||||
DirectoryWatchers = new DirectoryWatchers(Logger);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using MediaBrowser.Common.Logging;
|
||||
using MediaBrowser.Model.Logging;
|
||||
|
||||
namespace MediaBrowser.Controller.Library
|
||||
{
|
||||
@@ -18,14 +19,22 @@ namespace MediaBrowser.Controller.Library
|
||||
/// </summary>
|
||||
readonly Stopwatch stopwatch;
|
||||
|
||||
/// <summary>
|
||||
/// The _logger
|
||||
/// </summary>
|
||||
private ILogger _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Profiler" /> class.
|
||||
/// </summary>
|
||||
/// <param name="name">The name.</param>
|
||||
public Profiler(string name)
|
||||
/// <param name="logger">The logger.</param>
|
||||
public Profiler(string name, ILogger logger)
|
||||
{
|
||||
this.name = name;
|
||||
|
||||
_logger = logger;
|
||||
|
||||
stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
}
|
||||
@@ -60,7 +69,7 @@ namespace MediaBrowser.Controller.Library
|
||||
message = string.Format("{0} took {1} seconds.",
|
||||
name, ((float)stopwatch.ElapsedMilliseconds / 1000).ToString("#0.000"));
|
||||
}
|
||||
Logger.LogInfo(message);
|
||||
_logger.Info(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using MediaBrowser.Common.Localization;
|
||||
using MediaBrowser.Common.Logging;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Globalization;
|
||||
@@ -15,6 +16,10 @@ namespace MediaBrowser.Controller.Localization
|
||||
/// </summary>
|
||||
public class LocalizedStrings
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
private static readonly ILogger Logger = LogManager.GetLogger("LocalizedStrings");
|
||||
/// <summary>
|
||||
/// The base prefix
|
||||
/// </summary>
|
||||
@@ -80,7 +85,7 @@ namespace MediaBrowser.Controller.Localization
|
||||
var xs = new XmlSerializer(t);
|
||||
var strings = (LocalizedStringData)Activator.CreateInstance(t);
|
||||
strings.FileName = file;
|
||||
Logger.LogInfo("Using String Data from {0}", file);
|
||||
Logger.Info("Using String Data from {0}", file);
|
||||
if (File.Exists(file))
|
||||
{
|
||||
using (var fs = new FileStream(file, FileMode.Open, FileAccess.Read))
|
||||
@@ -121,17 +126,17 @@ namespace MediaBrowser.Controller.Localization
|
||||
}
|
||||
catch (TargetException ex)
|
||||
{
|
||||
Logger.LogException("Error getting value for field: {0}", ex, field.Name);
|
||||
Logger.ErrorException("Error getting value for field: {0}", ex, field.Name);
|
||||
continue;
|
||||
}
|
||||
catch (FieldAccessException ex)
|
||||
{
|
||||
Logger.LogException("Error getting value for field: {0}", ex, field.Name);
|
||||
Logger.ErrorException("Error getting value for field: {0}", ex, field.Name);
|
||||
continue;
|
||||
}
|
||||
catch (NotSupportedException ex)
|
||||
{
|
||||
Logger.LogException("Error getting value for field: {0}", ex, field.Name);
|
||||
Logger.ErrorException("Error getting value for field: {0}", ex, field.Name);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Model.Drawing;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Threading.Tasks;
|
||||
@@ -13,6 +14,10 @@ namespace MediaBrowser.Controller.Providers
|
||||
/// </summary>
|
||||
public abstract class BaseImageEnhancer : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
private static readonly ILogger Logger = LogManager.GetLogger("ImageEnhancer");
|
||||
/// <summary>
|
||||
/// Return true only if the given image for the given item will be enhanced by this enhancer.
|
||||
/// </summary>
|
||||
@@ -96,7 +101,7 @@ namespace MediaBrowser.Controller.Providers
|
||||
|
||||
var typeName = GetType().Name;
|
||||
|
||||
Logger.LogDebugInfo("Running {0} for {1}", typeName, item.Path ?? item.Name ?? "--Unknown--");
|
||||
Logger.Debug("Running {0} for {1}", typeName, item.Path ?? item.Name ?? "--Unknown--");
|
||||
|
||||
try
|
||||
{
|
||||
@@ -104,7 +109,7 @@ namespace MediaBrowser.Controller.Providers
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogException("{0} failed enhancing {1}", ex, typeName, item.Name);
|
||||
Logger.ErrorException("{0} failed enhancing {1}", ex, typeName, item.Name);
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -16,6 +17,20 @@ namespace MediaBrowser.Controller.Providers
|
||||
public class BaseItemXmlParser<T>
|
||||
where T : BaseItem, new()
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
protected ILogger Logger { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BaseItemXmlParser{T}" /> class.
|
||||
/// </summary>
|
||||
/// <param name="logger">The logger.</param>
|
||||
public BaseItemXmlParser(ILogger logger)
|
||||
{
|
||||
Logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetches metadata for an item from one xml file
|
||||
/// </summary>
|
||||
|
||||
@@ -66,13 +66,13 @@ namespace MediaBrowser.Controller.Providers
|
||||
private bool Fetch(BaseItem item, CancellationToken cancellationToken)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
|
||||
var metadataFile = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, "folder.xml"));
|
||||
|
||||
if (metadataFile.HasValue)
|
||||
{
|
||||
var path = metadataFile.Value.Path;
|
||||
new BaseItemXmlParser<Folder>().Fetch((Folder)item, path, cancellationToken);
|
||||
new BaseItemXmlParser<Folder>(Logger).Fetch((Folder)item, path, cancellationToken);
|
||||
SetLastRefreshed(item, DateTime.UtcNow);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -75,11 +75,11 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
var boxset = item as BoxSet;
|
||||
if (boxset != null)
|
||||
{
|
||||
new BaseItemXmlParser<BoxSet>().Fetch(boxset, path, cancellationToken);
|
||||
new BaseItemXmlParser<BoxSet>(Logger).Fetch(boxset, path, cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
new BaseItemXmlParser<Movie>().Fetch((Movie)item, path, cancellationToken);
|
||||
new BaseItemXmlParser<Movie>(Logger).Fetch((Movie)item, path, cancellationToken);
|
||||
}
|
||||
SetLastRefreshed(item, DateTime.UtcNow);
|
||||
return true;
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
return false;
|
||||
}
|
||||
|
||||
new EpisodeXmlParser().Fetch(item, metadataFile, cancellationToken);
|
||||
new EpisodeXmlParser(Logger).Fetch(item, metadataFile, cancellationToken);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
|
||||
@@ -9,6 +10,15 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
/// </summary>
|
||||
public class EpisodeXmlParser : BaseItemXmlParser<Episode>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="EpisodeXmlParser" /> class.
|
||||
/// </summary>
|
||||
/// <param name="logger">The logger.</param>
|
||||
public EpisodeXmlParser(ILogger logger)
|
||||
: base(logger)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetches the data from XML node.
|
||||
/// </summary>
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
{
|
||||
var path = metadataFile.Value.Path;
|
||||
|
||||
new SeriesXmlParser().Fetch((Series)item, path, cancellationToken);
|
||||
new SeriesXmlParser(Logger).Fetch((Series)item, path, cancellationToken);
|
||||
SetLastRefreshed(item, DateTime.UtcNow);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using MediaBrowser.Common.Logging;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Resolvers.TV;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.Xml;
|
||||
|
||||
@@ -12,6 +12,15 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
/// </summary>
|
||||
public class SeriesXmlParser : BaseItemXmlParser<Series>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BaseItemXmlParser{T}" /> class.
|
||||
/// </summary>
|
||||
/// <param name="logger">The logger.</param>
|
||||
public SeriesXmlParser(ILogger logger)
|
||||
: base(logger)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetches the data from XML node.
|
||||
/// </summary>
|
||||
@@ -74,7 +83,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogInfo("Unrecognized series status: " + status);
|
||||
Logger.Info("Unrecognized series status: " + status);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,9 +7,18 @@ using System.Linq;
|
||||
|
||||
namespace MediaBrowser.Controller.Resolvers.TV
|
||||
{
|
||||
/// <summary>
|
||||
/// Class TVUtils
|
||||
/// </summary>
|
||||
public static class TVUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// The TVDB API key
|
||||
/// </summary>
|
||||
public static readonly string TVDBApiKey = "B89CE93890E9419B";
|
||||
/// <summary>
|
||||
/// The banner URL
|
||||
/// </summary>
|
||||
public static readonly string BannerUrl = "http://www.thetvdb.com/banners/";
|
||||
|
||||
/// <summary>
|
||||
@@ -29,11 +38,6 @@ namespace MediaBrowser.Controller.Resolvers.TV
|
||||
/// match movie titles like "2001 A Space..."
|
||||
/// Currently we limit the numbers here to 2 digits to try and avoid this
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The order here is important, if the order is changed some of the later
|
||||
/// ones might incorrectly match things that higher ones would have caught.
|
||||
/// The most restrictive expressions should appear first
|
||||
/// </remarks>
|
||||
private static readonly Regex[] EpisodeExpressions = new[]
|
||||
{
|
||||
new Regex(
|
||||
@@ -78,6 +82,11 @@ namespace MediaBrowser.Controller.Resolvers.TV
|
||||
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Gets the season number from path.
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns>System.Nullable{System.Int32}.</returns>
|
||||
public static int? GetSeasonNumberFromPath(string path)
|
||||
{
|
||||
// Look for one of the season folder names
|
||||
@@ -97,6 +106,8 @@ namespace MediaBrowser.Controller.Resolvers.TV
|
||||
/// <summary>
|
||||
/// Extracts the season number from the second half of the Season folder name (everything after "Season", or "Staffel")
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns>System.Nullable{System.Int32}.</returns>
|
||||
private static int? GetSeasonNumberFromPathSubstring(string path)
|
||||
{
|
||||
int numericStart = -1;
|
||||
@@ -127,11 +138,22 @@ namespace MediaBrowser.Controller.Resolvers.TV
|
||||
return int.Parse(path.Substring(numericStart, length));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether [is season folder] [the specified path].
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns><c>true</c> if [is season folder] [the specified path]; otherwise, <c>false</c>.</returns>
|
||||
public static bool IsSeasonFolder(string path)
|
||||
{
|
||||
return GetSeasonNumberFromPath(path) != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether [is series folder] [the specified path].
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <param name="fileSystemChildren">The file system children.</param>
|
||||
/// <returns><c>true</c> if [is series folder] [the specified path]; otherwise, <c>false</c>.</returns>
|
||||
public static bool IsSeriesFolder(string path, IEnumerable<WIN32_FIND_DATA> fileSystemChildren)
|
||||
{
|
||||
// A folder with more than 3 non-season folders in will not becounted as a series
|
||||
@@ -171,6 +193,12 @@ namespace MediaBrowser.Controller.Resolvers.TV
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Episodes the number from file.
|
||||
/// </summary>
|
||||
/// <param name="fullPath">The full path.</param>
|
||||
/// <param name="isInSeason">if set to <c>true</c> [is in season].</param>
|
||||
/// <returns>System.String.</returns>
|
||||
public static string EpisodeNumberFromFile(string fullPath, bool isInSeason)
|
||||
{
|
||||
string fl = fullPath.ToLower();
|
||||
@@ -194,6 +222,11 @@ namespace MediaBrowser.Controller.Resolvers.TV
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Seasons the number from episode file.
|
||||
/// </summary>
|
||||
/// <param name="fullPath">The full path.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
public static string SeasonNumberFromEpisodeFile(string fullPath)
|
||||
{
|
||||
string fl = fullPath.ToLower();
|
||||
@@ -211,6 +244,11 @@ namespace MediaBrowser.Controller.Resolvers.TV
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the air days.
|
||||
/// </summary>
|
||||
/// <param name="day">The day.</param>
|
||||
/// <returns>List{DayOfWeek}.</returns>
|
||||
public static List<DayOfWeek> GetAirDays(string day)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(day))
|
||||
@@ -239,8 +277,6 @@ namespace MediaBrowser.Controller.Resolvers.TV
|
||||
};
|
||||
}
|
||||
|
||||
Logger.LogWarning("Invalid value passed into GetAirDays: {0}", day);
|
||||
|
||||
return new List<DayOfWeek>
|
||||
{
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user