mirror of https://github.com/Sonarr/Sonarr
Allow sorting with articles (option)
New: Option to sort with articles (a, the, an) included
This commit is contained in:
parent
978e564845
commit
2439b9e087
|
@ -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 @@ namespace NzbDrone.Core.Test
|
|||
[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 @@ using System.Text;
|
|||
|
||||
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 @@ namespace NzbDrone.Core.Jobs
|
|||
{
|
||||
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 @@ namespace NzbDrone.Core.Jobs
|
|||
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 Ninject;
|
|||
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 @@ namespace NzbDrone.Core.Jobs
|
|||
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 @@ namespace NzbDrone.Core.Jobs
|
|||
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 @@ namespace NzbDrone.Core.Providers.Core
|
|||
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 DataTables.Mvc.Core.Models;
|
|||
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 @@ namespace NzbDrone.Web.Controllers
|
|||
{
|
||||
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 @@ namespace NzbDrone.Web.Controllers
|
|||
{
|
||||
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 @@ namespace NzbDrone.Web.Controllers
|
|||
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 System.Web.Script.Serialization;
|
|||
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 @@ namespace NzbDrone.Web.Controllers
|
|||
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.Helpers;
|
|||
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 @@ namespace NzbDrone.Web.Controllers
|
|||
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 @@ namespace NzbDrone.Web.Controllers
|
|||
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 @@ namespace NzbDrone.Web.Controllers
|
|||
|
||||
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 @@ namespace NzbDrone.Web.Controllers
|
|||
model.EnableBacklogSearching = _configProvider.EnableBacklogSearching;
|
||||
model.AutoIgnorePreviouslyDownloadedEpisodes = _configProvider.AutoIgnorePreviouslyDownloadedEpisodes;
|
||||
model.AllowedReleaseGroups = _configProvider.AllowedReleaseGroups;
|
||||
model.IgnoreArticlesWhenSortingSeries = _configProvider.IgnoreArticlesWhenSortingSeries;
|
||||
|
||||
return View(model);
|
||||
}
|
||||
|
@ -662,6 +663,7 @@ namespace NzbDrone.Web.Controllers
|
|||
_configProvider.EnableBacklogSearching = data.EnableBacklogSearching;
|
||||
_configProvider.AutoIgnorePreviouslyDownloadedEpisodes = data.AutoIgnorePreviouslyDownloadedEpisodes;
|
||||
_configProvider.AllowedReleaseGroups = data.AllowedReleaseGroups;
|
||||
_configProvider.IgnoreArticlesWhenSortingSeries = data.IgnoreArticlesWhenSortingSeries;
|
||||
|
||||
return GetSuccessResult();
|
||||
}
|
||||
|
|
|
@ -20,5 +20,9 @@ namespace NzbDrone.Web.Models
|
|||
[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 New Issue