diff --git a/NzbDrone.Core.Test/Files/SceneMappings.csv b/NzbDrone.Core.Test/Files/SceneMappings.csv
deleted file mode 100644
index 4238b2ebb..000000000
--- a/NzbDrone.Core.Test/Files/SceneMappings.csv
+++ /dev/null
@@ -1,5 +0,0 @@
-csinewyork,73696,CSI
-csiny,73696,CSI
-csi,72546,CSI
-csilasvegas,72546,CSI
-archer,110381,Archer
\ No newline at end of file
diff --git a/NzbDrone.Core.Test/Files/SceneMappings.json b/NzbDrone.Core.Test/Files/SceneMappings.json
new file mode 100644
index 000000000..a914ecdc9
--- /dev/null
+++ b/NzbDrone.Core.Test/Files/SceneMappings.json
@@ -0,0 +1,27 @@
+[
+ {
+ "CleanTitle": "csinewyork",
+ "Id": "73696",
+ "Title": "CSI"
+ },
+ {
+ "CleanTitle": "csiny",
+ "Id": "73696",
+ "Title": "CSI"
+ },
+ {
+ "CleanTitle": "csi",
+ "Id": "72546",
+ "Title": "CSI"
+ },
+ {
+ "CleanTitle": "csilasvegas",
+ "Id": "72546",
+ "Title": "CSI"
+ },
+ {
+ "CleanTitle": "archer",
+ "Id": "110381",
+ "Title": "Archer"
+ }
+]
\ No newline at end of file
diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
index db25df83f..24241cdaf 100644
--- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
+++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
@@ -235,7 +235,7 @@
Designer
Always
-
+
Always
diff --git a/NzbDrone.Core.Test/ProviderTests/SceneMappingProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/SceneMappingProviderTest.cs
index a400776ba..9a9a37160 100644
--- a/NzbDrone.Core.Test/ProviderTests/SceneMappingProviderTest.cs
+++ b/NzbDrone.Core.Test/ProviderTests/SceneMappingProviderTest.cs
@@ -17,16 +17,16 @@ namespace NzbDrone.Core.Test.ProviderTests
// ReSharper disable InconsistentNaming
public class SceneMappingProviderTest : CoreTest
{
- private const string SceneMappingUrl = "http://www.nzbdrone.com/SceneMappings.csv";
+ private const string SceneMappingUrl = "http://services.nzbdrone.com/SceneMapping/Active";
- private void WithValidCsv()
+ private void WithValidJson()
{
Mocker.GetMock()
.Setup(s => s.DownloadString(SceneMappingUrl))
- .Returns(File.ReadAllText(@".\Files\SceneMappings.csv"));
+ .Returns(File.ReadAllText(@".\Files\SceneMappings.json"));
}
- private void WithErrorDownloadingCsv()
+ private void WithErrorDownloadingJson()
{
Mocker.GetMock()
.Setup(s => s.DownloadString(SceneMappingUrl))
@@ -163,13 +163,13 @@ namespace NzbDrone.Core.Test.ProviderTests
{
//Setup
WithRealDb();
- WithValidCsv();
+ WithValidJson();
//Act
Mocker.Resolve().UpdateMappings();
//Assert
- Mocker.Verify(v => v.DownloadString(It.IsAny()), Times.Once());
+ Mocker.Verify(v => v.DownloadString(SceneMappingUrl), Times.Once());
var result = Db.Fetch();
result.Should().HaveCount(5);
}
@@ -185,14 +185,14 @@ namespace NzbDrone.Core.Test.ProviderTests
.Build();
WithRealDb();
- WithValidCsv();
+ WithValidJson();
Db.Insert(fakeMap);
//Act
Mocker.Resolve().UpdateMappings();
//Assert
- Mocker.Verify(v => v.DownloadString(It.IsAny()), Times.Once());
+ Mocker.Verify(v => v.DownloadString(SceneMappingUrl), Times.Once());
var result = Db.Fetch();
result.Should().HaveCount(5);
}
@@ -208,14 +208,14 @@ namespace NzbDrone.Core.Test.ProviderTests
.Build();
WithRealDb();
- WithErrorDownloadingCsv();
+ WithErrorDownloadingJson();
Db.Insert(fakeMap);
//Act
Mocker.Resolve().UpdateMappings();
//Assert
- Mocker.Verify(v => v.DownloadString(It.IsAny()), Times.Once());
+ Mocker.Verify(v => v.DownloadString(SceneMappingUrl), Times.Once());
var result = Db.Fetch();
result.Should().HaveCount(1);
}
@@ -237,7 +237,7 @@ namespace NzbDrone.Core.Test.ProviderTests
Mocker.Resolve().UpdateIfEmpty();
//Assert
- Mocker.Verify(v => v.DownloadString(It.IsAny()), Times.Never());
+ Mocker.Verify(v => v.DownloadString(SceneMappingUrl), Times.Never());
}
[Test]
@@ -245,7 +245,7 @@ namespace NzbDrone.Core.Test.ProviderTests
{
//Setup
WithRealDb();
- WithValidCsv();
+ WithValidJson();
//Act
Mocker.Resolve().UpdateIfEmpty();
diff --git a/NzbDrone.Core/Providers/SceneMappingProvider.cs b/NzbDrone.Core/Providers/SceneMappingProvider.cs
index 313d0c6b5..82ca68809 100644
--- a/NzbDrone.Core/Providers/SceneMappingProvider.cs
+++ b/NzbDrone.Core/Providers/SceneMappingProvider.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using NLog;
+using Newtonsoft.Json;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using PetaPoco;
@@ -29,32 +30,16 @@ namespace NzbDrone.Core.Providers
{
try
{
- var mapping = _httpProvider.DownloadString("http://www.nzbdrone.com/SceneMappings.csv");
- var newMaps = new List();
-
- using (var reader = new StringReader(mapping))
- {
- string line;
- while ((line = reader.ReadLine()) != null)
- {
- var split = line.Split(',');
- int seriesId;
- Int32.TryParse(split[1], out seriesId);
-
- var map = new SceneMapping();
- map.CleanTitle = split[0];
- map.SeriesId = seriesId;
- map.SceneName = split[2];
-
- newMaps.Add(map);
- }
- }
+ const string url = "http://services.nzbdrone.com/SceneMapping/Active";
+
+ var mappingsJson = _httpProvider.DownloadString(url);
+ var mappings = JsonConvert.DeserializeObject>(mappingsJson);
Logger.Debug("Deleting all existing Scene Mappings.");
_database.Delete(String.Empty);
Logger.Debug("Adding Scene Mappings");
- _database.InsertMany(newMaps);
+ _database.InsertMany(mappings);
}
catch (Exception ex)
diff --git a/NzbDrone.Core/Repository/SceneMapping.cs b/NzbDrone.Core/Repository/SceneMapping.cs
index 5cec317c2..73bf07705 100644
--- a/NzbDrone.Core/Repository/SceneMapping.cs
+++ b/NzbDrone.Core/Repository/SceneMapping.cs
@@ -1,4 +1,5 @@
-using PetaPoco;
+using Newtonsoft.Json;
+using PetaPoco;
namespace NzbDrone.Core.Repository
{
@@ -8,8 +9,10 @@ namespace NzbDrone.Core.Repository
{
public string CleanTitle { get; set; }
+ [JsonProperty(PropertyName = "Id")]
public int SeriesId { get; set; }
+ [JsonProperty(PropertyName = "Title")]
public string SceneName { get; set; }
}
}
\ No newline at end of file