Misc Sonarr Pulls

pull/94/head
Qstick 7 years ago
parent 4c916f9186
commit f8f988a083

@ -20,7 +20,7 @@ namespace NzbDrone.Core.Test.IndexerTests.IPTorrentsTests
Subject.Definition = new IndexerDefinition() Subject.Definition = new IndexerDefinition()
{ {
Name = "IPTorrents", Name = "IPTorrents",
Settings = new IPTorrentsSettings() { Url = "http://fake.com/" } Settings = new IPTorrentsSettings() { BaseUrl = "http://fake.com/" }
}; };
} }

@ -21,7 +21,7 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
{ {
_settings = new NewznabSettings() _settings = new NewznabSettings()
{ {
Url = "http://indxer.local" BaseUrl = "http://indxer.local"
}; };
_caps = ReadAllText("Files/Indexers/Newznab/newznab_caps.xml"); _caps = ReadAllText("Files/Indexers/Newznab/newznab_caps.xml");

@ -26,7 +26,7 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
Name = "Newznab", Name = "Newznab",
Settings = new NewznabSettings() Settings = new NewznabSettings()
{ {
Url = "http://indexer.local/", BaseUrl = "http://indexer.local/",
Categories = new int[] { 1 } Categories = new int[] { 1 }
} }
}; };

@ -19,7 +19,7 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
{ {
Subject.Settings = new NewznabSettings() Subject.Settings = new NewznabSettings()
{ {
Url = "http://127.0.0.1:1234/", BaseUrl = "http://127.0.0.1:1234/",
Categories = new [] { 1, 2 }, Categories = new [] { 1, 2 },
ApiKey = "abcd", ApiKey = "abcd",
}; };

@ -15,7 +15,7 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
var setting = new NewznabSettings() var setting = new NewznabSettings()
{ {
ApiKey = "", ApiKey = "",
Url = url BaseUrl = url
}; };
@ -32,7 +32,7 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
var setting = new NewznabSettings var setting = new NewznabSettings
{ {
ApiKey = "", ApiKey = "",
Url = url BaseUrl = url
}; };
@ -49,7 +49,7 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
var setting = new NewznabSettings() var setting = new NewznabSettings()
{ {
ApiKey = "", ApiKey = "",
Url = url BaseUrl = url
}; };

@ -1,14 +1,17 @@
using System; using System;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.ThingiProvider; using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation; using NzbDrone.Core.Validation;
namespace NzbDrone.Core.Test.IndexerTests namespace NzbDrone.Core.Test.IndexerTests
{ {
public class TestIndexerSettings : IProviderConfig public class TestIndexerSettings : IIndexerSettings
{ {
public NzbDroneValidationResult Validate() public NzbDroneValidationResult Validate()
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public string BaseUrl { get; set; }
} }
} }

@ -1,4 +1,4 @@
using System; using System;
using System.Linq; using System.Linq;
using FluentAssertions; using FluentAssertions;
using Moq; using Moq;
@ -25,7 +25,7 @@ namespace NzbDrone.Core.Test.IndexerTests.TorznabTests
Name = "Torznab", Name = "Torznab",
Settings = new TorznabSettings() Settings = new TorznabSettings()
{ {
Url = "http://indexer.local/", BaseUrl = "http://indexer.local/",
Categories = new int[] { 1 } Categories = new int[] { 1 }
} }
}; };
@ -44,7 +44,7 @@ namespace NzbDrone.Core.Test.IndexerTests.TorznabTests
Mocker.GetMock<IHttpClient>() Mocker.GetMock<IHttpClient>()
.Setup(o => o.Execute(It.Is<HttpRequest>(v => v.Method == HttpMethod.GET))) .Setup(o => o.Execute(It.Is<HttpRequest>(v => v.Method == HttpMethod.GET)))
.Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), recentFeed)); .Returns<HttpRequest>(r => new HttpResponse(r, new HttpHeader(), recentFeed));
var releases = Subject.FetchRecent(); var releases = Subject.FetchRecent();
releases.Should().HaveCount(5); releases.Should().HaveCount(5);

@ -1,6 +1,7 @@
using FluentAssertions; using FluentAssertions;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Core.Parser; using NzbDrone.Core.Parser;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.ParserTests namespace NzbDrone.Core.Test.ParserTests
@ -63,6 +64,14 @@ namespace NzbDrone.Core.Test.ParserTests
Parser.Parser.ParseTitle(postTitle).SeriesTitle.Should().Be(title); Parser.Parser.ParseTitle(postTitle).SeriesTitle.Should().Be(title);
} }
[TestCase("Revolution.S01E02.Chained.Heat.mkv")]
[TestCase("Dexter - S01E01 - Title.avi")]
public void should_parse_quality_from_extension(string title)
{
Parser.Parser.ParseTitle(title).Quality.Quality.Should().NotBe(Quality.Unknown);
Parser.Parser.ParseTitle(title).Quality.QualitySource.Should().Be(QualitySource.Extension);
}
[TestCase("VA - The Best 101 Love Ballads (2017) MP3 [192 kbps]", "The Best 101 Love Ballads")] [TestCase("VA - The Best 101 Love Ballads (2017) MP3 [192 kbps]", "The Best 101 Love Ballads")]
[TestCase("ATCQ - The Love Movement 1998 2CD 192kbps RIP", "The Love Movement")] [TestCase("ATCQ - The Love Movement 1998 2CD 192kbps RIP", "The Love Movement")]
[TestCase("A Tribe Called Quest - The Love Movement 1998 2CD [192kbps] RIP", "The Love Movement")] [TestCase("A Tribe Called Quest - The Love Movement 1998 2CD [192kbps] RIP", "The Love Movement")]

