From 22377f2516b78d9eb6a2e5bf4e99958590bd5788 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 4 Mar 2016 12:07:14 -0500 Subject: [PATCH] auto-organize fixes --- .../TV/TvdbSeasonIdentityProvider.cs | 5 +++ .../TV/TvdbSeriesProvider.cs | 34 +++++++++---------- .../FileOrganization/TvFolderOrganizer.cs | 8 ++--- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/MediaBrowser.Providers/TV/TvdbSeasonIdentityProvider.cs b/MediaBrowser.Providers/TV/TvdbSeasonIdentityProvider.cs index edeea36e4..4198430c9 100644 --- a/MediaBrowser.Providers/TV/TvdbSeasonIdentityProvider.cs +++ b/MediaBrowser.Providers/TV/TvdbSeasonIdentityProvider.cs @@ -27,6 +27,11 @@ namespace MediaBrowser.Providers.TV public static TvdbSeasonIdentity? ParseIdentity(string id) { + if (id == null) + { + return null; + } + try { var parts = id.Split(':'); diff --git a/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs b/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs index 4a7ae57fb..593507fb2 100644 --- a/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs +++ b/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs @@ -160,19 +160,19 @@ namespace MediaBrowser.Providers.TV var series = result.Item; string id; - if (seriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out id)) + if (seriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out id) && !string.IsNullOrEmpty(id)) { series.SetProviderId(MetadataProviders.Tvdb, id); } - if (seriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out id)) + if (seriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out id) && !string.IsNullOrEmpty(id)) { series.SetProviderId(MetadataProviders.Imdb, id); } var seriesDataPath = GetSeriesDataPath(_config.ApplicationPaths, seriesProviderIds); - var seriesXmlPath = GetSeriesXmlPath (seriesProviderIds, metadataLanguage); + var seriesXmlPath = GetSeriesXmlPath(seriesProviderIds, metadataLanguage); var actorsXmlPath = Path.Combine(seriesDataPath, "actors.xml"); FetchSeriesInfo(series, seriesXmlPath, cancellationToken); @@ -320,7 +320,7 @@ namespace MediaBrowser.Providers.TV internal static bool IsValidSeries(Dictionary seriesProviderIds) { string id; - if (seriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out id)) + if (seriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out id) && !string.IsNullOrEmpty(id)) { // This check should ideally never be necessary but we're seeing some cases of this and haven't tracked them down yet. if (!string.IsNullOrWhiteSpace(id)) @@ -329,7 +329,7 @@ namespace MediaBrowser.Providers.TV } } - if (seriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out id)) + if (seriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out id) && !string.IsNullOrEmpty(id)) { // This check should ideally never be necessary but we're seeing some cases of this and haven't tracked them down yet. if (!string.IsNullOrWhiteSpace(id)) @@ -340,7 +340,7 @@ namespace MediaBrowser.Providers.TV return false; } - private SemaphoreSlim _ensureSemaphore = new SemaphoreSlim(1,1); + private SemaphoreSlim _ensureSemaphore = new SemaphoreSlim(1, 1); internal async Task EnsureSeriesInfo(Dictionary seriesProviderIds, string preferredMetadataLanguage, CancellationToken cancellationToken) { await _ensureSemaphore.WaitAsync(cancellationToken).ConfigureAwait(false); @@ -348,7 +348,7 @@ namespace MediaBrowser.Providers.TV try { string seriesId; - if (seriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out seriesId)) + if (seriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out seriesId) && !string.IsNullOrEmpty(seriesId)) { var seriesDataPath = GetSeriesDataPath(_config.ApplicationPaths, seriesProviderIds); @@ -362,7 +362,7 @@ namespace MediaBrowser.Providers.TV return seriesDataPath; } - if (seriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out seriesId)) + if (seriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out seriesId) && !string.IsNullOrEmpty(seriesId)) { var seriesDataPath = GetSeriesDataPath(_config.ApplicationPaths, seriesProviderIds); @@ -1300,14 +1300,14 @@ namespace MediaBrowser.Providers.TV internal static string GetSeriesDataPath(IApplicationPaths appPaths, Dictionary seriesProviderIds) { string seriesId; - if (seriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out seriesId)) + if (seriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out seriesId) && !string.IsNullOrEmpty(seriesId)) { var seriesDataPath = Path.Combine(GetSeriesDataPath(appPaths), seriesId); return seriesDataPath; } - if (seriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out seriesId)) + if (seriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out seriesId) && !string.IsNullOrEmpty(seriesId)) { var seriesDataPath = Path.Combine(GetSeriesDataPath(appPaths), seriesId); @@ -1317,14 +1317,14 @@ namespace MediaBrowser.Providers.TV return null; } - public string GetSeriesXmlPath(Dictionary seriesProviderIds, string language) - { - var seriesDataPath = GetSeriesDataPath(_config.ApplicationPaths, seriesProviderIds); + public string GetSeriesXmlPath(Dictionary seriesProviderIds, string language) + { + var seriesDataPath = GetSeriesDataPath(_config.ApplicationPaths, seriesProviderIds); - var seriesXmlFilename = language.ToLower() + ".xml"; + var seriesXmlFilename = language.ToLower() + ".xml"; - return Path.Combine (seriesDataPath, seriesXmlFilename); - } + return Path.Combine(seriesDataPath, seriesXmlFilename); + } /// /// Gets the series data path. @@ -1466,4 +1466,4 @@ namespace MediaBrowser.Providers.TV }; } } -} +} \ No newline at end of file diff --git a/MediaBrowser.Server.Implementations/FileOrganization/TvFolderOrganizer.cs b/MediaBrowser.Server.Implementations/FileOrganization/TvFolderOrganizer.cs index 845fcdff2..43bd2f29c 100644 --- a/MediaBrowser.Server.Implementations/FileOrganization/TvFolderOrganizer.cs +++ b/MediaBrowser.Server.Implementations/FileOrganization/TvFolderOrganizer.cs @@ -84,7 +84,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization } catch (Exception ex) { - _logger.ErrorException("Error organizing episode {0}", ex, file); + _logger.ErrorException("Error organizing episode {0}", ex, file.FullName); } numComplete++; @@ -132,7 +132,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization { try { - return _fileSystem.GetFiles(path, true) + return _fileSystem.GetFiles(path, true) .ToList(); } catch (IOException ex) @@ -150,7 +150,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization /// The extensions. private void DeleteLeftOverFiles(string path, IEnumerable extensions) { - var eligibleFiles = _fileSystem.GetFiles(path, true) + var eligibleFiles = _fileSystem.GetFiles(path, true) .Where(i => extensions.Contains(i.Extension, StringComparer.OrdinalIgnoreCase)) .ToList(); @@ -206,4 +206,4 @@ namespace MediaBrowser.Server.Implementations.FileOrganization return watchLocations.Contains(path, StringComparer.OrdinalIgnoreCase); } } -} +} \ No newline at end of file