mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-09 04:22:30 +01:00
DailySeries renaming fixed
Fixed: Daily Series will be named with AirDate #ND-112 fixed
This commit is contained in:
parent
62b10a56df
commit
78187b68f9
@ -1,7 +1,9 @@
|
|||||||
// ReSharper disable RedundantUsingDirective
|
// ReSharper disable RedundantUsingDirective
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using FizzWare.NBuilder;
|
using FizzWare.NBuilder;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
@ -748,5 +750,92 @@ public void should_have_two_episodeTitles_when_distinct_count_is_two()
|
|||||||
//Assert
|
//Assert
|
||||||
result.Should().Be("30 Rock - S06E06-E07-E08 - Hello + World");
|
result.Should().Be("30 Rock - S06E06-E07-E08 - Hello + World");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_use_airDate_if_series_isDaily()
|
||||||
|
{
|
||||||
|
var fakeConfig = Mocker.GetMock<ConfigProvider>();
|
||||||
|
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
||||||
|
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
||||||
|
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(true);
|
||||||
|
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
||||||
|
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
|
||||||
|
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
||||||
|
|
||||||
|
var series = Builder<Series>
|
||||||
|
.CreateNew()
|
||||||
|
.With(s => s.IsDaily = true)
|
||||||
|
.With(s => s.Title = "The Daily Show with Jon Stewart")
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var episodes = Builder<Episode>
|
||||||
|
.CreateListOfSize(1)
|
||||||
|
.All()
|
||||||
|
.With(e => e.AirDate = new DateTime(2012, 12, 13))
|
||||||
|
.With(e => e.Title = "Kristen Stewart")
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var result = Mocker.Resolve<MediaFileProvider>()
|
||||||
|
.GetNewFilename(episodes, series, QualityTypes.HDTV, false, new EpisodeFile());
|
||||||
|
result.Should().Be("The Daily Show with Jon Stewart - 2012-12-13 - Kristen Stewart [HDTV]");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_use_airDate_if_series_isDaily_no_episode_title()
|
||||||
|
{
|
||||||
|
var fakeConfig = Mocker.GetMock<ConfigProvider>();
|
||||||
|
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
||||||
|
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(false);
|
||||||
|
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
|
||||||
|
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
||||||
|
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
|
||||||
|
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
||||||
|
|
||||||
|
var series = Builder<Series>
|
||||||
|
.CreateNew()
|
||||||
|
.With(s => s.IsDaily = true)
|
||||||
|
.With(s => s.Title = "The Daily Show with Jon Stewart")
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var episodes = Builder<Episode>
|
||||||
|
.CreateListOfSize(1)
|
||||||
|
.All()
|
||||||
|
.With(e => e.AirDate = new DateTime(2012, 12, 13))
|
||||||
|
.With(e => e.Title = "Kristen Stewart")
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var result = Mocker.Resolve<MediaFileProvider>()
|
||||||
|
.GetNewFilename(episodes, series, QualityTypes.HDTV, false, new EpisodeFile());
|
||||||
|
result.Should().Be("The Daily Show with Jon Stewart - 2012-12-13");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_set_airdate_to_unknown_if_not_available()
|
||||||
|
{
|
||||||
|
var fakeConfig = Mocker.GetMock<ConfigProvider>();
|
||||||
|
fakeConfig.SetupGet(c => c.SortingIncludeSeriesName).Returns(true);
|
||||||
|
fakeConfig.SetupGet(c => c.SortingIncludeEpisodeTitle).Returns(true);
|
||||||
|
fakeConfig.SetupGet(c => c.SortingAppendQuality).Returns(false);
|
||||||
|
fakeConfig.SetupGet(c => c.SortingSeparatorStyle).Returns(0);
|
||||||
|
fakeConfig.SetupGet(c => c.SortingNumberStyle).Returns(2);
|
||||||
|
fakeConfig.SetupGet(c => c.SortingReplaceSpaces).Returns(false);
|
||||||
|
|
||||||
|
var series = Builder<Series>
|
||||||
|
.CreateNew()
|
||||||
|
.With(s => s.IsDaily = true)
|
||||||
|
.With(s => s.Title = "The Daily Show with Jon Stewart")
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var episodes = Builder<Episode>
|
||||||
|
.CreateListOfSize(1)
|
||||||
|
.All()
|
||||||
|
.With(e => e.AirDate = null)
|
||||||
|
.With(e => e.Title = "Kristen Stewart")
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var result = Mocker.Resolve<MediaFileProvider>()
|
||||||
|
.GetNewFilename(episodes, series, QualityTypes.HDTV, false, new EpisodeFile());
|
||||||
|
result.Should().Be("The Daily Show with Jon Stewart - Unknown - Kristen Stewart");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -174,33 +174,47 @@ public virtual string GetNewFilename(IList<Episode> episodes, Series series, Qua
|
|||||||
result += series.Title + separatorStyle.Pattern;
|
result += series.Title + separatorStyle.Pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
result += numberStyle.Pattern.Replace("%0e", String.Format("{0:00}", sortedEpisodes.First().EpisodeNumber));
|
if(!series.IsDaily)
|
||||||
|
|
||||||
if (episodes.Count > 1)
|
|
||||||
{
|
{
|
||||||
var multiEpisodeStyle = EpisodeSortingHelper.GetMultiEpisodeStyle(_configProvider.SortingMultiEpisodeStyle);
|
result += numberStyle.Pattern.Replace("%0e",
|
||||||
|
String.Format("{0:00}", sortedEpisodes.First().EpisodeNumber));
|
||||||
|
|
||||||
foreach (var episode in sortedEpisodes.Skip(1))
|
if(episodes.Count > 1)
|
||||||
{
|
{
|
||||||
if (multiEpisodeStyle.Name == "Duplicate")
|
var multiEpisodeStyle =
|
||||||
{
|
EpisodeSortingHelper.GetMultiEpisodeStyle(_configProvider.SortingMultiEpisodeStyle);
|
||||||
result += separatorStyle.Pattern + numberStyle.Pattern;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result += multiEpisodeStyle.Pattern;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = result.Replace("%0e", String.Format("{0:00}", episode.EpisodeNumber));
|
foreach(var episode in sortedEpisodes.Skip(1))
|
||||||
episodeNames.Add(Parser.CleanupEpisodeTitle(episode.Title));
|
{
|
||||||
|
if(multiEpisodeStyle.Name == "Duplicate")
|
||||||
|
{
|
||||||
|
result += separatorStyle.Pattern + numberStyle.Pattern;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result += multiEpisodeStyle.Pattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = result.Replace("%0e", String.Format("{0:00}", episode.EpisodeNumber));
|
||||||
|
episodeNames.Add(Parser.CleanupEpisodeTitle(episode.Title));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result = result
|
||||||
|
.Replace("%s", String.Format("{0}", episodes.First().SeasonNumber))
|
||||||
|
.Replace("%0s", String.Format("{0:00}", episodes.First().SeasonNumber))
|
||||||
|
.Replace("%x", numberStyle.EpisodeSeparator)
|
||||||
|
.Replace("%p", separatorStyle.Pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
result = result
|
else
|
||||||
.Replace("%s", String.Format("{0}", episodes.First().SeasonNumber))
|
{
|
||||||
.Replace("%0s", String.Format("{0:00}", episodes.First().SeasonNumber))
|
if(episodes.First().AirDate.HasValue)
|
||||||
.Replace("%x", numberStyle.EpisodeSeparator)
|
result += episodes.First().AirDate.Value.ToString("yyyy-MM-dd");
|
||||||
.Replace("%p", separatorStyle.Pattern);
|
|
||||||
|
else
|
||||||
|
result += "Unknown";
|
||||||
|
}
|
||||||
|
|
||||||
if (_configProvider.SortingIncludeEpisodeTitle)
|
if (_configProvider.SortingIncludeEpisodeTitle)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user