diskscan is triggered when new episodes are added.

This commit is contained in:
kay.one 2013-05-20 15:45:16 -07:00
parent c6933f0228
commit 80759f923e
9 changed files with 22 additions and 15 deletions

View File

@ -204,7 +204,7 @@
<Compile Include="ParserTests\ParserFixture.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Qualities\QualityProfileFixture.cs" />
<Compile Include="TvTests\SeriesProviderTest.cs" />
<Compile Include="TvTests\SeriesServiceFixture.cs" />
<Compile Include="UpdateTests\UpdatePackageProviderFixture.cs" />
<Compile Include="UpdateTests\GetUpdateLogFixture.cs" />
<Compile Include="XbmcVersionTests.cs" />

View File

@ -13,9 +13,5 @@ namespace NzbDrone.Core.MediaFiles.Commands
SeriesId = seriesId;
}
}
public DiskScanCommand()
{
}
}
}

View File

@ -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<DiskScanCommand>
public class DiskScanService : IDiskScanService, IExecute<DiskScanCommand>, IHandle<EpisodeInfoAddedEvent>
{
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);
}
}
}

View File

@ -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())

View File

@ -6,10 +6,12 @@ namespace NzbDrone.Core.Tv.Events
{
public class EpisodeInfoAddedEvent : IEvent
{
public Series Series { get; private set; }
public ReadOnlyCollection<Episode> Episodes { get; private set; }
public EpisodeInfoAddedEvent(IList<Episode> episodes)
public EpisodeInfoAddedEvent(IList<Episode> episodes, Series series)
{
Series = series;
Episodes = new ReadOnlyCollection<Episode>(episodes);
}
}

View File

@ -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.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;

View File

@ -18,6 +18,7 @@ define(['app', 'Series/SeriesModel'], function () {
this.model.destroy({
data : { 'deleteFiles': deleteFiles },
wait : true,
success: function (model) {
model.collection.remove(model);
}

View File

@ -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,