Fixed: Multipart episodes are now added to sab queue using single episode title only.

pull/2/head
kay.one 13 years ago
parent 44d6d20bd6
commit 65417bd8ec

@ -155,6 +155,27 @@
"unpackopts":"3",
"verbosity":""
},
{
"avg_age":"580d",
"cat":"tv",
"eta":"01:45 PM Mon 23 Jan",
"filename":"My Name Is Earl - 3x14-3x15 - I Won't Die With a Little Help from My Friends (1) + I Won't Die With a Little Help from My Friend [Bluray720p]",
"index":1,
"mb":"419.23",
"mbleft":"419.23",
"missing":0,
"msgid":5657628,
"nzo_id":"SABnzbd_nzo_dgrzts",
"percentage":"0",
"priority":"Normal",
"script":"None",
"size":"419 MB",
"sizeleft":"419 MB",
"status":"Queued",
"timeleft":"86:01:55",
"unpackopts":"3",
"verbosity":""
},
{
"status":"Paused",
"index":1,

@ -41,14 +41,14 @@ namespace NzbDrone.Core.Test.ProviderTests
fakeEpisode = Builder<Episode>.CreateNew()
.With(e => e.SeriesId = fakeSeries.SeriesId)
.With(e => e.Title = "Episode 1")
.With(e => e.Title = "Episode (1)")
.Build();
fakeEpisode2 = Builder<Episode>.CreateNew()
.With(e => e.SeriesId = fakeSeries.SeriesId)
.With(e => e.SeasonNumber = fakeEpisode.SeasonNumber)
.With(e => e.EpisodeNumber = fakeEpisode.EpisodeNumber + 1)
.With(e => e.Title = "Episode 2")
.With(e => e.Title = "Episode (2)")
.Build();
fakeDailyEpisode = Builder<Episode>.CreateNew()
@ -137,6 +137,7 @@ namespace NzbDrone.Core.Test.ProviderTests
VerifyEpisode(ep[0], fakeEpisode);
VerifyEpisode(ep[1], fakeEpisode2);
parseResult.EpisodeTitle.Should().Be("Episode");
}
@ -155,7 +156,7 @@ namespace NzbDrone.Core.Test.ProviderTests
var ep = episodeProvider.GetEpisodesByParseResult(parseResult,true);
ep.Should().BeEmpty();
Db.Fetch<Episode>().Should().HaveCount(0);
Db.Fetch<Episode>().Should().BeEmpty();
}
@ -208,7 +209,7 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void GetEpisodeParseResult_should_return_multiple_titles_for_multiple_episodes()
public void GetEpisodeParseResult_should_return_single_title_for_multiple_episodes()
{
Db.Insert(fakeSeries);
Db.Insert(fakeEpisode);
@ -229,7 +230,7 @@ namespace NzbDrone.Core.Test.ProviderTests
VerifyEpisode(ep[0], fakeEpisode);
VerifyEpisode(ep[1], fakeEpisode2);
parseResult.EpisodeTitle.Should().Be(fakeEpisode.Title + " + " + fakeEpisode2.Title);
parseResult.EpisodeTitle.Should().Be("Episode");
}
[Test]

