From 7bdc10c3703f13f7e1c2a3809cf33778098287bd Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Tue, 4 Dec 2012 17:41:19 -0800 Subject: [PATCH 1/2] Xbmc episode metadata Fixed: An issue with episode nfo not downloading when episode did not have a thumbnail (XBMC Metadata) --- .../Metadata/Xbmc_ForEpisodeFile_Fixture.cs | 15 +++++++ .../Metadata/Xbmc_ForSeries_Fixture.cs | 29 +++++++++++++ NzbDrone.Core/Providers/Metadata/Xbmc.cs | 43 +++++++++++++------ 3 files changed, 74 insertions(+), 13 deletions(-) diff --git a/NzbDrone.Core.Test/ProviderTests/Metadata/Xbmc_ForEpisodeFile_Fixture.cs b/NzbDrone.Core.Test/ProviderTests/Metadata/Xbmc_ForEpisodeFile_Fixture.cs index 48b8ed3fc..d579b4406 100644 --- a/NzbDrone.Core.Test/ProviderTests/Metadata/Xbmc_ForEpisodeFile_Fixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/Metadata/Xbmc_ForEpisodeFile_Fixture.cs @@ -131,6 +131,11 @@ namespace NzbDrone.Core.Test.ProviderTests.Metadata tvdbSeries.Episodes.ForEach(e => e.Writer = new List()); } + private void WithoutThumbnails() + { + tvdbSeries.Episodes.ForEach(e => e.BannerPath = String.Empty); + } + [Test] public void should_not_blowup() { @@ -177,5 +182,15 @@ namespace NzbDrone.Core.Test.ProviderTests.Metadata WithNoWriters(); Mocker.Resolve().CreateForEpisodeFile(episodeFile, tvdbSeries); } + + [Test] + public void should_download_nfo_even_if_thumbnail_is_missing() + { + WithSingleEpisodeFile(); + WithoutThumbnails(); + Mocker.Resolve().CreateForEpisodeFile(episodeFile, tvdbSeries); + + Mocker.GetMock().Verify(v => v.WriteAllText(It.IsAny(), It.IsAny()), Times.Once()); + } } } \ No newline at end of file diff --git a/NzbDrone.Core.Test/ProviderTests/Metadata/Xbmc_ForSeries_Fixture.cs b/NzbDrone.Core.Test/ProviderTests/Metadata/Xbmc_ForSeries_Fixture.cs index 1a55c0eb7..ce2731037 100644 --- a/NzbDrone.Core.Test/ProviderTests/Metadata/Xbmc_ForSeries_Fixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/Metadata/Xbmc_ForSeries_Fixture.cs @@ -165,5 +165,34 @@ namespace NzbDrone.Core.Test.ProviderTests.Metadata Mocker.Resolve().CreateForSeries(series, tvdbSeries); Mocker.GetMock().Verify(v => v.Download(It.Is(s => s.Contains("banners")), It.IsRegex(@"season-specials.tbn")), Times.Exactly(1)); } + + [Test] + public void should_not_try_to_download_fanart_if_fanart_path_is_empty() + { + WithUseBanners(); + tvdbSeries.FanartPath = String.Empty; + + Mocker.Resolve().CreateForSeries(series, tvdbSeries); + Mocker.GetMock().Verify(v => v.Download(It.IsAny(), Path.Combine(series.Path, "fanart.jpg")), Times.Never()); + } + + [Test] + public void should_not_try_to_download_banner_if_banner_path_is_empty() + { + WithUseBanners(); + tvdbSeries.BannerPath = String.Empty; + + Mocker.Resolve().CreateForSeries(series, tvdbSeries); + Mocker.GetMock().Verify(v => v.Download(It.IsAny(), Path.Combine(series.Path, "folder.jpg")), Times.Never()); + } + + [Test] + public void should_not_try_to_download_poster_if_poster_path_is_empty() + { + tvdbSeries.PosterPath = String.Empty; + + Mocker.Resolve().CreateForSeries(series, tvdbSeries); + Mocker.GetMock().Verify(v => v.Download(It.IsAny(), Path.Combine(series.Path, "folder.jpg")), Times.Never()); + } } } \ No newline at end of file diff --git a/NzbDrone.Core/Providers/Metadata/Xbmc.cs b/NzbDrone.Core/Providers/Metadata/Xbmc.cs index 8182cc235..a7563b8ce 100644 --- a/NzbDrone.Core/Providers/Metadata/Xbmc.cs +++ b/NzbDrone.Core/Providers/Metadata/Xbmc.cs @@ -68,18 +68,28 @@ namespace NzbDrone.Core.Providers.Metadata _diskProvider.WriteAllText(Path.Combine(series.Path, "tvshow.nfo"), doc.ToString()); } - if (!_diskProvider.FileExists(Path.Combine(series.Path, "fanart.jpg"))) + if(String.IsNullOrWhiteSpace(tvDbSeries.FanartPath)) { - _logger.Debug("Downloading fanart for: {0}", series.Title); - _bannerProvider.Download(tvDbSeries.FanartPath, Path.Combine(series.Path, "fanart.jpg")); + _logger.Debug("Fanart does not exist for series: {0}, skipping.", series.Title); + } + else + { + if (!_diskProvider.FileExists(Path.Combine(series.Path, "fanart.jpg"))) + { + _logger.Debug("Downloading fanart for: {0}", series.Title); + _bannerProvider.Download(tvDbSeries.FanartPath, Path.Combine(series.Path, "fanart.jpg")); + } } if (!_diskProvider.FileExists(Path.Combine(series.Path, "folder.jpg"))) { if(_configProvider.MetadataUseBanners) { - _logger.Debug("Downloading series banner for: {0}", series.Title); - _bannerProvider.Download(tvDbSeries.BannerPath, Path.Combine(series.Path, "folder.jpg")); + if(!String.IsNullOrWhiteSpace(tvDbSeries.BannerPath)) + { + _logger.Debug("Downloading series banner for: {0}", series.Title); + _bannerProvider.Download(tvDbSeries.BannerPath, Path.Combine(series.Path, "folder.jpg")); + } _logger.Debug("Downloading Season banners for {0}", series.Title); DownloadSeasonThumbnails(series, tvDbSeries, TvdbSeasonBanner.Type.seasonwide); @@ -87,8 +97,11 @@ namespace NzbDrone.Core.Providers.Metadata else { - _logger.Debug("Downloading series thumbnail for: {0}", series.Title); - _bannerProvider.Download(tvDbSeries.PosterPath, Path.Combine(series.Path, "folder.jpg")); + if(!String.IsNullOrWhiteSpace(tvDbSeries.PosterPath)) + { + _logger.Debug("Downloading series thumbnail for: {0}", series.Title); + _bannerProvider.Download(tvDbSeries.PosterPath, Path.Combine(series.Path, "folder.jpg")); + } _logger.Debug("Downloading Season posters for {0}", series.Title); DownloadSeasonThumbnails(series, tvDbSeries, TvdbSeasonBanner.Type.season); @@ -112,19 +125,23 @@ namespace NzbDrone.Core.Providers.Metadata e.SeasonNumber == episodeFile.SeasonNumber && e.EpisodeNumber == episodes.First().EpisodeNumber); - if (episodeFileThumbnail == null || String.IsNullOrWhiteSpace(episodeFileThumbnail.BannerPath)) + if(episodeFileThumbnail == null || String.IsNullOrWhiteSpace(episodeFileThumbnail.BannerPath)) { _logger.Debug("No thumbnail is available for this episode"); - return; } - if (!_diskProvider.FileExists(episodeFile.Path.Replace(Path.GetExtension(episodeFile.Path), ".tbn"))) + else { - _logger.Debug("Downloading episode thumbnail for: {0}", episodeFile.EpisodeFileId); - _bannerProvider.Download(episodeFileThumbnail.BannerPath, - episodeFile.Path.Replace(Path.GetExtension(episodeFile.Path), ".tbn")); + if (!_diskProvider.FileExists(episodeFile.Path.Replace(Path.GetExtension(episodeFile.Path), ".tbn"))) + { + _logger.Debug("Downloading episode thumbnail for: {0}", episodeFile.EpisodeFileId); + _bannerProvider.Download(episodeFileThumbnail.BannerPath, + episodeFile.Path.Replace(Path.GetExtension(episodeFile.Path), ".tbn")); + } } + + _logger.Debug("Generating filename.nfo for: {0}", episodeFile.EpisodeFileId); var xmlResult = String.Empty; From feaf63c758f81e03bb9ae10caed5fd93ba3aa8fe Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Wed, 5 Dec 2012 17:54:09 -0800 Subject: [PATCH 2/2] DateTime.ToString fixes for other countries Fixed: Aired Date sorting on Missing --- .../NzbDrone.Services.Service.csproj | 2 +- NzbDrone.Web/Controllers/HistoryController.cs | 3 ++- NzbDrone.Web/Controllers/MissingController.cs | 5 +++-- NzbDrone.Web/Controllers/SeriesController.cs | 2 +- NzbDrone.Web/Models/MissingEpisodeModel.cs | 2 +- NzbDrone.Web/Views/Missing/Index.cshtml | 4 ++-- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/NzbDrone.Services/NzbDrone.Services.Service/NzbDrone.Services.Service.csproj b/NzbDrone.Services/NzbDrone.Services.Service/NzbDrone.Services.Service.csproj index 5e178474b..15eb7f6ee 100644 --- a/NzbDrone.Services/NzbDrone.Services.Service/NzbDrone.Services.Service.csproj +++ b/NzbDrone.Services/NzbDrone.Services.Service/NzbDrone.Services.Service.csproj @@ -362,7 +362,7 @@ False True - 62182 + 32122 / http://localhost:62182/ False diff --git a/NzbDrone.Web/Controllers/HistoryController.cs b/NzbDrone.Web/Controllers/HistoryController.cs index 8d203502c..fc92aa598 100644 --- a/NzbDrone.Web/Controllers/HistoryController.cs +++ b/NzbDrone.Web/Controllers/HistoryController.cs @@ -1,4 +1,5 @@ using System; +using System.Globalization; using System.Linq; using System.Linq.Dynamic; using System.Web.Mvc; @@ -45,7 +46,7 @@ namespace NzbDrone.Web.Controllers Quality = h.Quality.ToString(), IsProper = h.IsProper, Date = h.Date.ToString(), - DateSorter = h.Date.ToString("MM/dd/yyyy h:mm:ss tt"), + DateSorter = h.Date.ToString("o", CultureInfo.InvariantCulture), Indexer = h.Indexer, EpisodeId = h.EpisodeId, NzbInfoUrl = h.NzbInfoUrl, diff --git a/NzbDrone.Web/Controllers/MissingController.cs b/NzbDrone.Web/Controllers/MissingController.cs index d1045c68d..c111dc82b 100644 --- a/NzbDrone.Web/Controllers/MissingController.cs +++ b/NzbDrone.Web/Controllers/MissingController.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Web; using System.Web.Mvc; @@ -34,8 +35,8 @@ namespace NzbDrone.Web.Controllers Overview = e.Overview, SeriesTitle = e.Series.Title, SeriesTitleSorter = SortHelper.SkipArticles(e.Series.Title), - AirDate = e.AirDate.Value.ToString("MM/dd/yyyy"), - AirDateString = e.AirDate.Value.ToBestDateString() + AirDateSorter = e.AirDate.Value.ToString("o", CultureInfo.InvariantCulture), + AirDate = e.AirDate.Value.ToBestDateString() }); JsConfig.IncludeNullValues = true; diff --git a/NzbDrone.Web/Controllers/SeriesController.cs b/NzbDrone.Web/Controllers/SeriesController.cs index 7ae695143..2a3a299b7 100644 --- a/NzbDrone.Web/Controllers/SeriesController.cs +++ b/NzbDrone.Web/Controllers/SeriesController.cs @@ -225,7 +225,7 @@ namespace NzbDrone.Web.Controllers EpisodeCount = s.EpisodeCount, EpisodeFileCount = s.EpisodeFileCount, NextAiring = s.NextAiring == null ? String.Empty : s.NextAiring.Value.ToBestDateString(), - NextAiringSorter = s.NextAiring == null ? "12/31/9999" : s.NextAiring.Value.ToString("MM/dd/yyyy"), + NextAiringSorter = s.NextAiring == null ? new DateTime(9999, 12, 31).ToString("o", CultureInfo.InvariantCulture) : s.NextAiring.Value.ToString("o", CultureInfo.InvariantCulture), AirTime = s.AirTimes, CustomStartDate = s.CustomStartDate.HasValue ? s.CustomStartDate.Value.ToString("yyyy-MM-dd") : String.Empty }).ToList(); diff --git a/NzbDrone.Web/Models/MissingEpisodeModel.cs b/NzbDrone.Web/Models/MissingEpisodeModel.cs index 7c54ecaaf..7db97a09c 100644 --- a/NzbDrone.Web/Models/MissingEpisodeModel.cs +++ b/NzbDrone.Web/Models/MissingEpisodeModel.cs @@ -12,8 +12,8 @@ namespace NzbDrone.Web.Models public string SeriesTitleSorter { get; set; } public string EpisodeNumbering { get; set; } public string EpisodeTitle { get; set; } + public string AirDateSorter { get; set; } public string AirDate { get; set; } - public string AirDateString { get; set; } public string Overview { get; set; } public string Details { get; set; } } diff --git a/NzbDrone.Web/Views/Missing/Index.cshtml b/NzbDrone.Web/Views/Missing/Index.cshtml index 363e57f61..b1a087666 100644 --- a/NzbDrone.Web/Views/Missing/Index.cshtml +++ b/NzbDrone.Web/Views/Missing/Index.cshtml @@ -49,10 +49,10 @@ function airDate (source, type, val) { // 'display' and 'filter' use our fancy naming if (type === 'display' || type === 'filter') { - return source["AirDateString"]; + return source["AirDate"]; } // 'sort' and 'type' both just use the raw data - return source["AirDate"]; + return source["AirDateSorter"]; } function actions(row) {