mirror of
https://github.com/Radarr/Radarr
synced 2024-12-25 01:11:43 +00:00
Force Refresh added to Series Editor
This commit is contained in:
parent
2982e79065
commit
9d5c942cbf
5 changed files with 136 additions and 21 deletions
81
NzbDrone.Core/Jobs/RefreshEpsiodeMetadata.cs
Normal file
81
NzbDrone.Core/Jobs/RefreshEpsiodeMetadata.cs
Normal file
|
@ -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\SabnzbdPriorityTypeConverter.cs" />
|
||||
<Compile Include="Jobs\CheckpointJob.cs" />
|
||||
<Compile Include="Jobs\RefreshEpsiodeMetadata.cs" />
|
||||
<Compile Include="Jobs\PastWeekBacklogSearchJob.cs" />
|
||||
<Compile Include="Jobs\SearchHistoryCleanupJob.cs" />
|
||||
<Compile Include="Model\DownloadClientType.cs" />
|
||||
|
|
|
@ -66,9 +66,14 @@ public override void CreateForSeries(Series series, TvdbSeries tvDbSeries)
|
|||
_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);
|
||||
_bannerProvider.Download(tvDbSeries.FanartPath, Path.Combine(series.Path, "fanart.jpg"));
|
||||
}
|
||||
|
||||
if (!_diskProvider.FileExists(Path.Combine(series.Path, "folder.jpg")))
|
||||
{
|
||||
if(_configProvider.MetadataUseBanners)
|
||||
{
|
||||
_logger.Debug("Downloading series banner for: {0}", series.Title);
|
||||
|
@ -87,6 +92,7 @@ public override void CreateForSeries(Series series, TvdbSeries tvDbSeries)
|
|||
DownloadSeasonThumbnails(series, tvDbSeries, TvdbSeasonBanner.Type.season);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void CreateForEpisodeFile(EpisodeFile episodeFile, TvdbSeries tvDbSeries)
|
||||
{
|
||||
|
@ -110,8 +116,12 @@ public override void CreateForEpisodeFile(EpisodeFile episodeFile, TvdbSeries tv
|
|||
return;
|
||||
}
|
||||
|
||||
if (!_diskProvider.FileExists(episodeFile.Path.Replace(Path.GetExtension(episodeFile.Path), ".tbn")))
|
||||
{
|
||||
_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);
|
||||
|
||||
|
@ -230,12 +240,17 @@ private void DownloadSeasonThumbnails(Series series, TvdbSeries tvDbSeries, Tvdb
|
|||
_logger.Debug("Downloading banner for Season: {0} Series: {1}", season, series.Title);
|
||||
|
||||
if (season == 0)
|
||||
{
|
||||
if (!_diskProvider.FileExists(Path.Combine(series.Path, "season-specials.tbn")))
|
||||
{
|
||||
_bannerProvider.Download(banner.BannerPath,
|
||||
Path.Combine(series.Path, "season-specials.tbn"));
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (!_diskProvider.FileExists(Path.Combine(series.Path, String.Format("season{0:00}.tbn", season))))
|
||||
{
|
||||
_bannerProvider.Download(banner.BannerPath,
|
||||
Path.Combine(series.Path, String.Format("season{0:00}.tbn", season)));
|
||||
|
@ -244,3 +259,4 @@ private void DownloadSeasonThumbnails(Series series, TvdbSeries tvDbSeries, Tvdb
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,6 +62,16 @@ public JsonResult ForceRefresh(int seriesId)
|
|||
{
|
||||
_jobProvider.QueueJob(typeof(UpdateInfoJob), 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");
|
||||
}
|
||||
|
|
|
@ -54,6 +54,13 @@
|
|||
</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" }))
|
||||
{
|
||||
<table id ="seriesEditorGrid" class="dataTable dataTablesGrid no-details">
|
||||
|
|
Loading…
Reference in a new issue