@ -0,0 +1,58 @@
using System.Collections.Generic;
using System.Data;
using FluentMigrator;
using Newtonsoft.Json.Linq;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Serializer;
using NzbDrone.Core.Datastore.Migration.Framework;
namespace NzbDrone.Core.Datastore.Migration
{
[Migration(122)]
public class consolidate_indexer_baseurl : NzbDroneMigrationBase
{
protected override void MainDbUpgrade()
{
Execute.WithConnection(RenameUrlToBaseUrl);
}
private void RenameUrlToBaseUrl(IDbConnection conn, IDbTransaction tran)
{
using (var cmd = conn.CreateCommand())
{
cmd.Transaction = tran;
cmd.CommandText = "SELECT Id, Settings FROM Indexers WHERE ConfigContract IN ('NewznabSettings', 'TorznabSettings', 'IPTorrentsSettings', 'OmgwtfnzbsSettings')";
using (var reader = cmd.ExecuteReader())
{
while (reader.Read())
{
var id = reader.GetInt32(0);
var settings = reader.GetString(1);
if (settings.IsNotNullOrWhiteSpace())
{
var jsonObject = Json.Deserialize<JObject>(settings);
if (jsonObject.Property("url") != null)
{
jsonObject.AddFirst(new JProperty("baseUrl", jsonObject["url"]));
jsonObject.Remove("url");
settings = jsonObject.ToJson();
using (var updateCmd = conn.CreateCommand())
{
updateCmd.Transaction = tran;
updateCmd.CommandText = "UPDATE Indexers SET Settings = ? WHERE Id = ?";
updateCmd.AddParameter(settings);
updateCmd.AddParameter(id);
updateCmd.ExecuteNonQuery();
}
}
}
}
}
}
}
}
}

