Show Path to episode on disk in Details.

Timer to cleanup/scan for EpisodeFiles (Midnight)
Fixed Relationship for EpisodeFile to Series
This commit is contained in:
markus101 2011-02-24 17:18:22 -08:00
parent b5c7135d24
commit a950a13c30
9 changed files with 40 additions and 11 deletions

View File

@ -14,6 +14,7 @@ namespace NzbDrone.Core.Providers
EpisodeFile ImportFile(Series series, string filePath);
string GenerateEpisodePath(EpisodeModel episode);
void CleanUp(List<EpisodeFile> files);
void DeleteFromDb(int fileId);
void DeleteFromDisk(int fileId, string path);
void Update(EpisodeFile episodeFile);

View File

@ -132,7 +132,7 @@ namespace NzbDrone.Core.Providers
//Can't use providers because episode provider needs series provider - Cyclic Dependency Injection, this will work
Logger.Debug("Deleting EpisodeFiles from DB for Series: {0}", series.SeriesId);
_sonioRepo.DeleteMany(series.Files);
_sonioRepo.DeleteMany(series.EpisodeFiles);
Logger.Debug("Deleting Episodes from DB for Series: {0}", series.SeriesId);
_sonioRepo.DeleteMany(series.Episodes);

View File

@ -10,22 +10,24 @@ namespace NzbDrone.Core.Providers
{
public class TimerProvider : ITimerProvider
{
private IRssSyncProvider _rssSyncProvider;
private ISeriesProvider _seriesProvider;
private ISeasonProvider _seasonProvider;
private IEpisodeProvider _episodeProvider;
private readonly IRssSyncProvider _rssSyncProvider;
private readonly ISeriesProvider _seriesProvider;
private readonly ISeasonProvider _seasonProvider;
private readonly IEpisodeProvider _episodeProvider;
private readonly IMediaFileProvider _mediaFileProvider;
private Timer _rssSyncTimer;
private Timer _minuteTimer;
private DateTime _rssSyncNextInterval;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public TimerProvider(IRssSyncProvider rssSyncProvider, ISeriesProvider seriesProvider, ISeasonProvider seasonProvider, IEpisodeProvider episodeProvider)
public TimerProvider(IRssSyncProvider rssSyncProvider, ISeriesProvider seriesProvider, ISeasonProvider seasonProvider, IEpisodeProvider episodeProvider, IMediaFileProvider mediaFileProvider)
{
_rssSyncProvider = rssSyncProvider;
_seriesProvider = seriesProvider;
_seasonProvider = seasonProvider;
_episodeProvider = episodeProvider;
_mediaFileProvider = mediaFileProvider;
_rssSyncTimer = new Timer();
_minuteTimer = new Timer(60000);
@ -117,6 +119,16 @@ namespace NzbDrone.Core.Providers
}
}
//Daily 00:00 (Midnight) - Cleanup (removed) EpisodeFiles + Scan for New EpisodeFiles
if (now.Hour == 0 && now.Minute == 0)
{
foreach (var series in _seriesProvider.GetAllSeries())
{
_mediaFileProvider.CleanUp(series.EpisodeFiles);
_mediaFileProvider.Scan(series);
}
}
throw new NotImplementedException();
}
}

View File

@ -12,9 +12,9 @@ namespace NzbDrone.Core.Repository
public virtual int EpisodeId { get; set; }
public virtual int SeriesId { get; set; }
public virtual int EpisodeFileId { get; set; }
public virtual int SeasonId { get; set; }
public int SeasonNumber { get; set; }
public int EpisodeNumber { get; set; }
public int SeasonId { get; set; }
public string Title { get; set; }
public DateTime AirDate { get; set; }
[SubSonicLongString]

View File

@ -9,7 +9,7 @@ namespace NzbDrone.Core.Repository
{
[SubSonicPrimaryKey]
public virtual int EpisodeFileId { get; set; }
public int SeriesId { get; set; }
public virtual int SeriesId { get; set; }
public string Path { get; set; }
public QualityTypes Quality { get; set; }
public bool Proper { get; set; }
@ -18,5 +18,8 @@ namespace NzbDrone.Core.Repository
[SubSonicToManyRelation]
public virtual List<Episode> Episodes { get; private set; }
[SubSonicToOneRelation(ThisClassContainsJoinKey = true)]
public virtual Series Series { get; private set; }
}
}

View File

@ -42,6 +42,6 @@ namespace NzbDrone.Core.Repository
public virtual List<Episode> Episodes { get; private set; }
[SubSonicToManyRelation]
public virtual List<EpisodeFile> Files { get; private set; }
public virtual List<EpisodeFile> EpisodeFiles { get; private set; }
}
}

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Web;
@ -81,7 +82,8 @@ namespace NzbDrone.Web.Controllers
SeasonNumber = c.SeasonNumber,
Title = c.Title,
Overview = c.Overview,
AirDate = c.AirDate
AirDate = c.AirDate,
Path = GetEpisodePath(c.EpisodeFile)
});
return View(new GridModel(episodes));
}
@ -232,5 +234,15 @@ namespace NzbDrone.Web.Controllers
_renameProvider.RenameEpisode(episodeId);
return RedirectToAction("Index");
}
//Local Helpers
private string GetEpisodePath(EpisodeFile file)
{
if (file == null)
return String.Empty;
//Return the path relative to the Series' Folder
return file.Path.Replace(file.Series.Path, "").Trim(Path.DirectorySeparatorChar);
}
}
}

View File

@ -12,7 +12,7 @@ namespace NzbDrone.Web.Models
public int EpisodeNumber { get; set; }
public int SeasonNumber { get; set; }
public string Overview { get; set; }
public string Path { get; set; }
public DateTime AirDate { get; set; }
}
}

View File

@ -64,6 +64,7 @@
columns.Bound(c => c.EpisodeNumber).Width(0).Title("Episode");
columns.Bound(c => c.Title).Title("Title");
columns.Bound(c => c.AirDate).Format("{0:d}").Width(0);
columns.Bound(c => c.Path);
})
//.DetailView(detailView => detailView.Template(e => Html.RenderPartial("EpisodeDetail", e)))
.DetailView(detailView => detailView.ClientTemplate("<div><#= Overview #></div>"))