Force Refresh added to Series Editor

pull/4/head
Mark McDowall 13 years ago
parent 2982e79065
commit 9d5c942cbf

@ -0,0 +1,81 @@
using System.Collections.Generic;
using System.Linq;
using System;
using NLog;
using Ninject;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository;
namespace NzbDrone.Core.Jobs
{
public class RefreshEpisodeMetadata : IJob
{
private readonly MediaFileProvider _mediaFileProvider;
private readonly SeriesProvider _seriesProvider;
private readonly MetadataProvider _metadataProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
[Inject]
public RefreshEpisodeMetadata(MediaFileProvider mediaFileProvider, SeriesProvider seriesProvider,
MetadataProvider metadataProvider)
{
_mediaFileProvider = mediaFileProvider;
_seriesProvider = seriesProvider;
_metadataProvider = metadataProvider;
}
public string Name
{
get { return "Refresh Episode Metadata"; }
}
public TimeSpan DefaultInterval
{
get { return TimeSpan.FromTicks(0); }
}
public void Start(ProgressNotification notification, int targetId, int secondaryTargetId)
{
if (targetId <= 0)
{
var allSeries = _seriesProvider.GetAllSeries();
foreach(var s in allSeries)
{
RefreshMetadata(notification, s);
}
}
var series = _seriesProvider.GetSeries(targetId);
RefreshMetadata(notification, series);
}
private void RefreshMetadata(ProgressNotification notification, Series series)
{
notification.CurrentMessage = String.Format("Refreshing episode metadata for '{0}'", series.Title);
Logger.Debug("Getting episodes from database for series: {0}", series.SeriesId);
var episodeFiles = _mediaFileProvider.GetSeriesFiles(series.SeriesId);
if (episodeFiles == null || episodeFiles.Count == 0)
{
Logger.Warn("No episodes in database found for series: {0}", series.SeriesId);
return;
}
try
{
_metadataProvider.CreateForEpisodeFiles(episodeFiles.ToList());
}
catch (Exception e)
{
Logger.WarnException("An error has occurred while refreshing episode metadata", e);
}
notification.CurrentMessage = String.Format("Epsiode metadata refresh completed for {0}", series.Title);
}
}
}

@ -249,6 +249,7 @@
<Compile Include="Helpers\SortHelper.cs" /> <Compile Include="Helpers\SortHelper.cs" />
<Compile Include="Helpers\SabnzbdPriorityTypeConverter.cs" /> <Compile Include="Helpers\SabnzbdPriorityTypeConverter.cs" />
<Compile Include="Jobs\CheckpointJob.cs" /> <Compile Include="Jobs\CheckpointJob.cs" />
<Compile Include="Jobs\RefreshEpsiodeMetadata.cs" />
<Compile Include="Jobs\PastWeekBacklogSearchJob.cs" /> <Compile Include="Jobs\PastWeekBacklogSearchJob.cs" />
<Compile Include="Jobs\SearchHistoryCleanupJob.cs" /> <Compile Include="Jobs\SearchHistoryCleanupJob.cs" />
<Compile Include="Model\DownloadClientType.cs" /> <Compile Include="Model\DownloadClientType.cs" />