@ -119,9 +119,9 @@ namespace NzbDrone.Core.Download.Clients.Blackhole
DeleteItemData(downloadId); DeleteItemData(downloadId);
} }
public override DownloadClientStatus GetStatus() public override DownloadClientInfo GetStatus()
{ {
return new DownloadClientStatus return new DownloadClientInfo
{ {
IsLocalhost = true, IsLocalhost = true,
OutputRootFolders = new List<OsPath> { new OsPath(Settings.WatchFolder) } OutputRootFolders = new List<OsPath> { new OsPath(Settings.WatchFolder) }

@ -86,9 +86,9 @@ namespace NzbDrone.Core.Download.Clients.Blackhole
DeleteItemData(downloadId); DeleteItemData(downloadId);
} }
public override DownloadClientStatus GetStatus() public override DownloadClientInfo GetStatus()
{ {
return new DownloadClientStatus return new DownloadClientInfo
{ {
IsLocalhost = true, IsLocalhost = true,
OutputRootFolders = new List<OsPath> { new OsPath(Settings.WatchFolder) } OutputRootFolders = new List<OsPath> { new OsPath(Settings.WatchFolder) }

@ -151,7 +151,7 @@ namespace NzbDrone.Core.Download.Clients.Deluge
_proxy.RemoveTorrent(downloadId.ToLower(), deleteData, Settings); _proxy.RemoveTorrent(downloadId.ToLower(), deleteData, Settings);
} }
public override DownloadClientStatus GetStatus() public override DownloadClientInfo GetStatus()
{ {
var config = _proxy.GetConfig(Settings); var config = _proxy.GetConfig(Settings);
@ -162,7 +162,7 @@ namespace NzbDrone.Core.Download.Clients.Deluge
destDir = new OsPath(config.GetValueOrDefault("move_completed_path") as string); destDir = new OsPath(config.GetValueOrDefault("move_completed_path") as string);
} }
var status = new DownloadClientStatus var status = new DownloadClientInfo
{ {
IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost" IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost"
}; };

@ -105,13 +105,13 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
return items; return items;
} }
public override DownloadClientStatus GetStatus() public override DownloadClientInfo GetStatus()
{ {
try try
{ {
var path = GetDownloadDirectory(); var path = GetDownloadDirectory();
return new DownloadClientStatus return new DownloadClientInfo
{ {
IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost", IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost",
OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(path)) } OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(path)) }

@ -130,13 +130,13 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
return finalPath; return finalPath;
} }
public override DownloadClientStatus GetStatus() public override DownloadClientInfo GetStatus()
{ {
try try
{ {
var path = GetDownloadDirectory(); var path = GetDownloadDirectory();
return new DownloadClientStatus return new DownloadClientInfo
{ {
IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost", IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost",
OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(path)) } OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(path)) }

@ -117,12 +117,12 @@ namespace NzbDrone.Core.Download.Clients.Hadouken
} }
} }
public override DownloadClientStatus GetStatus() public override DownloadClientInfo GetStatus()
{ {
var config = _proxy.GetConfig(Settings); var config = _proxy.GetConfig(Settings);
var destDir = new OsPath(config.GetValueOrDefault("bittorrent.defaultSavePath") as string); var destDir = new OsPath(config.GetValueOrDefault("bittorrent.defaultSavePath") as string);
var status = new DownloadClientStatus var status = new DownloadClientInfo
{ {
IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost" IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost"
}; };

@ -143,9 +143,9 @@ namespace NzbDrone.Core.Download.Clients.NzbVortex
return _proxy.GetGroups(Settings); return _proxy.GetGroups(Settings);
} }
public override DownloadClientStatus GetStatus() public override DownloadClientInfo GetStatus()
{ {
var status = new DownloadClientStatus var status = new DownloadClientInfo
{ {
IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost" IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost"
}; };

@ -214,13 +214,13 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
_proxy.RemoveItem(downloadId, Settings); _proxy.RemoveItem(downloadId, Settings);
} }
public override DownloadClientStatus GetStatus() public override DownloadClientInfo GetStatus()
{ {
var config = _proxy.GetConfig(Settings); var config = _proxy.GetConfig(Settings);
var category = GetCategories(config).FirstOrDefault(v => v.Name == Settings.TvCategory); var category = GetCategories(config).FirstOrDefault(v => v.Name == Settings.TvCategory);
var status = new DownloadClientStatus var status = new DownloadClientInfo
{ {
IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost" IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost"
}; };

@ -98,9 +98,9 @@ namespace NzbDrone.Core.Download.Clients.Pneumatic
throw new NotSupportedException(); throw new NotSupportedException();
} }
public override DownloadClientStatus GetStatus() public override DownloadClientInfo GetStatus()
{ {
var status = new DownloadClientStatus var status = new DownloadClientInfo
{ {
IsLocalhost = true IsLocalhost = true
}; };

@ -174,13 +174,13 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
_proxy.RemoveTorrent(hash.ToLower(), deleteData, Settings); _proxy.RemoveTorrent(hash.ToLower(), deleteData, Settings);
} }
public override DownloadClientStatus GetStatus() public override DownloadClientInfo GetStatus()
{ {
var config = _proxy.GetConfig(Settings); var config = _proxy.GetConfig(Settings);
var destDir = new OsPath(config.SavePath); var destDir = new OsPath(config.SavePath);
return new DownloadClientStatus return new DownloadClientInfo
{ {
IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost", IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost",
OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, destDir) } OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, destDir) }

@ -249,7 +249,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
} }
} }
public override DownloadClientStatus GetStatus() public override DownloadClientInfo GetStatus()
{ {
var config = _proxy.GetConfig(Settings); var config = _proxy.GetConfig(Settings);
var categories = GetCategories(config).ToArray(); var categories = GetCategories(config).ToArray();
@ -261,7 +261,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
category = categories.FirstOrDefault(v => v.Name == "*"); category = categories.FirstOrDefault(v => v.Name == "*");
} }
var status = new DownloadClientStatus var status = new DownloadClientInfo
{ {
IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost" IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost"
}; };

@ -119,7 +119,7 @@ namespace NzbDrone.Core.Download.Clients.Transmission
_proxy.RemoveTorrent(downloadId.ToLower(), deleteData, Settings); _proxy.RemoveTorrent(downloadId.ToLower(), deleteData, Settings);
} }
public override DownloadClientStatus GetStatus() public override DownloadClientInfo GetStatus()
{ {
var config = _proxy.GetConfig(Settings); var config = _proxy.GetConfig(Settings);
var destDir = config.GetValueOrDefault("download-dir") as string; var destDir = config.GetValueOrDefault("download-dir") as string;
@ -129,7 +129,7 @@ namespace NzbDrone.Core.Download.Clients.Transmission
destDir = string.Format("{0}/.{1}", destDir, Settings.TvCategory); destDir = string.Format("{0}/.{1}", destDir, Settings.TvCategory);
} }
return new DownloadClientStatus return new DownloadClientInfo
{ {
IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost", IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost",
OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(destDir)) } OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(destDir)) }

