Add series changes

pull/6/head
Mark McDowall 12 years ago
parent 19dfd49ad3
commit 684a72792a

@ -27,6 +27,8 @@ namespace NzbDrone.Core.Datastore.Migration
.WithColumn("Overview").AsString().Nullable() .WithColumn("Overview").AsString().Nullable()
.WithColumn("AirTime").AsString().Nullable() .WithColumn("AirTime").AsString().Nullable()
.WithColumn("Images").AsString() .WithColumn("Images").AsString()
.WithColumn("RootFolderId").AsInt32()
.WithColumn("Folder").AsString().NotNullable()
.WithColumn("Path").AsString().Unique() .WithColumn("Path").AsString().Unique()
.WithColumn("Monitored").AsBoolean() .WithColumn("Monitored").AsBoolean()
.WithColumn("QualityProfileId").AsInt32() .WithColumn("QualityProfileId").AsInt32()

@ -41,7 +41,8 @@ namespace NzbDrone.Core.Datastore
Mapper.Entity<History.History>().RegisterModel("History") Mapper.Entity<History.History>().RegisterModel("History")
.HasOne(h => h.Episode, h => h.EpisodeId); .HasOne(h => h.Episode, h => h.EpisodeId);
Mapper.Entity<Series>().RegisterModel("Series"); Mapper.Entity<Series>().RegisterModel("Series")
.HasOne(s => s.RootFolder, s => s.RootFolderId);
Mapper.Entity<Season>().RegisterModel("Seasons"); Mapper.Entity<Season>().RegisterModel("Seasons");
Mapper.Entity<Episode>().RegisterModel("Episodes"); Mapper.Entity<Episode>().RegisterModel("Episodes");

@ -83,7 +83,6 @@ namespace NzbDrone.Core.MediaFiles
parseResult.Quality = episodeFile.Quality; parseResult.Quality = episodeFile.Quality;
parseResult.Episodes = episodes; parseResult.Episodes = episodes;
if (newDownload) if (newDownload)
{ {
_eventAggregator.Publish(new EpisodeDownloadedEvent(parseResult)); _eventAggregator.Publish(new EpisodeDownloadedEvent(parseResult));
@ -91,7 +90,5 @@ namespace NzbDrone.Core.MediaFiles
return episodeFile; return episodeFile;
} }
} }
} }