@ -66,10 +66,15 @@ namespace NzbDrone.Core.Providers.Metadata
_diskProvider.WriteAllText(Path.Combine(series.Path, "tvshow.nfo"), doc.ToString()); _diskProvider.WriteAllText(Path.Combine(series.Path, "tvshow.nfo"), doc.ToString());
} }
if (!_diskProvider.FileExists(Path.Combine(series.Path, "fanart.jpg")))
{
_logger.Debug("Downloading fanart for: {0}", series.Title); _logger.Debug("Downloading fanart for: {0}", series.Title);
_bannerProvider.Download(tvDbSeries.FanartPath, Path.Combine(series.Path, "fanart.jpg")); _bannerProvider.Download(tvDbSeries.FanartPath, Path.Combine(series.Path, "fanart.jpg"));
}
if (_configProvider.MetadataUseBanners) if (!_diskProvider.FileExists(Path.Combine(series.Path, "folder.jpg")))
{
if(_configProvider.MetadataUseBanners)
{ {
_logger.Debug("Downloading series banner for: {0}", series.Title); _logger.Debug("Downloading series banner for: {0}", series.Title);
_bannerProvider.Download(tvDbSeries.BannerPath, Path.Combine(series.Path, "folder.jpg")); _bannerProvider.Download(tvDbSeries.BannerPath, Path.Combine(series.Path, "folder.jpg"));
@ -87,6 +92,7 @@ namespace NzbDrone.Core.Providers.Metadata
DownloadSeasonThumbnails(series, tvDbSeries, TvdbSeasonBanner.Type.season); DownloadSeasonThumbnails(series, tvDbSeries, TvdbSeasonBanner.Type.season);
} }
} }
}
public override void CreateForEpisodeFile(EpisodeFile episodeFile, TvdbSeries tvDbSeries) public override void CreateForEpisodeFile(EpisodeFile episodeFile, TvdbSeries tvDbSeries)
{ {
@ -110,8 +116,12 @@ namespace NzbDrone.Core.Providers.Metadata
return; return;
} }
if (!_diskProvider.FileExists(episodeFile.Path.Replace(Path.GetExtension(episodeFile.Path), ".tbn")))
{
_logger.Debug("Downloading episode thumbnail for: {0}", episodeFile.EpisodeFileId); _logger.Debug("Downloading episode thumbnail for: {0}", episodeFile.EpisodeFileId);
_bannerProvider.Download(episodeFileThumbnail.BannerPath, episodeFile.Path.Replace(Path.GetExtension(episodeFile.Path), ".tbn")); _bannerProvider.Download(episodeFileThumbnail.BannerPath,
episodeFile.Path.Replace(Path.GetExtension(episodeFile.Path), ".tbn"));
}
_logger.Debug("Generating filename.nfo for: {0}", episodeFile.EpisodeFileId); _logger.Debug("Generating filename.nfo for: {0}", episodeFile.EpisodeFileId);
@ -230,12 +240,17 @@ namespace NzbDrone.Core.Providers.Metadata
_logger.Debug("Downloading banner for Season: {0} Series: {1}", season, series.Title); _logger.Debug("Downloading banner for Season: {0} Series: {1}", season, series.Title);
if (season == 0) if (season == 0)
{
if (!_diskProvider.FileExists(Path.Combine(series.Path, "season-specials.tbn")))
{ {
_bannerProvider.Download(banner.BannerPath, _bannerProvider.Download(banner.BannerPath,
Path.Combine(series.Path, "season-specials.tbn")); Path.Combine(series.Path, "season-specials.tbn"));
} }
}
else else
{
if (!_diskProvider.FileExists(Path.Combine(series.Path, String.Format("season{0:00}.tbn", season))))
{ {
_bannerProvider.Download(banner.BannerPath, _bannerProvider.Download(banner.BannerPath,
Path.Combine(series.Path, String.Format("season{0:00}.tbn", season))); Path.Combine(series.Path, String.Format("season{0:00}.tbn", season)));
@ -243,4 +258,5 @@ namespace NzbDrone.Core.Providers.Metadata
} }
} }
} }
}
} }

@ -62,6 +62,16 @@ namespace NzbDrone.Web.Controllers
{ {
_jobProvider.QueueJob(typeof(UpdateInfoJob), seriesId); _jobProvider.QueueJob(typeof(UpdateInfoJob), seriesId);
_jobProvider.QueueJob(typeof(DiskScanJob), seriesId); _jobProvider.QueueJob(typeof(DiskScanJob), seriesId);
_jobProvider.QueueJob(typeof(RefreshEpisodeMetadata), seriesId);
return JsonNotificationResult.Queued("Episode update/Disk scan");
}
public JsonResult ForceRefreshAll()
{
_jobProvider.QueueJob(typeof(UpdateInfoJob));
_jobProvider.QueueJob(typeof(DiskScanJob));
_jobProvider.QueueJob(typeof(RefreshEpisodeMetadata));
return JsonNotificationResult.Queued("Episode update/Disk scan"); return JsonNotificationResult.Queued("Episode update/Disk scan");
} }

@ -54,6 +54,13 @@
</style> </style>
} }
@section ActionMenu
{
<ul class="sub-menu">
<li>@Ajax.ActionLink("Force Refresh", "ForceRefreshAll", "Command", null, null, new { Title = "Refresh episode and series information and scan for new episodes for all series" })</li>
</ul>
}
@using (Html.BeginForm("SaveEditor", "Series", FormMethod.Post, new { id = "SeriesEditor", name = "SeriesEditor" })) @using (Html.BeginForm("SaveEditor", "Series", FormMethod.Post, new { id = "SeriesEditor", name = "SeriesEditor" }))
{ {
<table id ="seriesEditorGrid" class="dataTable dataTablesGrid no-details"> <table id ="seriesEditorGrid" class="dataTable dataTablesGrid no-details">

Loading…
Cancel
Save