@ -156,11 +156,11 @@ namespace NzbDrone.Core.Download.Clients.RTorrent
_proxy.RemoveTorrent(downloadId, Settings); _proxy.RemoveTorrent(downloadId, Settings);
} }
public override DownloadClientStatus GetStatus() public override DownloadClientInfo GetStatus()
{ {
// XXX: This function's correctness has not been considered // XXX: This function's correctness has not been considered
var status = new DownloadClientStatus var status = new DownloadClientInfo
{ {
IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost" IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost"
}; };

@ -178,7 +178,7 @@ namespace NzbDrone.Core.Download.Clients.UTorrent
_proxy.RemoveTorrent(downloadId, deleteData, Settings); _proxy.RemoveTorrent(downloadId, deleteData, Settings);
} }
public override DownloadClientStatus GetStatus() public override DownloadClientInfo GetStatus()
{ {
var config = _proxy.GetConfig(Settings); var config = _proxy.GetConfig(Settings);
@ -199,7 +199,7 @@ namespace NzbDrone.Core.Download.Clients.UTorrent
} }
} }
var status = new DownloadClientStatus var status = new DownloadClientInfo
{ {
IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost" IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost"
}; };

@ -60,7 +60,7 @@ namespace NzbDrone.Core.Download
public abstract string Download(RemoteAlbum remoteAlbum); public abstract string Download(RemoteAlbum remoteAlbum);
public abstract IEnumerable<DownloadClientItem> GetItems(); public abstract IEnumerable<DownloadClientItem> GetItems();
public abstract void RemoveItem(string downloadId, bool deleteData); public abstract void RemoveItem(string downloadId, bool deleteData);
public abstract DownloadClientStatus GetStatus(); public abstract DownloadClientInfo GetStatus();
protected virtual void DeleteItemData(string downloadId) protected virtual void DeleteItemData(string downloadId)
{ {

@ -3,7 +3,7 @@ using NzbDrone.Common.Disk;
namespace NzbDrone.Core.Download namespace NzbDrone.Core.Download
{ {
public class DownloadClientStatus public class DownloadClientInfo
{ {
public bool IsLocalhost { get; set; } public bool IsLocalhost { get; set; }
public List<OsPath> OutputRootFolders { get; set; } public List<OsPath> OutputRootFolders { get; set; }

@ -12,6 +12,6 @@ namespace NzbDrone.Core.Download
string Download(RemoteAlbum remoteAlbum); string Download(RemoteAlbum remoteAlbum);
IEnumerable<DownloadClientItem> GetItems(); IEnumerable<DownloadClientItem> GetItems();
void RemoveItem(string downloadId, bool deleteData); void RemoveItem(string downloadId, bool deleteData);
DownloadClientStatus GetStatus(); DownloadClientInfo GetStatus();
} }
} }

@ -74,6 +74,6 @@ namespace NzbDrone.Core.HealthCheck.Checks
public class ImportMechanismCheckStatus public class ImportMechanismCheckStatus
{ {
public IDownloadClient DownloadClient { get; set; } public IDownloadClient DownloadClient { get; set; }
public DownloadClientStatus Status { get; set; } public DownloadClientInfo Status { get; set; }
} }
} }

