mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 12:02:35 +02:00
Moved GetSabTitle from episodeprovider to sabprovider, removed seriesprovider dependency
This commit is contained in:
parent
3beeff4e18
commit
217f98c4a9
@ -77,23 +77,23 @@ public void Is_Needed_Tv_Dvd_BluRay_BluRay720_Is_Cutoff(QualityTypes reportQuali
|
|||||||
Proper = isReportProper
|
Proper = isReportProper
|
||||||
};
|
};
|
||||||
|
|
||||||
var epFile = new EpisodeFile()
|
var epFile = new EpisodeFile
|
||||||
{
|
{
|
||||||
Proper = isFileProper,
|
Proper = isFileProper,
|
||||||
Quality = fileQuality
|
Quality = fileQuality
|
||||||
};
|
};
|
||||||
|
|
||||||
var episodeInfo = new Episode
|
var episodeInfo = new Episode
|
||||||
{
|
{
|
||||||
SeriesId = 12,
|
SeriesId = 12,
|
||||||
SeasonNumber = 2,
|
SeasonNumber = 2,
|
||||||
EpisodeNumber = 3,
|
EpisodeNumber = 3,
|
||||||
Series = new Series() { QualityProfileId = 1 },
|
Series = new Series { QualityProfileId = 1 },
|
||||||
EpisodeFile = epFile
|
EpisodeFile = epFile
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var seriesQualityProfile = new QualityProfile()
|
var seriesQualityProfile = new QualityProfile
|
||||||
{
|
{
|
||||||
Allowed = new List<QualityTypes> { QualityTypes.TV, QualityTypes.DVD, QualityTypes.Bluray720, QualityTypes.Bluray1080 },
|
Allowed = new List<QualityTypes> { QualityTypes.TV, QualityTypes.DVD, QualityTypes.Bluray720, QualityTypes.Bluray1080 },
|
||||||
Cutoff = QualityTypes.Bluray720,
|
Cutoff = QualityTypes.Bluray720,
|
||||||
@ -180,44 +180,7 @@ public void Missing_episode_should_be_added()
|
|||||||
Assert.Count(2, episodes);
|
Assert.Count(2, episodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
|
||||||
[Row(1, new[] { 2 }, "My Episode Title", QualityTypes.DVD, false, "My Series Name - 1x2 - My Episode Title DVD")]
|
|
||||||
[Row(1, new[] { 2 }, "My Episode Title", QualityTypes.DVD, true, "My Series Name - 1x2 - My Episode Title DVD [Proper]")]
|
|
||||||
[Row(1, new[] { 2 }, "", QualityTypes.DVD, true, "My Series Name - 1x2 - DVD [Proper]")]
|
|
||||||
[Row(1, new[] { 2, 4 }, "My Episode Title", QualityTypes.HDTV, false, "My Series Name - 1x2-1x4 - My Episode Title HDTV")]
|
|
||||||
[Row(1, new[] { 2, 4 }, "My Episode Title", QualityTypes.HDTV, true, "My Series Name - 1x2-1x4 - My Episode Title HDTV [Proper]")]
|
|
||||||
[Row(1, new[] { 2, 4 }, "", QualityTypes.HDTV, true, "My Series Name - 1x2-1x4 - HDTV [Proper]")]
|
|
||||||
public void sab_title(int seasons, int[] episodes, string title, QualityTypes quality, bool proper, string excpected)
|
|
||||||
{
|
|
||||||
//Arrange
|
|
||||||
var fakeSeries = new Series()
|
|
||||||
{
|
|
||||||
SeriesId = 12,
|
|
||||||
Path = "C:\\TV Shows\\My Series Name"
|
|
||||||
};
|
|
||||||
|
|
||||||
var mocker = new AutoMoqer();
|
|
||||||
mocker.GetMock<SeriesProvider>(MockBehavior.Strict)
|
|
||||||
.Setup(c => c.GetSeries(12))
|
|
||||||
.Returns(fakeSeries);
|
|
||||||
|
|
||||||
var parsResult = new EpisodeParseResult()
|
|
||||||
{
|
|
||||||
SeriesId = 12,
|
|
||||||
AirDate = DateTime.Now,
|
|
||||||
Episodes = episodes.ToList(),
|
|
||||||
Proper = proper,
|
|
||||||
Quality = quality,
|
|
||||||
SeasonNumber = seasons,
|
|
||||||
EpisodeTitle = title
|
|
||||||
};
|
|
||||||
|
|
||||||
//Act
|
|
||||||
var actual = mocker.Resolve<EpisodeProvider>().GetSabTitle(parsResult);
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
Assert.AreEqual(excpected, actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -1,9 +1,14 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using AutoMoq;
|
using AutoMoq;
|
||||||
using MbUnit.Framework;
|
using MbUnit.Framework;
|
||||||
|
using Moq;
|
||||||
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Providers.Core;
|
using NzbDrone.Core.Providers.Core;
|
||||||
|
using NzbDrone.Core.Repository;
|
||||||
|
using NzbDrone.Core.Repository.Quality;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test
|
namespace NzbDrone.Core.Test
|
||||||
{
|
{
|
||||||
@ -194,5 +199,35 @@ public void IsInQueue_False_Error()
|
|||||||
//Assert
|
//Assert
|
||||||
Assert.AreEqual(false, result);
|
Assert.AreEqual(false, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[Row(1, new[] { 2 }, "My Episode Title", QualityTypes.DVD, false, "My Series Name - 1x2 - My Episode Title DVD")]
|
||||||
|
[Row(1, new[] { 2 }, "My Episode Title", QualityTypes.DVD, true, "My Series Name - 1x2 - My Episode Title DVD [Proper]")]
|
||||||
|
[Row(1, new[] { 2 }, "", QualityTypes.DVD, true, "My Series Name - 1x2 - DVD [Proper]")]
|
||||||
|
[Row(1, new[] { 2, 4 }, "My Episode Title", QualityTypes.HDTV, false, "My Series Name - 1x2-1x4 - My Episode Title HDTV")]
|
||||||
|
[Row(1, new[] { 2, 4 }, "My Episode Title", QualityTypes.HDTV, true, "My Series Name - 1x2-1x4 - My Episode Title HDTV [Proper]")]
|
||||||
|
[Row(1, new[] { 2, 4 }, "", QualityTypes.HDTV, true, "My Series Name - 1x2-1x4 - HDTV [Proper]")]
|
||||||
|
public void sab_title(int seasons, int[] episodes, string title, QualityTypes quality, bool proper, string excpected)
|
||||||
|
{
|
||||||
|
var mocker = new AutoMoqer();
|
||||||
|
|
||||||
|
var parsResult = new EpisodeParseResult()
|
||||||
|
{
|
||||||
|
SeriesId = 12,
|
||||||
|
AirDate = DateTime.Now,
|
||||||
|
Episodes = episodes.ToList(),
|
||||||
|
Proper = proper,
|
||||||
|
Quality = quality,
|
||||||
|
SeasonNumber = seasons,
|
||||||
|
EpisodeTitle = title,
|
||||||
|
FolderName = "My Series Name"
|
||||||
|
};
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var actual = mocker.Resolve<SabProvider>().GetSabTitle(parsResult);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
Assert.AreEqual(excpected, actual);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,6 +9,8 @@ public class EpisodeParseResult
|
|||||||
internal string CleanTitle { get; set; }
|
internal string CleanTitle { get; set; }
|
||||||
public int SeriesId { get; set; }
|
public int SeriesId { get; set; }
|
||||||
|
|
||||||
|
public string FolderName { get; set; }
|
||||||
|
|
||||||
internal int SeasonNumber { get; set; }
|
internal int SeasonNumber { get; set; }
|
||||||
internal List<int> Episodes { get; set; }
|
internal List<int> Episodes { get; set; }
|
||||||
|
|
||||||
|
@ -66,30 +66,6 @@ public virtual IList<Episode> GetEpisodeByParseResult(EpisodeParseResult parseRe
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual String GetSabTitle(EpisodeParseResult parseResult)
|
|
||||||
{
|
|
||||||
//Show Name - 1x01-1x02 - Episode Name
|
|
||||||
//Show Name - 1x01 - Episode Name
|
|
||||||
var episodeString = new List<String>();
|
|
||||||
|
|
||||||
foreach (var episode in parseResult.Episodes)
|
|
||||||
{
|
|
||||||
episodeString.Add(String.Format("{0}x{1}", parseResult.SeasonNumber, episode));
|
|
||||||
}
|
|
||||||
|
|
||||||
var epNumberString = String.Join("-", episodeString);
|
|
||||||
var series = _series.GetSeries(parseResult.SeriesId);
|
|
||||||
var folderName = new DirectoryInfo(series.Path).Name;
|
|
||||||
|
|
||||||
var result = String.Format("{0} - {1} - {2} {3}", folderName, epNumberString, parseResult.EpisodeTitle, parseResult.Quality);
|
|
||||||
|
|
||||||
if (parseResult.Proper)
|
|
||||||
{
|
|
||||||
result += " [Proper]";
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Comprehensive check on whether or not this episode is needed.
|
/// Comprehensive check on whether or not this episode is needed.
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using System.ServiceModel.Syndication;
|
using System.ServiceModel.Syndication;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
@ -160,6 +161,8 @@ protected EpisodeParseResult ParseFeed(SyndicationItem item)
|
|||||||
if (seriesInfo != null)
|
if (seriesInfo != null)
|
||||||
{
|
{
|
||||||
episodeParseResult.SeriesId = seriesInfo.SeriesId;
|
episodeParseResult.SeriesId = seriesInfo.SeriesId;
|
||||||
|
episodeParseResult.FolderName = new DirectoryInfo(seriesInfo.Path).Name; ;
|
||||||
|
|
||||||
episodeParseResult.CleanTitle = seriesInfo.Title;
|
episodeParseResult.CleanTitle = seriesInfo.Title;
|
||||||
return CustomParser(item, episodeParseResult);
|
return CustomParser(item, episodeParseResult);
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Providers.Core;
|
using NzbDrone.Core.Providers.Core;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Providers
|
namespace NzbDrone.Core.Providers
|
||||||
@ -109,5 +112,28 @@ private string GetSabRequest(string action)
|
|||||||
string.Format(@"http://{0}/api?$Action&apikey={1}&ma_username={2}&ma_password={3}", sabnzbdInfo, apiKey,
|
string.Format(@"http://{0}/api?$Action&apikey={1}&ma_username={2}&ma_password={3}", sabnzbdInfo, apiKey,
|
||||||
username, password).Replace("$Action", action);
|
username, password).Replace("$Action", action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String GetSabTitle(EpisodeParseResult parseResult)
|
||||||
|
{
|
||||||
|
//Show Name - 1x01-1x02 - Episode Name
|
||||||
|
//Show Name - 1x01 - Episode Name
|
||||||
|
var episodeString = new List<String>();
|
||||||
|
|
||||||
|
foreach (var episode in parseResult.Episodes)
|
||||||
|
{
|
||||||
|
episodeString.Add(String.Format("{0}x{1}", parseResult.SeasonNumber, episode));
|
||||||
|
}
|
||||||
|
|
||||||
|
var epNumberString = String.Join("-", episodeString);
|
||||||
|
|
||||||
|
var result = String.Format("{0} - {1} - {2} {3}", parseResult.FolderName, epNumberString, parseResult.EpisodeTitle, parseResult.Quality);
|
||||||
|
|
||||||
|
if (parseResult.Proper)
|
||||||
|
{
|
||||||
|
result += " [Proper]";
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user