mirror of
https://github.com/Radarr/Radarr
synced 2024-12-24 08:52:38 +00:00
Allow sorting with articles (option)
New: Option to sort with articles (a, the, an) included
This commit is contained in:
parent
978e564845
commit
2439b9e087
12 changed files with 63 additions and 21 deletions
|
@ -18,10 +18,6 @@ namespace NzbDrone.Core.Test
|
|||
// ReSharper disable InconsistentNaming
|
||||
public class SortHelperTest : CoreTest
|
||||
{
|
||||
//American Gladiators
|
||||
//Ancient Apocalypse
|
||||
//There Will Be Brawl
|
||||
|
||||
[TestCase("The Office (US)", "Office (US)")]
|
||||
[TestCase("A Man in Anger", "Man in Anger")]
|
||||
[TestCase("An Idiot Abroad", "Idiot Abroad")]
|
||||
|
@ -32,7 +28,7 @@ public class SortHelperTest : CoreTest
|
|||
[TestCase(null, "")]
|
||||
public void SkipArticles(string title, string expected)
|
||||
{
|
||||
var result = SortHelper.SkipArticles(title);
|
||||
var result = title.IgnoreArticles();
|
||||
result.Should().Be(expected);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
|
||||
namespace NzbDrone.Core.Helpers
|
||||
{
|
||||
public class SortHelper
|
||||
public static class SortHelper
|
||||
{
|
||||
public static string SkipArticles(string input)
|
||||
public static string IgnoreArticles(this string input)
|
||||
{
|
||||
if (String.IsNullOrEmpty(input))
|
||||
return String.Empty;
|
||||
|
|
|
@ -15,13 +15,16 @@ public class DiskScanJob : IJob
|
|||
{
|
||||
private readonly SeriesProvider _seriesProvider;
|
||||
private readonly DiskScanProvider _diskScanProvider;
|
||||
private readonly ConfigProvider _configProvider;
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
[Inject]
|
||||
public DiskScanJob(SeriesProvider seriesProvider, DiskScanProvider diskScanProvider)
|
||||
public DiskScanJob(SeriesProvider seriesProvider, DiskScanProvider diskScanProvider,
|
||||
ConfigProvider configProvider)
|
||||
{
|
||||
_seriesProvider = seriesProvider;
|
||||
_diskScanProvider = diskScanProvider;
|
||||
_configProvider = configProvider;
|
||||
}
|
||||
|
||||
public DiskScanJob()
|
||||
|
@ -43,7 +46,11 @@ public virtual void Start(ProgressNotification notification, dynamic options)
|
|||
IList<Series> seriesToScan;
|
||||
if (options == null || options.SeriesId == 0)
|
||||
{
|
||||
seriesToScan = _seriesProvider.GetAllSeries().OrderBy(o => SortHelper.SkipArticles(o.Title)).ToList();
|
||||
if (_configProvider.IgnoreArticlesWhenSortingSeries)
|
||||
seriesToScan = _seriesProvider.GetAllSeries().OrderBy(o => o.Title.IgnoreArticles()).ToList();
|
||||
|
||||
else
|
||||
seriesToScan = _seriesProvider.GetAllSeries().OrderBy(o => o.Title).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
using NzbDrone.Core.Helpers;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
|
||||
namespace NzbDrone.Core.Jobs
|
||||
|
@ -15,15 +16,17 @@ public class UpdateInfoJob : IJob
|
|||
private readonly SeriesProvider _seriesProvider;
|
||||
private readonly EpisodeProvider _episodeProvider;
|
||||
private readonly ReferenceDataProvider _referenceDataProvider;
|
||||
private readonly ConfigProvider _configProvider;
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
[Inject]
|
||||
public UpdateInfoJob(SeriesProvider seriesProvider, EpisodeProvider episodeProvider,
|
||||
ReferenceDataProvider referenceDataProvider)
|
||||
ReferenceDataProvider referenceDataProvider, ConfigProvider configProvider)
|
||||
{
|
||||
_seriesProvider = seriesProvider;
|
||||
_episodeProvider = episodeProvider;
|
||||
_referenceDataProvider = referenceDataProvider;
|
||||
_configProvider = configProvider;
|
||||
}
|
||||
|
||||
public UpdateInfoJob()
|
||||
|
@ -46,7 +49,11 @@ public virtual void Start(ProgressNotification notification, dynamic options)
|
|||
IList<Series> seriesToUpdate;
|
||||
if (options == null || options.SeriesId == 0)
|
||||
{
|
||||
seriesToUpdate = _seriesProvider.GetAllSeries().OrderBy(o => SortHelper.SkipArticles(o.Title)).ToList();
|
||||
if (_configProvider.IgnoreArticlesWhenSortingSeries)
|
||||
seriesToUpdate = _seriesProvider.GetAllSeries().OrderBy(o => o.Title.IgnoreArticles()).ToList();
|
||||
|
||||
else
|
||||
seriesToUpdate = _seriesProvider.GetAllSeries().OrderBy(o => o.Title).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -529,6 +529,13 @@ public virtual string OmgwtfnzbsApiKey
|
|||
set { SetValue("OmgwtfnzbsApiKey", value); }
|
||||
}
|
||||
|
||||
public virtual Boolean IgnoreArticlesWhenSortingSeries
|
||||
{
|
||||
get { return GetValueBoolean("IgnoreArticlesWhenSortingSeries", true); }
|
||||
|
||||
set { SetValue("IgnoreArticlesWhenSortingSeries", value); }
|
||||
}
|
||||
|
||||
private string GetValue(string key)
|
||||
{
|
||||
return GetValue(key, String.Empty);
|
||||
|
|
|
@ -362,7 +362,7 @@
|
|||
<WebProjectProperties>
|
||||
<UseIIS>False</UseIIS>
|
||||
<AutoAssignPort>True</AutoAssignPort>
|
||||
<DevelopmentServerPort>32122</DevelopmentServerPort>
|
||||
<DevelopmentServerPort>25289</DevelopmentServerPort>
|
||||
<DevelopmentServerVPath>/</DevelopmentServerVPath>
|
||||
<IISUrl>http://localhost:62182/</IISUrl>
|
||||
<NTLMAuthentication>False</NTLMAuthentication>
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
using NzbDrone.Core.Helpers;
|
||||
using NzbDrone.Core.Jobs;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Web.Models;
|
||||
|
||||
namespace NzbDrone.Web.Controllers
|
||||
|
@ -16,11 +17,14 @@ public class HistoryController : Controller
|
|||
{
|
||||
private readonly HistoryProvider _historyProvider;
|
||||
private readonly JobProvider _jobProvider;
|
||||
private readonly ConfigProvider _configProvider;
|
||||
|
||||
public HistoryController(HistoryProvider historyProvider, JobProvider jobProvider)
|
||||
public HistoryController(HistoryProvider historyProvider, JobProvider jobProvider,
|
||||
ConfigProvider configProvider)
|
||||
{
|
||||
_historyProvider = historyProvider;
|
||||
_jobProvider = jobProvider;
|
||||
_configProvider = configProvider;
|
||||
}
|
||||
|
||||
public ActionResult Index()
|
||||
|
@ -32,6 +36,7 @@ public ActionResult AjaxBinding(DataTablesPageRequest pageRequest)
|
|||
{
|
||||
var pageResult = _historyProvider.GetPagedItems(pageRequest);
|
||||
var totalItems = _historyProvider.Count();
|
||||
var ignoreArticles = _configProvider.IgnoreArticlesWhenSortingSeries;
|
||||
|
||||
var items = pageResult.Items.Select(h => new HistoryModel
|
||||
{
|
||||
|
@ -41,7 +46,7 @@ public ActionResult AjaxBinding(DataTablesPageRequest pageRequest)
|
|||
EpisodeTitle = h.EpisodeTitle,
|
||||
EpisodeOverview = h.EpisodeOverview,
|
||||
SeriesTitle = h.SeriesTitle,
|
||||
SeriesTitleSorter = SortHelper.SkipArticles(h.SeriesTitle),
|
||||
SeriesTitleSorter = ignoreArticles ? h.SeriesTitle.IgnoreArticles() : h.SeriesTitle,
|
||||
NzbTitle = h.NzbTitle,
|
||||
Quality = h.Quality.ToString(),
|
||||
IsProper = h.IsProper,
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
using NzbDrone.Core;
|
||||
using NzbDrone.Core.Helpers;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Web.Models;
|
||||
using ServiceStack.Text;
|
||||
|
||||
|
@ -16,15 +17,18 @@ namespace NzbDrone.Web.Controllers
|
|||
public class MissingController : Controller
|
||||
{
|
||||
private readonly EpisodeProvider _episodeProvider;
|
||||
private readonly ConfigProvider _configProvider;
|
||||
|
||||
public MissingController(EpisodeProvider episodeProvider)
|
||||
public MissingController(EpisodeProvider episodeProvider, ConfigProvider configProvider)
|
||||
{
|
||||
_episodeProvider = episodeProvider;
|
||||
_configProvider = configProvider;
|
||||
}
|
||||
|
||||
public ActionResult Index()
|
||||
{
|
||||
var missingEpisodes = _episodeProvider.EpisodesWithoutFiles(false);
|
||||
var ignoreArticles = _configProvider.IgnoreArticlesWhenSortingSeries;
|
||||
|
||||
var missing = missingEpisodes.Select(e => new MissingEpisodeModel
|
||||
{
|
||||
|
@ -34,7 +38,7 @@ public ActionResult Index()
|
|||
EpisodeTitle = e.Title,
|
||||
Overview = e.Overview,
|
||||
SeriesTitle = e.Series.Title,
|
||||
SeriesTitleSorter = SortHelper.SkipArticles(e.Series.Title),
|
||||
SeriesTitleSorter = ignoreArticles ? e.Series.Title.IgnoreArticles() : e.Series.Title,
|
||||
AirDateSorter = e.AirDate.Value.ToString("o", CultureInfo.InvariantCulture),
|
||||
AirDate = e.AirDate.Value.ToBestDateString()
|
||||
});
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
using NzbDrone.Core.Jobs;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using NzbDrone.Web.Filters;
|
||||
|
@ -25,17 +26,19 @@ public class SeriesController : Controller
|
|||
private readonly SeriesProvider _seriesProvider;
|
||||
private readonly JobProvider _jobProvider;
|
||||
private readonly SeasonProvider _seasonProvider;
|
||||
private readonly ConfigProvider _configProvider;
|
||||
//
|
||||
// GET: /Series/
|
||||
|
||||
public SeriesController(SeriesProvider seriesProvider,
|
||||
QualityProvider qualityProvider, JobProvider jobProvider,
|
||||
SeasonProvider seasonProvider)
|
||||
public SeriesController(SeriesProvider seriesProvider, QualityProvider qualityProvider,
|
||||
JobProvider jobProvider, SeasonProvider seasonProvider,
|
||||
ConfigProvider configProvider)
|
||||
{
|
||||
_seriesProvider = seriesProvider;
|
||||
_qualityProvider = qualityProvider;
|
||||
_jobProvider = jobProvider;
|
||||
_seasonProvider = seasonProvider;
|
||||
_configProvider = configProvider;
|
||||
}
|
||||
|
||||
public ActionResult Index()
|
||||
|
@ -177,7 +180,7 @@ public ActionResult Editor()
|
|||
masterBacklogList.Insert(0, new KeyValuePair<int, string>(-10, "Select..."));
|
||||
ViewData["MasterBacklogSettingSelectList"] = new SelectList(masterBacklogList, "Key", "Value");
|
||||
|
||||
var series = GetSeriesModels(_seriesProvider.GetAllSeries()).OrderBy(o => SortHelper.SkipArticles(o.Title));
|
||||
var series = GetSeriesModels(_seriesProvider.GetAllSeries());
|
||||
|
||||
return View(series);
|
||||
}
|
||||
|
@ -206,11 +209,13 @@ public JsonResult Editor(List<SeriesModel> series)
|
|||
|
||||
private List<SeriesModel> GetSeriesModels(IList<Series> seriesInDb)
|
||||
{
|
||||
var ignoreArticles = _configProvider.IgnoreArticlesWhenSortingSeries;
|
||||
|
||||
var series = seriesInDb.Select(s => new SeriesModel
|
||||
{
|
||||
SeriesId = s.SeriesId,
|
||||
Title = s.Title,
|
||||
TitleSorter = SortHelper.SkipArticles(s.Title),
|
||||
TitleSorter = ignoreArticles? s.Title.IgnoreArticles() : s.Title,
|
||||
AirsDayOfWeek = s.AirsDayOfWeek.ToString(),
|
||||
Monitored = s.Monitored,
|
||||
Overview = s.Overview,
|
||||
|
|
|
@ -253,6 +253,7 @@ public ActionResult Misc()
|
|||
model.EnableBacklogSearching = _configProvider.EnableBacklogSearching;
|
||||
model.AutoIgnorePreviouslyDownloadedEpisodes = _configProvider.AutoIgnorePreviouslyDownloadedEpisodes;
|
||||
model.AllowedReleaseGroups = _configProvider.AllowedReleaseGroups;
|
||||
model.IgnoreArticlesWhenSortingSeries = _configProvider.IgnoreArticlesWhenSortingSeries;
|
||||
|
||||
return View(model);
|
||||
}
|
||||
|
@ -662,6 +663,7 @@ public JsonResult SaveMisc(MiscSettingsModel data)
|
|||
_configProvider.EnableBacklogSearching = data.EnableBacklogSearching;
|
||||
_configProvider.AutoIgnorePreviouslyDownloadedEpisodes = data.AutoIgnorePreviouslyDownloadedEpisodes;
|
||||
_configProvider.AllowedReleaseGroups = data.AllowedReleaseGroups;
|
||||
_configProvider.IgnoreArticlesWhenSortingSeries = data.IgnoreArticlesWhenSortingSeries;
|
||||
|
||||
return GetSuccessResult();
|
||||
}
|
||||
|
|
|
@ -20,5 +20,9 @@ public class MiscSettingsModel
|
|||
[Description("Comma separated list of release groups to download episodes (leave empty for all groups)")]
|
||||
[DisplayFormat(ConvertEmptyStringToNull = false)]
|
||||
public string AllowedReleaseGroups { get; set; }
|
||||
|
||||
[DisplayName("Ignore Articles")]
|
||||
[Description("Ignore articles when sorting by series title?")]
|
||||
public bool IgnoreArticlesWhenSortingSeries { get; set; }
|
||||
}
|
||||
}
|
|
@ -27,6 +27,11 @@
|
|||
</label>
|
||||
@Html.TextBoxFor(m => m.AllowedReleaseGroups, new { @class = "inputClass" })
|
||||
|
||||
<label class="labelClass">@Html.LabelFor(m => m.IgnoreArticlesWhenSortingSeries)
|
||||
<span class="small">@Html.DescriptionFor(m => m.IgnoreArticlesWhenSortingSeries)</span>
|
||||
</label>
|
||||
@Html.CheckBoxFor(m => m.IgnoreArticlesWhenSortingSeries, new { @class = "inputClass checkClass" })
|
||||
|
||||
<div style="overflow: hidden; height: 50px;">
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in a new issue