@ -1,4 +1,4 @@
using FluentValidation; using FluentValidation;
using NzbDrone.Core.Annotations; using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider; using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation; using NzbDrone.Core.Validation;
@ -13,7 +13,7 @@ namespace NzbDrone.Core.Indexers.Fanzub
} }
} }
public class FanzubSettings : IProviderConfig public class FanzubSettings : IIndexerSettings
{ {
private static readonly FanzubSettingsValidator Validator = new FanzubSettingsValidator(); private static readonly FanzubSettingsValidator Validator = new FanzubSettingsValidator();

@ -16,7 +16,7 @@ namespace NzbDrone.Core.Indexers.Gazelle
} }
} }
public class GazelleSettings : IProviderConfig public class GazelleSettings : IIndexerSettings
{ {
private static readonly GazelleSettingsValidator Validator = new GazelleSettingsValidator(); private static readonly GazelleSettingsValidator Validator = new GazelleSettingsValidator();

@ -17,7 +17,7 @@ using NzbDrone.Core.ThingiProvider;
namespace NzbDrone.Core.Indexers namespace NzbDrone.Core.Indexers
{ {
public abstract class HttpIndexerBase<TSettings> : IndexerBase<TSettings> public abstract class HttpIndexerBase<TSettings> : IndexerBase<TSettings>
where TSettings : IProviderConfig, new() where TSettings : IIndexerSettings, new()
{ {
protected const int MaxNumResultsPerQuery = 1000; protected const int MaxNumResultsPerQuery = 1000;

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NzbDrone.Core.ThingiProvider;
namespace NzbDrone.Core.Indexers
{
public interface IIndexerSettings : IProviderConfig
{
string BaseUrl { get; set; }
}
}

@ -29,7 +29,7 @@ namespace NzbDrone.Core.Indexers.IPTorrents
private IEnumerable<IndexerRequest> GetRssRequests() private IEnumerable<IndexerRequest> GetRssRequests()
{ {
yield return new IndexerRequest(Settings.Url, HttpAccept.Rss); yield return new IndexerRequest(Settings.BaseUrl, HttpAccept.Rss);
} }
} }
} }

@ -11,17 +11,17 @@ namespace NzbDrone.Core.Indexers.IPTorrents
{ {
public IPTorrentsSettingsValidator() public IPTorrentsSettingsValidator()
{ {
RuleFor(c => c.Url).ValidRootUrl(); RuleFor(c => c.BaseUrl).ValidRootUrl();
RuleFor(c => c.Url).Matches(@"/rss\?.+$"); RuleFor(c => c.BaseUrl).Matches(@"/rss\?.+$");
RuleFor(c => c.Url).Matches(@"/rss\?.+;download(?:;|$)") RuleFor(c => c.BaseUrl).Matches(@"/rss\?.+;download(?:;|$)")
.WithMessage("Use Direct Download Url (;download)") .WithMessage("Use Direct Download Url (;download)")
.When(v => v.Url.IsNotNullOrWhiteSpace() && Regex.IsMatch(v.Url, @"/rss\?.+$")); .When(v => v.BaseUrl.IsNotNullOrWhiteSpace() && Regex.IsMatch(v.BaseUrl, @"/rss\?.+$"));
} }
} }
public class IPTorrentsSettings : IProviderConfig public class IPTorrentsSettings : IIndexerSettings
{ {
private static readonly IPTorrentsSettingsValidator Validator = new IPTorrentsSettingsValidator(); private static readonly IPTorrentsSettingsValidator Validator = new IPTorrentsSettingsValidator();
@ -30,7 +30,7 @@ namespace NzbDrone.Core.Indexers.IPTorrents
} }
[FieldDefinition(0, Label = "Feed URL", HelpText = "The full RSS feed url generated by IPTorrents, using only the categories you selected (HD, SD, x264, etc ...)")] [FieldDefinition(0, Label = "Feed URL", HelpText = "The full RSS feed url generated by IPTorrents, using only the categories you selected (HD, SD, x264, etc ...)")]
public string Url { get; set; } public string BaseUrl { get; set; }
public NzbDroneValidationResult Validate() public NzbDroneValidationResult Validate()
{ {

@ -13,7 +13,7 @@ using NzbDrone.Core.ThingiProvider;
namespace NzbDrone.Core.Indexers namespace NzbDrone.Core.Indexers
{ {
public abstract class IndexerBase<TSettings> : IIndexer public abstract class IndexerBase<TSettings> : IIndexer
where TSettings : IProviderConfig, new() where TSettings : IIndexerSettings, new()
{ {
protected readonly IIndexerStatusService _indexerStatusService; protected readonly IIndexerStatusService _indexerStatusService;
protected readonly IConfigService _configService; protected readonly IConfigService _configService;

@ -78,7 +78,7 @@ namespace NzbDrone.Core.Indexers.Newznab
private NewznabSettings GetSettings(string url, params int[] categories) private NewznabSettings GetSettings(string url, params int[] categories)
{ {
var settings = new NewznabSettings { Url = url }; var settings = new NewznabSettings { BaseUrl = url };
if (categories.Any()) if (categories.Any())
{ {

@ -41,7 +41,7 @@ namespace NzbDrone.Core.Indexers.Newznab
{ {
var capabilities = new NewznabCapabilities(); var capabilities = new NewznabCapabilities();
var url = string.Format("{0}/api?t=caps", indexerSettings.Url.TrimEnd('/')); var url = string.Format("{0}/api?t=caps", indexerSettings.BaseUrl.TrimEnd('/'));
if (indexerSettings.ApiKey.IsNotNullOrWhiteSpace()) if (indexerSettings.ApiKey.IsNotNullOrWhiteSpace())
{ {
@ -58,7 +58,7 @@ namespace NzbDrone.Core.Indexers.Newznab
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.Debug(ex, "Failed to get newznab api capabilities from {0}", indexerSettings.Url); _logger.Debug(ex, "Failed to get newznab api capabilities from {0}", indexerSettings.BaseUrl);
throw; throw;
} }
@ -68,13 +68,13 @@ namespace NzbDrone.Core.Indexers.Newznab
} }
catch (XmlException ex) catch (XmlException ex)
{ {
_logger.Debug(ex, "Failed to parse newznab api capabilities for {0}.", indexerSettings.Url); _logger.Debug(ex, "Failed to parse newznab api capabilities for {0}.", indexerSettings.BaseUrl);
ex.WithData(response); ex.WithData(response);
throw; throw;
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.Error(ex, "Failed to determine newznab api capabilities for {0}, using the defaults instead till Lidarr restarts.", indexerSettings.Url); _logger.Error(ex, "Failed to determine newznab api capabilities for {0}, using the defaults instead till Lidarr restarts.", indexerSettings.BaseUrl);
} }
return capabilities; return capabilities;

@ -134,7 +134,7 @@ namespace NzbDrone.Core.Indexers.Newznab
var categoriesQuery = string.Join(",", categories.Distinct()); var categoriesQuery = string.Join(",", categories.Distinct());
var baseUrl = string.Format("{0}/api?t={1}&cat={2}&extended=1{3}", Settings.Url.TrimEnd('/'), searchType, categoriesQuery, Settings.AdditionalParameters); var baseUrl = string.Format("{0}/api?t={1}&cat={2}&extended=1{3}", Settings.BaseUrl.TrimEnd('/'), searchType, categoriesQuery, Settings.AdditionalParameters);
if (Settings.ApiKey.IsNotNullOrWhiteSpace()) if (Settings.ApiKey.IsNotNullOrWhiteSpace())
{ {

@ -25,12 +25,12 @@ namespace NzbDrone.Core.Indexers.Newznab
private static bool ShouldHaveApiKey(NewznabSettings settings) private static bool ShouldHaveApiKey(NewznabSettings settings)
{ {
if (settings.Url == null) if (settings.BaseUrl == null)
{ {
return false; return false;
} }
return ApiKeyWhiteList.Any(c => settings.Url.ToLowerInvariant().Contains(c)); return ApiKeyWhiteList.Any(c => settings.BaseUrl.ToLowerInvariant().Contains(c));
} }
private static readonly Regex AdditionalParametersRegex = new Regex(@"(&.+?\=.+?)+", RegexOptions.Compiled); private static readonly Regex AdditionalParametersRegex = new Regex(@"(&.+?\=.+?)+", RegexOptions.Compiled);
@ -47,14 +47,14 @@ namespace NzbDrone.Core.Indexers.Newznab
return null; return null;
}); });
RuleFor(c => c.Url).ValidRootUrl(); RuleFor(c => c.BaseUrl).ValidRootUrl();
RuleFor(c => c.ApiKey).NotEmpty().When(ShouldHaveApiKey); RuleFor(c => c.ApiKey).NotEmpty().When(ShouldHaveApiKey);
RuleFor(c => c.AdditionalParameters).Matches(AdditionalParametersRegex) RuleFor(c => c.AdditionalParameters).Matches(AdditionalParametersRegex)
.When(c => !c.AdditionalParameters.IsNullOrWhiteSpace()); .When(c => !c.AdditionalParameters.IsNullOrWhiteSpace());
} }
} }
public class NewznabSettings : IProviderConfig public class NewznabSettings : IIndexerSettings
{ {
private static readonly NewznabSettingsValidator Validator = new NewznabSettingsValidator(); private static readonly NewznabSettingsValidator Validator = new NewznabSettingsValidator();
@ -64,7 +64,7 @@ namespace NzbDrone.Core.Indexers.Newznab
} }
[FieldDefinition(0, Label = "URL")] [FieldDefinition(0, Label = "URL")]
public string Url { get; set; } public string BaseUrl { get; set; }
[FieldDefinition(1, Label = "API Key")] [FieldDefinition(1, Label = "API Key")]
public string ApiKey { get; set; } public string ApiKey { get; set; }

@ -1,4 +1,4 @@
using FluentValidation; using FluentValidation;
using NzbDrone.Core.Annotations; using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider; using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation; using NzbDrone.Core.Validation;
@ -14,7 +14,7 @@ namespace NzbDrone.Core.Indexers.Nyaa
} }
} }
public class NyaaSettings : IProviderConfig public class NyaaSettings : IIndexerSettings
{ {
private static readonly NyaaSettingsValidator Validator = new NyaaSettingsValidator(); private static readonly NyaaSettingsValidator Validator = new NyaaSettingsValidator();
@ -35,4 +35,4 @@ namespace NzbDrone.Core.Indexers.Nyaa
return new NzbDroneValidationResult(Validator.Validate(this)); return new NzbDroneValidationResult(Validator.Validate(this));
} }
} }
} }

