diskscan is triggered when new episodes are added.

pull/4/head
kay.one 12 years ago
parent c6933f0228
commit 80759f923e

@ -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" />

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

@ -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);
}
}
}

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

@ -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);
}
}

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

@ -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);
}

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

Loading…
Cancel
Save