mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-10-30 07:22:35 +01:00
Properly using Xem now
This commit is contained in:
parent
4b5d20cefe
commit
c9c967fa1d
7
NzbDrone.Core.Test/Files/Xem/Failure.txt
Normal file
7
NzbDrone.Core.Test/Files/Xem/Failure.txt
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
|
||||||
|
"result": "failure",
|
||||||
|
"data": [ ],
|
||||||
|
"message": "no show with the tvdb_id 79488 found"
|
||||||
|
|
||||||
|
}
|
24
NzbDrone.Core.Test/Files/Xem/Ids.txt
Normal file
24
NzbDrone.Core.Test/Files/Xem/Ids.txt
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
|
||||||
|
"result": "success",
|
||||||
|
"data": {
|
||||||
|
"220571": [
|
||||||
|
"Is This a Zombie? Of the Dead",
|
||||||
|
"Kore wa Zombie Desuka?",
|
||||||
|
"Kore wa Zombie Desuka? Of the Dead",
|
||||||
|
"Kore wa Zombie Desuka Of the Dead",
|
||||||
|
"Kore wa Zombie Desu ka - Of the Dead",
|
||||||
|
"Kore wa Zombie Desu ka of the Dead"
|
||||||
|
],
|
||||||
|
"79151": [
|
||||||
|
"Fate Stay Night",
|
||||||
|
"Fate/Zero",
|
||||||
|
"Fate Zero",
|
||||||
|
"Fate/Zero (2012)",
|
||||||
|
"Fate Zero S2",
|
||||||
|
"Fate Zero"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"message": ""
|
||||||
|
|
||||||
|
}
|
32
NzbDrone.Core.Test/Files/Xem/Mappings.txt
Normal file
32
NzbDrone.Core.Test/Files/Xem/Mappings.txt
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
{
|
||||||
|
|
||||||
|
"result": "success",
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"scene": {
|
||||||
|
"season": 1,
|
||||||
|
"episode": 1,
|
||||||
|
"absolute": 1
|
||||||
|
},
|
||||||
|
"tvdb": {
|
||||||
|
"season": 1,
|
||||||
|
"episode": 1,
|
||||||
|
"absolute": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"scene": {
|
||||||
|
"season": 1,
|
||||||
|
"episode": 2,
|
||||||
|
"absolute": 2
|
||||||
|
},
|
||||||
|
"tvdb": {
|
||||||
|
"season": 1,
|
||||||
|
"episode": 2,
|
||||||
|
"absolute": 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"message": "full mapping for 73388 on tvdb. this was a cached version"
|
||||||
|
|
||||||
|
}
|
@ -191,6 +191,8 @@
|
|||||||
<Compile Include="JobTests\AppUpdateJobFixture.cs" />
|
<Compile Include="JobTests\AppUpdateJobFixture.cs" />
|
||||||
<Compile Include="ProviderTests\UpdateProviderTests\GetUpdateLogFixture.cs" />
|
<Compile Include="ProviderTests\UpdateProviderTests\GetUpdateLogFixture.cs" />
|
||||||
<Compile Include="ProviderTests\UpdateProviderTests\GetAvilableUpdateFixture.cs" />
|
<Compile Include="ProviderTests\UpdateProviderTests\GetAvilableUpdateFixture.cs" />
|
||||||
|
<Compile Include="ProviderTests\XemCommunicationProviderTests\GetSceneTvdbMappingsFixture.cs" />
|
||||||
|
<Compile Include="ProviderTests\XemCommunicationProviderTests\GetXemSeriesIdsFixture.cs" />
|
||||||
<Compile Include="Services\ParseErrorServiceFixture.cs" />
|
<Compile Include="Services\ParseErrorServiceFixture.cs" />
|
||||||
<Compile Include="SortHelperTest.cs" />
|
<Compile Include="SortHelperTest.cs" />
|
||||||
<Compile Include="ProviderTests\EpisodeProviderTest_DeleteInvalidEpisodes.cs" />
|
<Compile Include="ProviderTests\EpisodeProviderTest_DeleteInvalidEpisodes.cs" />
|
||||||
@ -332,6 +334,15 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
<Content Include="Files\Xem\Failure.txt">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Include="Files\Xem\Ids.txt">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Include="Files\Xem\Mappings.txt">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="log.config">
|
<Content Include="log.config">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
@ -0,0 +1,77 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using FizzWare.NBuilder;
|
||||||
|
using FluentAssertions;
|
||||||
|
using Moq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using NzbDrone.Common;
|
||||||
|
using NzbDrone.Core.Model.Notification;
|
||||||
|
using NzbDrone.Core.Providers;
|
||||||
|
using NzbDrone.Core.Repository;
|
||||||
|
using NzbDrone.Core.Repository.Quality;
|
||||||
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
using NzbDrone.Test.Common.AutoMoq;
|
||||||
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Test.ProviderTests.XemCommunicationProviderTests
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
// ReSharper disable InconsistentNaming
|
||||||
|
public class GetSceneTvdbMappingsFixture : CoreTest
|
||||||
|
{
|
||||||
|
private void WithFailureJson()
|
||||||
|
{
|
||||||
|
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(It.IsAny<String>()))
|
||||||
|
.Returns(File.ReadAllText(@".\Files\Xem\Failure.txt"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void WithIdsJson()
|
||||||
|
{
|
||||||
|
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(It.IsAny<String>()))
|
||||||
|
.Returns(File.ReadAllText(@".\Files\Xem\Ids.txt"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void WithMappingsJson()
|
||||||
|
{
|
||||||
|
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(It.IsAny<String>()))
|
||||||
|
.Returns(File.ReadAllText(@".\Files\Xem\Mappings.txt"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_throw_when_failure_is_found()
|
||||||
|
{
|
||||||
|
WithFailureJson();
|
||||||
|
Assert.Throws<Exception>(() => Mocker.Resolve<XemCommunicationProvider>().GetSceneTvdbMappings(12345));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_get_list_of_mappings()
|
||||||
|
{
|
||||||
|
WithMappingsJson();
|
||||||
|
Mocker.Resolve<XemCommunicationProvider>().GetSceneTvdbMappings(12345).Should().NotBeEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_have_two_mappings()
|
||||||
|
{
|
||||||
|
WithMappingsJson();
|
||||||
|
Mocker.Resolve<XemCommunicationProvider>().GetSceneTvdbMappings(12345).Should().HaveCount(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_have_expected_results()
|
||||||
|
{
|
||||||
|
WithMappingsJson();
|
||||||
|
var results = Mocker.Resolve<XemCommunicationProvider>().GetSceneTvdbMappings(12345);
|
||||||
|
var first = results.First();
|
||||||
|
first.Scene.Absolute.Should().Be(1);
|
||||||
|
first.Scene.Season.Should().Be(1);
|
||||||
|
first.Scene.Episode.Should().Be(1);
|
||||||
|
first.Tvdb.Absolute.Should().Be(1);
|
||||||
|
first.Tvdb.Season.Should().Be(1);
|
||||||
|
first.Tvdb.Episode.Should().Be(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,63 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using FizzWare.NBuilder;
|
||||||
|
using FluentAssertions;
|
||||||
|
using Moq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using NzbDrone.Common;
|
||||||
|
using NzbDrone.Core.Model.Notification;
|
||||||
|
using NzbDrone.Core.Providers;
|
||||||
|
using NzbDrone.Core.Repository;
|
||||||
|
using NzbDrone.Core.Repository.Quality;
|
||||||
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
using NzbDrone.Test.Common.AutoMoq;
|
||||||
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Test.ProviderTests.XemCommunicationProviderTests
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
// ReSharper disable InconsistentNaming
|
||||||
|
public class GetXemSeriesIdsFixture : CoreTest
|
||||||
|
{
|
||||||
|
private void WithFailureJson()
|
||||||
|
{
|
||||||
|
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(It.IsAny<String>()))
|
||||||
|
.Returns(File.ReadAllText(@".\Files\Xem\Failure.txt"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void WithIdsJson()
|
||||||
|
{
|
||||||
|
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(It.IsAny<String>()))
|
||||||
|
.Returns(File.ReadAllText(@".\Files\Xem\Ids.txt"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void WithMappingsJson()
|
||||||
|
{
|
||||||
|
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(It.IsAny<String>()))
|
||||||
|
.Returns(File.ReadAllText(@".\Files\Xem\Mappings.txt"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_throw_when_failure_is_found()
|
||||||
|
{
|
||||||
|
WithFailureJson();
|
||||||
|
Assert.Throws<Exception>(() => Mocker.Resolve<XemCommunicationProvider>().GetXemSeriesIds());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_get_list_of_int()
|
||||||
|
{
|
||||||
|
WithIdsJson();
|
||||||
|
Mocker.Resolve<XemCommunicationProvider>().GetXemSeriesIds().Should().NotBeEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_have_two_ids()
|
||||||
|
{
|
||||||
|
WithIdsJson();
|
||||||
|
Mocker.Resolve<XemCommunicationProvider>().GetXemSeriesIds().Should().HaveCount(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
18
NzbDrone.Core/Datastore/Migrations/Migration20121016.cs
Normal file
18
NzbDrone.Core/Datastore/Migrations/Migration20121016.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Data;
|
||||||
|
using Migrator.Framework;
|
||||||
|
using NzbDrone.Common;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Datastore.Migrations
|
||||||
|
{
|
||||||
|
[Migration(20121016)]
|
||||||
|
public class Migration20121016 : NzbDroneMigration
|
||||||
|
{
|
||||||
|
protected override void MainDbUpgrade()
|
||||||
|
{
|
||||||
|
Database.AddColumn("Episodes", new Column("SceneAbsoluteEpisodeNumber", DbType.Int32, ColumnProperty.Null));
|
||||||
|
Database.AddColumn("Episodes", new Column("SceneSeasonNumber", DbType.Int32, ColumnProperty.Null));
|
||||||
|
Database.AddColumn("Episodes", new Column("SceneEpisodeNumber", DbType.Int32, ColumnProperty.Null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
14
NzbDrone.Core/Model/Xem/XemResult.cs
Normal file
14
NzbDrone.Core/Model/Xem/XemResult.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Model.Xem
|
||||||
|
{
|
||||||
|
public class XemResult<T>
|
||||||
|
{
|
||||||
|
public string Result { get; set; }
|
||||||
|
public T Data { get; set; }
|
||||||
|
public string Message { get; set; }
|
||||||
|
}
|
||||||
|
}
|
13
NzbDrone.Core/Model/Xem/XemSceneTvdbMapping.cs
Normal file
13
NzbDrone.Core/Model/Xem/XemSceneTvdbMapping.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Model.Xem
|
||||||
|
{
|
||||||
|
public class XemSceneTvdbMapping
|
||||||
|
{
|
||||||
|
public XemValues Scene { get; set; }
|
||||||
|
public XemValues Tvdb { get; set; }
|
||||||
|
}
|
||||||
|
}
|
14
NzbDrone.Core/Model/Xem/XemValues.cs
Normal file
14
NzbDrone.Core/Model/Xem/XemValues.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Model.Xem
|
||||||
|
{
|
||||||
|
public class XemValues
|
||||||
|
{
|
||||||
|
public int Season { get; set; }
|
||||||
|
public int Episode { get; set; }
|
||||||
|
public int Absolute { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -292,6 +292,9 @@
|
|||||||
<Compile Include="Model\Xbmc\TvShowResult.cs" />
|
<Compile Include="Model\Xbmc\TvShowResult.cs" />
|
||||||
<Compile Include="Model\Xbmc\ErrorResult.cs" />
|
<Compile Include="Model\Xbmc\ErrorResult.cs" />
|
||||||
<Compile Include="Model\Xbmc\IconType.cs" />
|
<Compile Include="Model\Xbmc\IconType.cs" />
|
||||||
|
<Compile Include="Model\Xem\XemResult.cs" />
|
||||||
|
<Compile Include="Model\Xem\XemSceneTvdbMapping.cs" />
|
||||||
|
<Compile Include="Model\Xem\XemValues.cs" />
|
||||||
<Compile Include="Providers\BannerProvider.cs" />
|
<Compile Include="Providers\BannerProvider.cs" />
|
||||||
<Compile Include="Providers\DecisionEngine\AllowedReleaseGroupSpecification.cs" />
|
<Compile Include="Providers\DecisionEngine\AllowedReleaseGroupSpecification.cs" />
|
||||||
<Compile Include="Providers\DecisionEngine\CustomStartDateSpecification.cs" />
|
<Compile Include="Providers\DecisionEngine\CustomStartDateSpecification.cs" />
|
||||||
@ -330,6 +333,7 @@
|
|||||||
<Compile Include="Jobs\RssSyncJob.cs" />
|
<Compile Include="Jobs\RssSyncJob.cs" />
|
||||||
<Compile Include="Jobs\UpdateInfoJob.cs" />
|
<Compile Include="Jobs\UpdateInfoJob.cs" />
|
||||||
<Compile Include="Providers\StatsProvider.cs" />
|
<Compile Include="Providers\StatsProvider.cs" />
|
||||||
|
<Compile Include="Providers\XemCommunicationProvider.cs" />
|
||||||
<Compile Include="Repository\MetadataDefinition.cs" />
|
<Compile Include="Repository\MetadataDefinition.cs" />
|
||||||
<Compile Include="Repository\Search\SearchHistoryItem.cs" />
|
<Compile Include="Repository\Search\SearchHistoryItem.cs" />
|
||||||
<Compile Include="Repository\Search\SearchHistory.cs" />
|
<Compile Include="Repository\Search\SearchHistory.cs" />
|
||||||
|
@ -331,7 +331,7 @@ namespace NzbDrone.Core.Providers
|
|||||||
episodeToUpdate.TvDbEpisodeId = episode.Id;
|
episodeToUpdate.TvDbEpisodeId = episode.Id;
|
||||||
episodeToUpdate.EpisodeNumber = episode.EpisodeNumber;
|
episodeToUpdate.EpisodeNumber = episode.EpisodeNumber;
|
||||||
episodeToUpdate.SeasonNumber = episode.SeasonNumber;
|
episodeToUpdate.SeasonNumber = episode.SeasonNumber;
|
||||||
episodeToUpdate.AbsoluteEpisodeNumber = episode.AbsoluteEpisodeNumber;
|
episodeToUpdate.AbsoluteEpisodeNumber = episode.AbsoluteNumber;
|
||||||
episodeToUpdate.Title = episode.EpisodeName;
|
episodeToUpdate.Title = episode.EpisodeName;
|
||||||
|
|
||||||
episodeToUpdate.Overview = episode.Overview.Truncate(3500);
|
episodeToUpdate.Overview = episode.Overview.Truncate(3500);
|
||||||
@ -435,5 +435,10 @@ namespace NzbDrone.Core.Providers
|
|||||||
logger.Trace("Updating PostDownloadStatus for all episodeIds in {0}", episodeIdString);
|
logger.Trace("Updating PostDownloadStatus for all episodeIds in {0}", episodeIdString);
|
||||||
_database.Execute(episodeIdQuery);
|
_database.Execute(episodeIdQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual void UpdateEpisodes(List<Episode> episodes)
|
||||||
|
{
|
||||||
|
_database.UpdateMany(episodes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} |