@ -1,4 +1,4 @@
using FluentValidation; using FluentValidation;
using NzbDrone.Core.Annotations; using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider; using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation; using NzbDrone.Core.Validation;
@ -15,7 +15,7 @@ namespace NzbDrone.Core.Indexers.Omgwtfnzbs
} }
} }
public class OmgwtfnzbsSettings : IProviderConfig public class OmgwtfnzbsSettings : IIndexerSettings
{ {
private static readonly OmgwtfnzbsSettingsValidator Validator = new OmgwtfnzbsSettingsValidator(); private static readonly OmgwtfnzbsSettingsValidator Validator = new OmgwtfnzbsSettingsValidator();
@ -24,6 +24,9 @@ namespace NzbDrone.Core.Indexers.Omgwtfnzbs
Delay = 30; Delay = 30;
} }
// Unused since Omg has a hardcoded url.
public string BaseUrl { get; set; }
[FieldDefinition(0, Label = "Username")] [FieldDefinition(0, Label = "Username")]
public string Username { get; set; } public string Username { get; set; }

@ -13,7 +13,7 @@ namespace NzbDrone.Core.Indexers.Rarbg
} }
} }
public class RarbgSettings : IProviderConfig public class RarbgSettings : IIndexerSettings
{ {
private static readonly RarbgSettingsValidator Validator = new RarbgSettingsValidator(); private static readonly RarbgSettingsValidator Validator = new RarbgSettingsValidator();
@ -37,4 +37,4 @@ namespace NzbDrone.Core.Indexers.Rarbg
return new NzbDroneValidationResult(Validator.Validate(this)); return new NzbDroneValidationResult(Validator.Validate(this));
} }
} }
} }

