From 80759f923e1118ccc9a2b162b473c2718080cf55 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Mon, 20 May 2013 15:45:16 -0700 Subject: [PATCH] diskscan is triggered when new episodes are added. --- NzbDrone.Core.Test/NzbDrone.Core.Test.csproj | 2 +- ...roviderTest.cs => SeriesServiceFixture.cs} | Bin 3393 -> 2375 bytes .../MediaFiles/Commands/DiskScanCommand.cs | 4 ---- NzbDrone.Core/MediaFiles/DiskScanService.cs | 8 +++++++- NzbDrone.Core/Tv/EpisodeService.cs | 2 +- .../Tv/Events/EpisodeInfoAddedEvent.cs | 4 +++- NzbDrone.Core/Tv/SeriesService.cs | 12 +++++++----- UI/Series/Delete/DeleteSeriesView.js | 3 ++- UI/Series/SeriesCollection.js | 2 +- 9 files changed, 22 insertions(+), 15 deletions(-) rename NzbDrone.Core.Test/TvTests/{SeriesProviderTest.cs => SeriesServiceFixture.cs} (51%) diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index 716666123..78d9e4994 100644 --- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -204,7 +204,7 @@ - + diff --git a/NzbDrone.Core.Test/TvTests/SeriesProviderTest.cs b/NzbDrone.Core.Test/TvTests/SeriesServiceFixture.cs similarity index 51% rename from NzbDrone.Core.Test/TvTests/SeriesProviderTest.cs rename to NzbDrone.Core.Test/TvTests/SeriesServiceFixture.cs index 8cf08a429e3cb538f7bdf8035c52f7ce51dd587d..71334d1fb35459cd46b3645dba28b4cd11d24524 100644 GIT binary patch delta 377 zcmX>obzEq|GVY-K{1UhPoRrj};)(r^6Z1qkL(24A%Tn`7iYK0p;0sPID$7hxb<3{A^lA2&$#_vXn2ytdW;mu7EH?p;{pTXtIK>f>N?oOiU5b8%hebn%2Bryj%)Mpe(US0pd`g z(%{mhtkmQZJ;#(3pc67vCv$Vk2|{G`5JpeVXHgNy5Y-Dy%qdL;%1M}_+7JdbDXkJ5 kWC5i~Ihn;7sVO#K@+6lvdV3q#j%_P03B(7RR910 literal 3393 zcmeHJ&2HL25bha?cUa|QBIGD(Picab5K$o&)CQs+LWPVyB-=QFHafARL}&JWW8A zCus)4oM{cpa4Gcb!9bSg!z;l}*i+FxJW6%W7Jq1g}^PA{Sum>*|M(D9PKbhGi?Y%sj8>1U7sG?{|$?$IKfr95VF8fnc&pg8C+ zN-jB;PhfV;C~dkuai{pX7`-BvS#8Q*HacrH&XyXP7pMw7ZDR zEoQaXJ)TU6n8{?Xmc0iz+@wHw%jcMWy^ZI>Ftfav^%F!N9=-qYrdL8eWKqh^3WYM~ zDOmgwf~(|G@j0+ZaW z;pkRoX@W8tN^=fFEZma{W$zn&L2gT{a|np+x;TB4v8Bv2ax88)`Bb5JLEyDO_H z&)&AMYLpL!qsxv&H_{Lol|idA9OcP8O0{>CFDg6s{@hHp?ea9!Fh%9#dY#Ut!l8<^ z6nIOkTn95LQ-+X{ecZE8D?)nqRY7~Ax-s0^MuFJfSDn;CfsFa`y{d%@FL75Xp@Vu3 zYl`%ycQ@=lG1TsVb=WJ)!Zlap8EG!0^0I$W-9p>m5L{31CH}9#cQCGz(nU?K>)R9G zb;04$o2#-AV)>4vNiBU-n&nwIDB@#HG_PyeVuSYeE0jX}3xNi`+5#62*TT!Y-L>n$ Kt^@x^2mS&yB))?H diff --git a/NzbDrone.Core/MediaFiles/Commands/DiskScanCommand.cs b/NzbDrone.Core/MediaFiles/Commands/DiskScanCommand.cs index 6d5b144fd..db7dd7a04 100644 --- a/NzbDrone.Core/MediaFiles/Commands/DiskScanCommand.cs +++ b/NzbDrone.Core/MediaFiles/Commands/DiskScanCommand.cs @@ -13,9 +13,5 @@ namespace NzbDrone.Core.MediaFiles.Commands SeriesId = seriesId; } } - - public DiskScanCommand() - { - } } } \ No newline at end of file diff --git a/NzbDrone.Core/MediaFiles/DiskScanService.cs b/NzbDrone.Core/MediaFiles/DiskScanService.cs index 2ea1f5c4c..d8d07e967 100644 --- a/NzbDrone.Core/MediaFiles/DiskScanService.cs +++ b/NzbDrone.Core/MediaFiles/DiskScanService.cs @@ -9,6 +9,7 @@ using NzbDrone.Core.MediaFiles.Commands; using NzbDrone.Core.Parser; using NzbDrone.Core.Providers; using NzbDrone.Core.Tv; +using NzbDrone.Core.Tv.Events; namespace NzbDrone.Core.MediaFiles { @@ -18,7 +19,7 @@ namespace NzbDrone.Core.MediaFiles string[] GetVideoFiles(string path, bool allDirectories = true); } - public class DiskScanService : IDiskScanService, IExecute + public class DiskScanService : IDiskScanService, IExecute, IHandle { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly string[] MediaExtensions = new[] { ".mkv", ".avi", ".wmv", ".mp4", ".mpg", ".mpeg", ".xvid", ".flv", ".mov", ".rm", ".rmvb", ".divx", ".dvr-ms", ".ts", ".ogm", ".m4v", ".strm" }; @@ -143,5 +144,10 @@ namespace NzbDrone.Core.MediaFiles Scan(series); } } + + public void Handle(EpisodeInfoAddedEvent message) + { + Scan(message.Series); + } } } \ No newline at end of file diff --git a/NzbDrone.Core/Tv/EpisodeService.cs b/NzbDrone.Core/Tv/EpisodeService.cs index 28e19f7c9..5ba9c4ae2 100644 --- a/NzbDrone.Core/Tv/EpisodeService.cs +++ b/NzbDrone.Core/Tv/EpisodeService.cs @@ -206,7 +206,7 @@ namespace NzbDrone.Core.Tv if (newList.Any()) { - _messageAggregator.PublishEvent(new EpisodeInfoAddedEvent(newList)); + _messageAggregator.PublishEvent(new EpisodeInfoAddedEvent(newList, series)); } if (updateList.Any()) diff --git a/NzbDrone.Core/Tv/Events/EpisodeInfoAddedEvent.cs b/NzbDrone.Core/Tv/Events/EpisodeInfoAddedEvent.cs index 8bca207ad..ff6353b9c 100644 --- a/NzbDrone.Core/Tv/Events/EpisodeInfoAddedEvent.cs +++ b/NzbDrone.Core/Tv/Events/EpisodeInfoAddedEvent.cs @@ -6,10 +6,12 @@ namespace NzbDrone.Core.Tv.Events { public class EpisodeInfoAddedEvent : IEvent { + public Series Series { get; private set; } public ReadOnlyCollection Episodes { get; private set; } - public EpisodeInfoAddedEvent(IList episodes) + public EpisodeInfoAddedEvent(IList episodes, Series series) { + Series = series; Episodes = new ReadOnlyCollection(episodes); } } diff --git a/NzbDrone.Core/Tv/SeriesService.cs b/NzbDrone.Core/Tv/SeriesService.cs index 22e423f30..84311befa 100644 --- a/NzbDrone.Core/Tv/SeriesService.cs +++ b/NzbDrone.Core/Tv/SeriesService.cs @@ -101,18 +101,20 @@ namespace NzbDrone.Core.Tv { Ensure.That(() => newSeries).IsNotNull(); - if (String.IsNullOrWhiteSpace(newSeries.FolderName)) - { - newSeries.FolderName = FileNameBuilder.CleanFilename(newSeries.Title); - _diskProvider.CreateFolder(Path.Combine(_rootFolderService.Get(newSeries.RootFolderId).Path, newSeries.FolderName)); - } + newSeries.FolderName = FileNameBuilder.CleanFilename(newSeries.Title); + newSeries.RootFolder = _rootFolderService.Get(newSeries.RootFolderId); + + _diskProvider.CreateFolder(newSeries.Path); _logger.Info("Adding Series [{0}] Path: [{1}]", newSeries.Title, newSeries.Path); newSeries.Monitored = true; newSeries.CleanTitle = Parser.Parser.NormalizeTitle(newSeries.Title); + if (newSeries.QualityProfileId == 0) + { newSeries.QualityProfileId = _configService.DefaultQualityProfile; + } newSeries.SeasonFolder = _configService.UseSeasonFolder; newSeries.BacklogSetting = BacklogSettingType.Inherit; diff --git a/UI/Series/Delete/DeleteSeriesView.js b/UI/Series/Delete/DeleteSeriesView.js index f3bfdf890..34ef1a907 100644 --- a/UI/Series/Delete/DeleteSeriesView.js +++ b/UI/Series/Delete/DeleteSeriesView.js @@ -2,7 +2,7 @@ define(['app', 'Series/SeriesModel'], function () { NzbDrone.Series.Delete.DeleteSeriesView = Backbone.Marionette.ItemView.extend({ - template : 'Series/Delete/DeleteSeriesTemplate', + template: 'Series/Delete/DeleteSeriesTemplate', events: { 'click .x-confirm-delete': 'removeSeries' @@ -18,6 +18,7 @@ define(['app', 'Series/SeriesModel'], function () { this.model.destroy({ data : { 'deleteFiles': deleteFiles }, + wait : true, success: function (model) { model.collection.remove(model); } diff --git a/UI/Series/SeriesCollection.js b/UI/Series/SeriesCollection.js index 53ecbdff2..78df7bba8 100644 --- a/UI/Series/SeriesCollection.js +++ b/UI/Series/SeriesCollection.js @@ -1,6 +1,6 @@ "use strict"; define(['app', 'Series/SeriesModel'], function () { - NzbDrone.Series.SeriesCollection = Backbone.PageableCollection.extend({ + NzbDrone.Series.SeriesCollection = Backbone.Collection.extend({ url : NzbDrone.Constants.ApiRoot + '/series', model: NzbDrone.Series.SeriesModel,