diff --git a/NzbDrone.Common/NzbDrone.Common.csproj b/NzbDrone.Common/NzbDrone.Common.csproj
index 42d7d0903..c1b17236f 100644
--- a/NzbDrone.Common/NzbDrone.Common.csproj
+++ b/NzbDrone.Common/NzbDrone.Common.csproj
@@ -93,6 +93,7 @@
+
diff --git a/NzbDrone.Common/Serializer/Json.cs b/NzbDrone.Common/Serializer/Json.cs
index 59c58946a..866776ec9 100644
--- a/NzbDrone.Common/Serializer/Json.cs
+++ b/NzbDrone.Common/Serializer/Json.cs
@@ -40,7 +40,6 @@ public static string ToJson(this object obj)
return JsonConvert.SerializeObject(obj);
}
-
public static void Serialize(TModel model, TextWriter outputStream)
{
var jsonTextWriter = new JsonTextWriter(outputStream);
@@ -52,7 +51,5 @@ public static void Serialize(TModel model, Stream outputStream)
{
Serialize(model, new StreamWriter(outputStream));
}
-
-
}
}
\ No newline at end of file
diff --git a/NzbDrone.Common/Services.cs b/NzbDrone.Common/Services.cs
new file mode 100644
index 000000000..bfa537901
--- /dev/null
+++ b/NzbDrone.Common/Services.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace NzbDrone.Common
+{
+ public class Services
+ {
+ public static String RootUrl
+ {
+ get
+ {
+ return "http://services.nzbdrone.com";
+ }
+ }
+ }
+}
diff --git a/NzbDrone.Core.Test/DataAugmentationFixture/Scene/SceneMappingProxyFixture.cs b/NzbDrone.Core.Test/DataAugmentationFixture/Scene/SceneMappingProxyFixture.cs
index 64c5cbc79..98ad8b504 100644
--- a/NzbDrone.Core.Test/DataAugmentationFixture/Scene/SceneMappingProxyFixture.cs
+++ b/NzbDrone.Core.Test/DataAugmentationFixture/Scene/SceneMappingProxyFixture.cs
@@ -15,14 +15,6 @@ public class SceneMappingProxyFixture : CoreTest
{
private const string SCENE_MAPPING_URL = "http://services.nzbdrone.com/SceneMapping/Active";
- [SetUp]
- public void Setup()
- {
- Mocker.GetMock().SetupGet(s => s.ServiceRootUrl)
- .Returns("http://services.nzbdrone.com");
-
- }
-
[Test]
public void fetch_should_return_list_of_mappings()
{
diff --git a/NzbDrone.Core.Test/UpdateTests/UpdatePackageProviderFixture.cs b/NzbDrone.Core.Test/UpdateTests/UpdatePackageProviderFixture.cs
index bbf0c5b9c..138e3b404 100644
--- a/NzbDrone.Core.Test/UpdateTests/UpdatePackageProviderFixture.cs
+++ b/NzbDrone.Core.Test/UpdateTests/UpdatePackageProviderFixture.cs
@@ -16,13 +16,7 @@ public void should_get_list_of_available_updates()
Mocker.GetMock().SetupGet(c => c.Branch).Returns("master");
- var updates = Subject.GetAvailablePackages().ToList();
-
- updates.Should().NotBeEmpty();
- updates.Should().OnlyContain(c => !string.IsNullOrWhiteSpace(c.FileName));
- updates.Should().OnlyContain(c => !string.IsNullOrWhiteSpace(c.Url));
- updates.Should().OnlyContain(c => c.Version != null);
- updates.Should().OnlyContain(c => c.Version.Major == 2);
+ Subject.GetLatestUpdate().Should().BeNull();
}
}
}
diff --git a/NzbDrone.Core/Configuration/ConfigService.cs b/NzbDrone.Core/Configuration/ConfigService.cs
index 0d9189fc6..e3ca0317b 100644
--- a/NzbDrone.Core/Configuration/ConfigService.cs
+++ b/NzbDrone.Core/Configuration/ConfigService.cs
@@ -172,11 +172,6 @@ public string BlackholeFolder
set { SetValue("BlackholeFolder", value); }
}
- public string ServiceRootUrl
- {
- get { return "http://services.nzbdrone.com"; }
- }
-
public string PneumaticFolder
{
get { return GetValue("PneumaticFolder", String.Empty); }
diff --git a/NzbDrone.Core/Configuration/IConfigService.cs b/NzbDrone.Core/Configuration/IConfigService.cs
index 07e70d25b..d84ed272b 100644
--- a/NzbDrone.Core/Configuration/IConfigService.cs
+++ b/NzbDrone.Core/Configuration/IConfigService.cs
@@ -25,7 +25,6 @@ public interface IConfigService
int Retention { get; set; }
DownloadClientType DownloadClient { get; set; }
string BlackholeFolder { get; set; }
- string ServiceRootUrl { get; }
string PneumaticFolder { get; set; }
string RecycleBin { get; set; }
String NzbgetUsername { get; set; }
diff --git a/NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesDataProxy.cs b/NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesDataProxy.cs
index fc2a591a2..239afecc8 100644
--- a/NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesDataProxy.cs
+++ b/NzbDrone.Core/DataAugmentation/DailySeries/DailySeriesDataProxy.cs
@@ -17,13 +17,11 @@ public interface IDailySeriesDataProxy
public class DailySeriesDataProxy : IDailySeriesDataProxy
{
private readonly IHttpProvider _httpProvider;
- private readonly IConfigService _configService;
private readonly Logger _logger;
- public DailySeriesDataProxy(IHttpProvider httpProvider, IConfigService configService, Logger logger)
+ public DailySeriesDataProxy(IHttpProvider httpProvider, Logger logger)
{
_httpProvider = httpProvider;
- _configService = configService;
_logger = logger;
}
@@ -31,7 +29,7 @@ public IEnumerable GetDailySeriesIds()
{
try
{
- var dailySeriesIds = _httpProvider.DownloadString(_configService.ServiceRootUrl + "/DailySeries/AllIds");
+ var dailySeriesIds = _httpProvider.DownloadString(Services.RootUrl + "/DailySeries/AllIds");
var seriesIds = Json.Deserialize>(dailySeriesIds);
@@ -49,7 +47,7 @@ public bool IsDailySeries(int tvdbid)
{
try
{
- var result = _httpProvider.DownloadString(_configService.ServiceRootUrl + "/DailySeries/Check?seriesId=" + tvdbid);
+ var result = _httpProvider.DownloadString(Services.RootUrl + "/DailySeries/Check?seriesId=" + tvdbid);
return Convert.ToBoolean(result);
}
catch (Exception ex)
diff --git a/NzbDrone.Core/DataAugmentation/Scene/SceneMappingProxy.cs b/NzbDrone.Core/DataAugmentation/Scene/SceneMappingProxy.cs
index c38cb4a58..2447a96ec 100644
--- a/NzbDrone.Core/DataAugmentation/Scene/SceneMappingProxy.cs
+++ b/NzbDrone.Core/DataAugmentation/Scene/SceneMappingProxy.cs
@@ -13,19 +13,15 @@ public interface ISceneMappingProxy
public class SceneMappingProxy : ISceneMappingProxy
{
private readonly IHttpProvider _httpProvider;
- private readonly IConfigService _configService;
-
- public SceneMappingProxy(IHttpProvider httpProvider, IConfigService configService)
+ public SceneMappingProxy(IHttpProvider httpProvider)
{
_httpProvider = httpProvider;
- _configService = configService;
-
}
public List Fetch()
{
- var mappingsJson = _httpProvider.DownloadString(_configService.ServiceRootUrl + "/SceneMapping/Active");
+ var mappingsJson = _httpProvider.DownloadString(Services.RootUrl + "/SceneMapping/Active");
return Json.Deserialize>(mappingsJson);
}
}
diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj
index 7adf989f7..9234720af 100644
--- a/NzbDrone.Core/NzbDrone.Core.csproj
+++ b/NzbDrone.Core/NzbDrone.Core.csproj
@@ -492,6 +492,7 @@
+
diff --git a/NzbDrone.Core/Update/UpdateCheckService.cs b/NzbDrone.Core/Update/UpdateCheckService.cs
index 36d43ea44..313f1ef58 100644
--- a/NzbDrone.Core/Update/UpdateCheckService.cs
+++ b/NzbDrone.Core/Update/UpdateCheckService.cs
@@ -26,7 +26,7 @@ public UpdatePackage AvailableUpdate()
{
var latestAvailable = _updatePackageProvider.GetLatestUpdate();
- if (latestAvailable == null || latestAvailable.Version <= BuildInfo.Version)
+ if (latestAvailable == null)
{
_logger.Debug("No update available.");
return null;
diff --git a/NzbDrone.Core/Update/UpdatePackage.cs b/NzbDrone.Core/Update/UpdatePackage.cs
index e600e2a83..ce038ac99 100644
--- a/NzbDrone.Core/Update/UpdatePackage.cs
+++ b/NzbDrone.Core/Update/UpdatePackage.cs
@@ -1,11 +1,18 @@
using System;
+using Newtonsoft.Json;
namespace NzbDrone.Core.Update
{
public class UpdatePackage
{
- public string Url { get; set; }
- public string FileName { get; set; }
+ public String Id { get; set; }
+
+ [JsonConverter(typeof(Newtonsoft.Json.Converters.VersionConverter))]
public Version Version { get; set; }
+
+ public String Branch { get; set; }
+ public DateTime ReleaseDate { get; set; }
+ public String FileName { get; set; }
+ public String Url { get; set; }
}
}
diff --git a/NzbDrone.Core/Update/UpdatePackageAvailable.cs b/NzbDrone.Core/Update/UpdatePackageAvailable.cs
new file mode 100644
index 000000000..1d76e22d7
--- /dev/null
+++ b/NzbDrone.Core/Update/UpdatePackageAvailable.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace NzbDrone.Core.Update
+{
+ public class UpdatePackageAvailable
+ {
+ public Boolean Available { get; set; }
+ public UpdatePackage UpdatePackage { get; set; }
+ }
+}
diff --git a/NzbDrone.Core/Update/UpdatePackageProvider.cs b/NzbDrone.Core/Update/UpdatePackageProvider.cs
index f85dc6e66..2456b5511 100644
--- a/NzbDrone.Core/Update/UpdatePackageProvider.cs
+++ b/NzbDrone.Core/Update/UpdatePackageProvider.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
+using Newtonsoft.Json;
using NLog;
using NzbDrone.Common;
using NzbDrone.Common.EnvironmentInfo;
@@ -11,56 +12,30 @@ namespace NzbDrone.Core.Update
{
public interface IUpdatePackageProvider
{
- IEnumerable GetAvailablePackages();
UpdatePackage GetLatestUpdate();
}
public class UpdatePackageProvider : IUpdatePackageProvider
{
- private readonly IConfigFileProvider _configService;
+ private readonly IConfigFileProvider _configFileProvider;
private readonly IHttpProvider _httpProvider;
private readonly Logger _logger;
- private static readonly Regex ParseRegex = new Regex(@"(?:\>)(?NzbDrone.+?(?(?<=\.)\d+\.\d+\.\d+\.\d+).+?)(?:\<\/a\>)",
- RegexOptions.IgnoreCase);
-
- public UpdatePackageProvider(IConfigFileProvider configService, IHttpProvider httpProvider, Logger logger)
+ public UpdatePackageProvider(IConfigFileProvider configFileProvider, IHttpProvider httpProvider, Logger logger)
{
- _configService = configService;
+ _configFileProvider = configFileProvider;
_httpProvider = httpProvider;
_logger = logger;
}
- public IEnumerable GetAvailablePackages()
- {
- var updateList = new List();
-
- var branch = _configService.Branch;
- var version = BuildInfo.Version;
- var updateUrl = String.Format("http://update.nzbdrone.com/v{0}/{1}/", version.Major, branch);
-
- _logger.Debug("Getting a list of updates from {0}", updateUrl);
-
- var rawUpdateList = _httpProvider.DownloadString(updateUrl);
- var matches = ParseRegex.Matches(rawUpdateList);
-
- foreach (Match match in matches)
- {
- var updatePackage = new UpdatePackage();
- updatePackage.FileName = match.Groups["filename"].Value;
- updatePackage.Url = updateUrl + updatePackage.FileName;
- updatePackage.Version = new Version(match.Groups["version"].Value);
- updateList.Add(updatePackage);
- }
-
- _logger.Debug("Found {0} update packages", updateUrl.Length);
-
- return updateList;
- }
-
public UpdatePackage GetLatestUpdate()
{
- return GetAvailablePackages().OrderByDescending(c => c.Version).FirstOrDefault();
+ var url = String.Format("{0}/v1/update/{1}?{2}", Services.RootUrl, _configFileProvider.Branch, BuildInfo.Version);
+ var update = JsonConvert.DeserializeObject(_httpProvider.DownloadString(url));
+
+ if (!update.Available) return null;
+
+ return update.UpdatePackage;
}
}
}
\ No newline at end of file