@ -13,7 +13,7 @@ namespace NzbDrone.Core.Indexers.TorrentRss
} }
} }
public class TorrentRssIndexerSettings : IProviderConfig public class TorrentRssIndexerSettings : IIndexerSettings
{ {
private static readonly TorrentRssIndexerSettingsValidator validator = new TorrentRssIndexerSettingsValidator(); private static readonly TorrentRssIndexerSettingsValidator validator = new TorrentRssIndexerSettingsValidator();
@ -37,4 +37,4 @@ namespace NzbDrone.Core.Indexers.TorrentRss
return new NzbDroneValidationResult(validator.Validate(this)); return new NzbDroneValidationResult(validator.Validate(this));
} }
} }
} }

@ -14,7 +14,7 @@ namespace NzbDrone.Core.Indexers.Torrentleech
} }
} }
public class TorrentleechSettings : IProviderConfig public class TorrentleechSettings : IIndexerSettings
{ {
private static readonly TorrentleechSettingsValidator Validator = new TorrentleechSettingsValidator(); private static readonly TorrentleechSettingsValidator Validator = new TorrentleechSettingsValidator();
@ -34,4 +34,4 @@ namespace NzbDrone.Core.Indexers.Torrentleech
return new NzbDroneValidationResult(Validator.Validate(this)); return new NzbDroneValidationResult(Validator.Validate(this));
} }
} }
} }

@ -66,7 +66,7 @@ namespace NzbDrone.Core.Indexers.Torznab
private TorznabSettings GetSettings(string url, params int[] categories) private TorznabSettings GetSettings(string url, params int[] categories)
{ {
var settings = new TorznabSettings { Url = url }; var settings = new TorznabSettings { BaseUrl = url };
if (categories.Any()) if (categories.Any())
{ {

@ -17,12 +17,12 @@ namespace NzbDrone.Core.Indexers.Torznab
private static bool ShouldHaveApiKey(TorznabSettings settings) private static bool ShouldHaveApiKey(TorznabSettings settings)
{ {
if (settings.Url == null) if (settings.BaseUrl == null)
{ {
return false; return false;
} }
return ApiKeyWhiteList.Any(c => settings.Url.ToLowerInvariant().Contains(c)); return ApiKeyWhiteList.Any(c => settings.BaseUrl.ToLowerInvariant().Contains(c));
} }
private static readonly Regex AdditionalParametersRegex = new Regex(@"(&.+?\=.+?)+", RegexOptions.Compiled); private static readonly Regex AdditionalParametersRegex = new Regex(@"(&.+?\=.+?)+", RegexOptions.Compiled);
@ -39,7 +39,7 @@ namespace NzbDrone.Core.Indexers.Torznab
return null; return null;
}); });
RuleFor(c => c.Url).ValidRootUrl(); RuleFor(c => c.BaseUrl).ValidRootUrl();
RuleFor(c => c.ApiKey).NotEmpty().When(ShouldHaveApiKey); RuleFor(c => c.ApiKey).NotEmpty().When(ShouldHaveApiKey);
RuleFor(c => c.AdditionalParameters).Matches(AdditionalParametersRegex) RuleFor(c => c.AdditionalParameters).Matches(AdditionalParametersRegex)
.When(c => !c.AdditionalParameters.IsNullOrWhiteSpace()); .When(c => !c.AdditionalParameters.IsNullOrWhiteSpace());

@ -1,4 +1,4 @@
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using FluentValidation; using FluentValidation;
using NzbDrone.Core.Annotations; using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider; using NzbDrone.Core.ThingiProvider;
@ -16,7 +16,7 @@ namespace NzbDrone.Core.Indexers.Waffles
} }
} }
public class WafflesSettings : IProviderConfig public class WafflesSettings : IIndexerSettings
{ {
private static readonly WafflesSettingsValidator Validator = new WafflesSettingsValidator(); private static readonly WafflesSettingsValidator Validator = new WafflesSettingsValidator();
@ -40,4 +40,4 @@ namespace NzbDrone.Core.Indexers.Waffles
return new NzbDroneValidationResult(Validator.Validate(this)); return new NzbDroneValidationResult(Validator.Validate(this));
} }
} }
} }

