Show Path to episode on disk in Details.

Timer to cleanup/scan for EpisodeFiles (Midnight)
Fixed Relationship for EpisodeFile to Series
pull/6/head
markus101 14 years ago
parent b5c7135d24
commit a950a13c30

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

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

@ -10,22 +10,24 @@ namespace NzbDrone.Core.Providers
{ {
public class TimerProvider : ITimerProvider public class TimerProvider : ITimerProvider
{ {
private IRssSyncProvider _rssSyncProvider; private readonly IRssSyncProvider _rssSyncProvider;
private ISeriesProvider _seriesProvider; private readonly ISeriesProvider _seriesProvider;
private ISeasonProvider _seasonProvider; private readonly ISeasonProvider _seasonProvider;
private IEpisodeProvider _episodeProvider; private readonly IEpisodeProvider _episodeProvider;
private readonly IMediaFileProvider _mediaFileProvider;
private Timer _rssSyncTimer; private Timer _rssSyncTimer;
private Timer _minuteTimer; private Timer _minuteTimer;
private DateTime _rssSyncNextInterval; private DateTime _rssSyncNextInterval;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); 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; _rssSyncProvider = rssSyncProvider;
_seriesProvider = seriesProvider; _seriesProvider = seriesProvider;
_seasonProvider = seasonProvider; _seasonProvider = seasonProvider;
_episodeProvider = episodeProvider; _episodeProvider = episodeProvider;
_mediaFileProvider = mediaFileProvider;
_rssSyncTimer = new Timer(); _rssSyncTimer = new Timer();
_minuteTimer = new Timer(60000); _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(); throw new NotImplementedException();
} }
} }

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

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

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

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Web; using System.Web;
@ -81,7 +82,8 @@ namespace NzbDrone.Web.Controllers
SeasonNumber = c.SeasonNumber, SeasonNumber = c.SeasonNumber,
Title = c.Title, Title = c.Title,
Overview = c.Overview, Overview = c.Overview,
AirDate = c.AirDate AirDate = c.AirDate,
Path = GetEpisodePath(c.EpisodeFile)
}); });
return View(new GridModel(episodes)); return View(new GridModel(episodes));
} }
@ -232,5 +234,15 @@ namespace NzbDrone.Web.Controllers
_renameProvider.RenameEpisode(episodeId); _renameProvider.RenameEpisode(episodeId);
return RedirectToAction("Index"); 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);
}
} }
} }

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

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

Loading…
Cancel
Save