@ -28,7 +28,6 @@ namespace NzbDrone.Core.MediaFiles
private readonly Logger _logger; private readonly Logger _logger;
private readonly IMediaFileRepository _mediaFileRepository; private readonly IMediaFileRepository _mediaFileRepository;
public MediaFileService(IMediaFileRepository mediaFileRepository, IConfigService configService, IEpisodeService episodeService, IEventAggregator eventAggregator, Logger logger) public MediaFileService(IMediaFileRepository mediaFileRepository, IConfigService configService, IEpisodeService episodeService, IEventAggregator eventAggregator, Logger logger)
{ {
_mediaFileRepository = mediaFileRepository; _mediaFileRepository = mediaFileRepository;
@ -74,8 +73,6 @@ namespace NzbDrone.Core.MediaFiles
return _mediaFileRepository.GetFilesBySeason(seriesId, seasonNumber); return _mediaFileRepository.GetFilesBySeason(seriesId, seasonNumber);
} }
public void HandleAsync(SeriesDeletedEvent message) public void HandleAsync(SeriesDeletedEvent message)
{ {
var files = GetFilesBySeries(message.Series.Id); var files = GetFilesBySeries(message.Series.Id);

@ -1,9 +1,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Marr.Data;
using NzbDrone.Core.Datastore; using NzbDrone.Core.Datastore;
using NzbDrone.Core.MetadataSource.Trakt; using NzbDrone.Core.MetadataSource.Trakt;
using NzbDrone.Core.Model; using NzbDrone.Core.Model;
using NzbDrone.Core.Qualities; using NzbDrone.Core.Qualities;
using NzbDrone.Core.RootFolders;
namespace NzbDrone.Core.Tv namespace NzbDrone.Core.Tv
@ -25,13 +27,11 @@ namespace NzbDrone.Core.Tv
public int TvDbId { get; set; } public int TvDbId { get; set; }
public int TvRageId { get; set; } public int TvRageId { get; set; }
public string ImdbId { get; set; } public string ImdbId { get; set; }
public string Title { get; set; } public string Title { get; set; }
public string CleanTitle { get; set; } public string CleanTitle { get; set; }
public SeriesStatusType Status { get; set; } public SeriesStatusType Status { get; set; }
public string Overview { get; set; } public string Overview { get; set; }
public String AirTime { get; set; } public String AirTime { get; set; }
public string Path { get; set; }
public bool Monitored { get; set; } public bool Monitored { get; set; }
public int QualityProfileId { get; set; } public int QualityProfileId { get; set; }
public bool SeasonFolder { get; set; } public bool SeasonFolder { get; set; }
@ -44,9 +44,15 @@ namespace NzbDrone.Core.Tv
public string Network { get; set; } public string Network { get; set; }
public DateTime? CustomStartDate { get; set; } public DateTime? CustomStartDate { get; set; }
public bool UseSceneNumbering { get; set; } public bool UseSceneNumbering { get; set; }
public string TitleSlug { get; set; } public string TitleSlug { get; set; }
public int RootFolderId { get; set; }
public string Folder { get; set; }
public LazyLoaded<RootFolder> RootFolder { get; set; }
//Todo: Store the root folder + folderName
public string Path { get; set; }
//Todo: This should be a double since there are timezones that aren't on a full hour offset //Todo: This should be a double since there are timezones that aren't on a full hour offset
public int UtcOffset { get; set; } public int UtcOffset { get; set; }

@ -1,12 +1,17 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using Marr.Data;
using NLog; using NLog;
using NzbDrone.Common;
using NzbDrone.Common.EnsureThat; using NzbDrone.Common.EnsureThat;
using NzbDrone.Common.Eventing; using NzbDrone.Common.Eventing;
using NzbDrone.Core.Configuration; using NzbDrone.Core.Configuration;
using NzbDrone.Core.MetadataSource; using NzbDrone.Core.MetadataSource;
using NzbDrone.Core.Model; using NzbDrone.Core.Model;
using NzbDrone.Core.Organizer;
using NzbDrone.Core.RootFolders;
using NzbDrone.Core.Tv.Events; using NzbDrone.Core.Tv.Events;
namespace NzbDrone.Core.Tv namespace NzbDrone.Core.Tv
@ -29,15 +34,18 @@ namespace NzbDrone.Core.Tv
private readonly IConfigService _configService; private readonly IConfigService _configService;
private readonly IProvideSeriesInfo _seriesInfoProxy; private readonly IProvideSeriesInfo _seriesInfoProxy;
private readonly IEventAggregator _eventAggregator; private readonly IEventAggregator _eventAggregator;
private readonly DiskProvider _diskProvider;
private readonly Logger _logger; private readonly Logger _logger;
public SeriesService(ISeriesRepository seriesRepository, IConfigService configServiceService, IProvideSeriesInfo seriesInfoProxy, public SeriesService(ISeriesRepository seriesRepository, IConfigService configServiceService,
IEventAggregator eventAggregator, Logger logger) IProvideSeriesInfo seriesInfoProxy, IEventAggregator eventAggregator,
DiskProvider diskProvider, Logger logger)
{ {
_seriesRepository = seriesRepository; _seriesRepository = seriesRepository;
_configService = configServiceService; _configService = configServiceService;
_seriesInfoProxy = seriesInfoProxy; _seriesInfoProxy = seriesInfoProxy;
_eventAggregator = eventAggregator; _eventAggregator = eventAggregator;
_diskProvider = diskProvider;
_logger = logger; _logger = logger;
} }
@ -80,6 +88,13 @@ namespace NzbDrone.Core.Tv
{ {
Ensure.That(() => newSeries).IsNotNull(); Ensure.That(() => newSeries).IsNotNull();
//Todo: If Path is null we need to create the path
if(String.IsNullOrWhiteSpace(newSeries.Folder))
{
newSeries.Folder = FileNameBuilder.CleanFilename(newSeries.Title);
_diskProvider.CreateDirectory(Path.Combine(newSeries.RootFolder.Value.Path, newSeries.Folder));
}
_logger.Info("Adding Series [{0}] Path: [{1}]", newSeries.Title, newSeries.Path); _logger.Info("Adding Series [{0}] Path: [{1}]", newSeries.Title, newSeries.Path);
newSeries.Monitored = true; newSeries.Monitored = true;

@ -22,13 +22,10 @@ define(['app', 'Shared/NotificationCollection', 'Series/SeriesCollection'], func
addSeries: function () { addSeries: function () {
var quality = this.ui.qualityProfile.val(); var quality = this.ui.qualityProfile.val();
var rootFolderId = this.ui.rootFolder.val();
//Todo: This will create an invalid path on linux...
var rootPath = this.ui.rootFolder.find(":selected").text();
var path = rootPath + "\\" + this.model.get('title');
this.model.set('qualityProfileId', quality); this.model.set('qualityProfileId', quality);
this.model.set('path', path); this.model.set('rootFolderId', rootFolderId);
var self = this; var self = this;

Loading…
Cancel
Save