@ -303,6 +303,7 @@
<Compile Include="Datastore\Migration\114_music_blacklist.cs" /> <Compile Include="Datastore\Migration\114_music_blacklist.cs" />
<Compile Include="Datastore\Migration\113_music_history.cs" /> <Compile Include="Datastore\Migration\113_music_history.cs" />
<Compile Include="Datastore\Migration\112_setup_music.cs" /> <Compile Include="Datastore\Migration\112_setup_music.cs" />
<Compile Include="Datastore\Migration\122_consolidate_indexer_baseurl.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationContext.cs" /> <Compile Include="Datastore\Migration\Framework\MigrationContext.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationController.cs" /> <Compile Include="Datastore\Migration\Framework\MigrationController.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationDbFactory.cs" /> <Compile Include="Datastore\Migration\Framework\MigrationDbFactory.cs" />
@ -522,7 +523,7 @@
<Compile Include="Download\DownloadClientItem.cs" /> <Compile Include="Download\DownloadClientItem.cs" />
<Compile Include="Download\DownloadClientProvider.cs" /> <Compile Include="Download\DownloadClientProvider.cs" />
<Compile Include="Download\DownloadClientRepository.cs" /> <Compile Include="Download\DownloadClientRepository.cs" />
<Compile Include="Download\DownloadClientStatus.cs" /> <Compile Include="Download\DownloadClientInfo.cs" />
<Compile Include="Download\DownloadClientType.cs" /> <Compile Include="Download\DownloadClientType.cs" />
<Compile Include="Download\DownloadFailedEvent.cs" /> <Compile Include="Download\DownloadFailedEvent.cs" />
<Compile Include="Download\DownloadItemStatus.cs" /> <Compile Include="Download\DownloadItemStatus.cs" />
@ -629,6 +630,7 @@
<Compile Include="Indexers\Gazelle\GazelleParser.cs" /> <Compile Include="Indexers\Gazelle\GazelleParser.cs" />
<Compile Include="Indexers\Gazelle\GazelleRequestGenerator.cs" /> <Compile Include="Indexers\Gazelle\GazelleRequestGenerator.cs" />
<Compile Include="Indexers\Gazelle\GazelleSettings.cs" /> <Compile Include="Indexers\Gazelle\GazelleSettings.cs" />
<Compile Include="Indexers\IIndexerSettings.cs" />
<Compile Include="Indexers\Waffles\WafflesRssParser.cs" /> <Compile Include="Indexers\Waffles\WafflesRssParser.cs" />
<Compile Include="Indexers\Waffles\Waffles.cs" /> <Compile Include="Indexers\Waffles\Waffles.cs" />
<Compile Include="Indexers\Waffles\WafflesRequestGenerator.cs" /> <Compile Include="Indexers\Waffles\WafflesRequestGenerator.cs" />

@ -457,9 +457,9 @@ namespace NzbDrone.Core.Parser
Logger.Debug("Reversed name detected. Converted to '{0}'", title); Logger.Debug("Reversed name detected. Converted to '{0}'", title);
} }
var simpleTitle = SimpleTitleRegex.Replace(title, string.Empty); var releaseTitle = RemoveFileExtension(title);
simpleTitle = RemoveFileExtension(simpleTitle); var simpleTitle = SimpleTitleRegex.Replace(releaseTitle, string.Empty);
// TODO: Quick fix stripping [url] - prefixes. // TODO: Quick fix stripping [url] - prefixes.
simpleTitle = WebsitePrefixRegex.Replace(simpleTitle, string.Empty); simpleTitle = WebsitePrefixRegex.Replace(simpleTitle, string.Empty);
@ -568,9 +568,9 @@ namespace NzbDrone.Core.Parser
Logger.Debug("Reversed name detected. Converted to '{0}'", title); Logger.Debug("Reversed name detected. Converted to '{0}'", title);
} }
var simpleTitle = SimpleTitleRegex.Replace(title, string.Empty); var releaseTitle = RemoveFileExtension(title);
simpleTitle = RemoveFileExtension(simpleTitle); var simpleTitle = SimpleTitleRegex.Replace(releaseTitle, string.Empty);
// TODO: Quick fix stripping [url] - prefixes. // TODO: Quick fix stripping [url] - prefixes.
simpleTitle = WebsitePrefixRegex.Replace(simpleTitle, string.Empty); simpleTitle = WebsitePrefixRegex.Replace(simpleTitle, string.Empty);
@ -611,13 +611,13 @@ namespace NzbDrone.Core.Parser
if (result != null) if (result != null)
{ {
result.Language = LanguageParser.ParseLanguage(title); result.Language = LanguageParser.ParseLanguage(releaseTitle);
Logger.Debug("Language parsed: {0}", result.Language); Logger.Debug("Language parsed: {0}", result.Language);
result.Quality = QualityParser.ParseQuality(title); result.Quality = QualityParser.ParseQuality(title);
Logger.Debug("Quality parsed: {0}", result.Quality); Logger.Debug("Quality parsed: {0}", result.Quality);
result.ReleaseGroup = ParseReleaseGroup(title); result.ReleaseGroup = ParseReleaseGroup(releaseTitle);
var subGroup = GetSubGroup(match); var subGroup = GetSubGroup(match);
if (!subGroup.IsNullOrWhiteSpace()) if (!subGroup.IsNullOrWhiteSpace())

Loading…
Cancel
Save