@ -94,7 +94,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SabProviderTests
var result = Mocker.Resolve<SabProvider>().GetQueue();
result.Should().HaveCount(6);
result.Should().HaveCount(7);
}
[Test]
@ -225,6 +225,28 @@ namespace NzbDrone.Core.Test.ProviderTests.SabProviderTests
result.Should().BeTrue();
}
[TestCase(3, new[] { 14, 15 }, "My Name Is Earl", QualityTypes.Bluray720p, false)]
[TestCase(3, new[] { 15 }, "My Name Is Earl", QualityTypes.DVD, false)]
[TestCase(3, new[] { 14 }, "My Name Is Earl", QualityTypes.HDTV, false)]
[TestCase(3, new[] { 15, 16 }, "My Name Is Earl", QualityTypes.SDTV, false)]
public void IsInQueue_should_find_double_episodes_(int season, int[] episodes, string title, QualityTypes qualityType, bool proper)
{
WithFullQueue();
var parseResult = new EpisodeParseResult
{
EpisodeTitle = "Title",
EpisodeNumbers = new List<int>(episodes),
SeasonNumber = season,
Quality = new Quality { QualityType = qualityType, Proper = proper },
Series = new Series { Title = title, CleanTitle = Parser.NormalizeTitle(title) },
};
var result = Mocker.Resolve<SabProvider>().IsInQueue(parseResult);
result.Should().BeTrue();
}
[Test]
public void IsInQueue_should_return_false_if_queue_is_empty()
{

@ -102,15 +102,11 @@ namespace NzbDrone.Core.Test.ProviderTests.SabProviderTests
}
[TestCase(1, new[] { 2 }, "My Episode Title", QualityTypes.DVD, false,
"My Series Name - 1x2 - My Episode Title [DVD]")]
[TestCase(1, new[] { 2 }, "My Episode Title", QualityTypes.DVD, true,
"My Series Name - 1x2 - My Episode Title [DVD] [Proper]")]
[TestCase(1, new[] { 2 }, "My Episode Title", QualityTypes.DVD, false, "My Series Name - 1x2 - My Episode Title [DVD]")]
[TestCase(1, new[] { 2 }, "My Episode Title", QualityTypes.DVD, true, "My Series Name - 1x2 - My Episode Title [DVD] [Proper]")]
[TestCase(1, new[] { 2 }, "", QualityTypes.DVD, true, "My Series Name - 1x2 - [DVD] [Proper]")]
[TestCase(1, new[] { 2, 4 }, "My Episode Title", QualityTypes.HDTV, false,
"My Series Name - 1x2-1x4 - My Episode Title [HDTV]")]
[TestCase(1, new[] { 2, 4 }, "My Episode Title", QualityTypes.HDTV, true,
"My Series Name - 1x2-1x4 - My Episode Title [HDTV] [Proper]")]
[TestCase(1, new[] { 2, 4 }, "My Episode Title", QualityTypes.HDTV, false, "My Series Name - 1x2-1x4 - My Episode Title [HDTV]")]
[TestCase(1, new[] { 2, 4 }, "My Episode Title", QualityTypes.HDTV, true, "My Series Name - 1x2-1x4 - My Episode Title [HDTV] [Proper]")]
[TestCase(1, new[] { 2, 4 }, "", QualityTypes.HDTV, true, "My Series Name - 1x2-1x4 - [HDTV] [Proper]")]
public void create_proper_sab_titles(int seasons, int[] episodes, string title, QualityTypes quality,
bool proper, string expected)

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Ninject;
using NLog;
using NzbDrone.Core.Model;
@ -12,7 +13,12 @@ namespace NzbDrone.Core.Providers
{
public class EpisodeProvider
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
//this will remove (1),(2) from the end of multi part episodes.
private static readonly Regex multiPartCleanupRegex = new Regex(@"\(\d+\)$", RegexOptions.Compiled);
private readonly TvDbProvider _tvDbProvider;
private readonly IDatabase _database;
private readonly SeriesProvider _seriesProvider;
@ -213,8 +219,15 @@ namespace NzbDrone.Core.Providers
if (episodeInfo != null)
{
result.Add(episodeInfo);
parseResult.EpisodeTitle += String.Format(" + {0}", episodeInfo.Title);
parseResult.EpisodeTitle = parseResult.EpisodeTitle.Trim('+', ' ');
if (parseResult.EpisodeNumbers.Count == 1)
{
parseResult.EpisodeTitle = episodeInfo.Title.Trim();
}
else
{
parseResult.EpisodeTitle = multiPartCleanupRegex.Replace(episodeInfo.Title, string.Empty).Trim();
}
}
else
{

Loading…
Cancel
Save