mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 10:47:08 -07:00
Add Advanced Option for Alternate Metadata Provider Source
This commit is contained in:
parent
f460f630c3
commit
0201aa812e
16 changed files with 334 additions and 29 deletions
21
src/Lidarr.Api.V3/Config/MetadataProviderConfigModule.cs
Normal file
21
src/Lidarr.Api.V3/Config/MetadataProviderConfigModule.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using Lidarr.Http;
|
||||
|
||||
namespace Lidarr.Api.V3.Config
|
||||
{
|
||||
public class MetadataProviderConfigModule : SonarrConfigModule<MetadataProviderConfigResource>
|
||||
{
|
||||
public MetadataProviderConfigModule(IConfigService configService)
|
||||
: base(configService)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override MetadataProviderConfigResource ToResource(IConfigService model)
|
||||
{
|
||||
return MetadataProviderConfigResourceMapper.ToResource(model);
|
||||
}
|
||||
}
|
||||
}
|
24
src/Lidarr.Api.V3/Config/MetadataProviderConfigResource.cs
Normal file
24
src/Lidarr.Api.V3/Config/MetadataProviderConfigResource.cs
Normal file
|
@ -0,0 +1,24 @@
|
|||
using NzbDrone.Core.Configuration;
|
||||
using Lidarr.Http.REST;
|
||||
|
||||
namespace Lidarr.Api.V3.Config
|
||||
{
|
||||
public class MetadataProviderConfigResource : RestResource
|
||||
{
|
||||
//Calendar
|
||||
public string MetadataSource { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public static class MetadataProviderConfigResourceMapper
|
||||
{
|
||||
public static MetadataProviderConfigResource ToResource(IConfigService model)
|
||||
{
|
||||
return new MetadataProviderConfigResource
|
||||
{
|
||||
MetadataSource = model.MetadataSource,
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -95,6 +95,8 @@
|
|||
<Compile Include="Calendar\CalendarModule.cs" />
|
||||
<Compile Include="Commands\CommandModule.cs" />
|
||||
<Compile Include="Commands\CommandResource.cs" />
|
||||
<Compile Include="Config\MetadataProviderConfigModule.cs" />
|
||||
<Compile Include="Config\MetadataProviderConfigResource.cs" />
|
||||
<Compile Include="TrackFiles\TrackFileListResource.cs" />
|
||||
<Compile Include="TrackFiles\MediaInfoResource.cs" />
|
||||
<Compile Include="Indexers\ReleaseModuleBase.cs" />
|
||||
|
|
|
@ -7,7 +7,6 @@ namespace NzbDrone.Common.Cloud
|
|||
IHttpRequestBuilderFactory Services { get; }
|
||||
IHttpRequestBuilderFactory Search { get; }
|
||||
IHttpRequestBuilderFactory InternalSearch { get; }
|
||||
IHttpRequestBuilderFactory SkyHookTvdb { get; }
|
||||
}
|
||||
|
||||
public class LidarrCloudRequestBuilder : ILidarrCloudRequestBuilder
|
||||
|
@ -19,11 +18,6 @@ namespace NzbDrone.Common.Cloud
|
|||
|
||||
Search = new HttpRequestBuilder("https://api.lidarr.audio/api/v0/{route}/") // TODO: Add {version} once LidarrAPI.Metadata is released.
|
||||
.CreateFactory();
|
||||
|
||||
|
||||
SkyHookTvdb = new HttpRequestBuilder("http://skyhook.lidarr.tv/v1/tvdb/{route}/{language}/")
|
||||
.SetSegment("language", "en")
|
||||
.CreateFactory();
|
||||
}
|
||||
|
||||
public IHttpRequestBuilderFactory Services { get; }
|
||||
|
@ -31,7 +25,5 @@ namespace NzbDrone.Common.Cloud
|
|||
public IHttpRequestBuilderFactory Search { get; }
|
||||
|
||||
public IHttpRequestBuilderFactory InternalSearch { get; }
|
||||
|
||||
public IHttpRequestBuilderFactory SkyHookTvdb { get; }
|
||||
}
|
||||
}
|
|
@ -78,7 +78,7 @@
|
|||
<Compile Include="Cache\CachedDictionary.cs" />
|
||||
<Compile Include="Cache\ICached.cs" />
|
||||
<Compile Include="Cache\ICachedDictionary.cs" />
|
||||
<Compile Include="Cloud\SonarrCloudRequestBuilder.cs" />
|
||||
<Compile Include="Cloud\LidarrCloudRequestBuilder.cs" />
|
||||
<Compile Include="Composition\Container.cs" />
|
||||
<Compile Include="Composition\ContainerBuilderBase.cs" />
|
||||
<Compile Include="Composition\IContainer.cs" />
|
||||
|
|
|
@ -238,6 +238,13 @@ namespace NzbDrone.Core.Configuration
|
|||
set { SetValue("ChownGroup", value); }
|
||||
}
|
||||
|
||||
public string MetadataSource
|
||||
{
|
||||
get { return GetValue("MetadataSource", ""); }
|
||||
|
||||
set { SetValue("MetadataSource", value); }
|
||||
}
|
||||
|
||||
public int FirstDayOfWeek
|
||||
{
|
||||
get { return GetValueInt("FirstDayOfWeek", (int)CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek); }
|
||||
|
|
|
@ -58,6 +58,9 @@ namespace NzbDrone.Core.Configuration
|
|||
//Internal
|
||||
bool CleanupMetadataImages { get; set; }
|
||||
|
||||
//MetadataSource
|
||||
string MetadataSource { get; set; }
|
||||
|
||||
|
||||
//Forms Auth
|
||||
string RijndaelPassphrase { get; }
|
||||
|
|
|
@ -13,6 +13,7 @@ using NzbDrone.Core.Tv;
|
|||
using Newtonsoft.Json.Linq;
|
||||
using NzbDrone.Core.Music;
|
||||
using Newtonsoft.Json;
|
||||
using NzbDrone.Core.Configuration;
|
||||
|
||||
namespace NzbDrone.Core.MetadataSource.SkyHook
|
||||
{
|
||||
|
@ -23,15 +24,20 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
|||
|
||||
private readonly IArtistService _artistService;
|
||||
private readonly IHttpRequestBuilderFactory _requestBuilder;
|
||||
private readonly IConfigService _configService;
|
||||
|
||||
public SkyHookProxy(IHttpClient httpClient, ILidarrCloudRequestBuilder requestBuilder, IArtistService artistService, Logger logger)
|
||||
private IHttpRequestBuilderFactory customerRequestBuilder;
|
||||
|
||||
public SkyHookProxy(IHttpClient httpClient, ILidarrCloudRequestBuilder requestBuilder, IArtistService artistService, Logger logger, IConfigService configService)
|
||||
{
|
||||
_httpClient = httpClient;
|
||||
_configService = configService;
|
||||
_requestBuilder = requestBuilder.Search;
|
||||
_artistService = artistService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[Obsolete("Used for Sonarr, not Lidarr")]
|
||||
public Tuple<Series, List<Episode>> GetSeriesInfo(int tvdbSeriesId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
@ -42,8 +48,9 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
|||
|
||||
_logger.Debug("Getting Artist with LidarrAPI.MetadataID of {0}", foreignArtistId);
|
||||
|
||||
// We need to perform a direct lookup of the artist
|
||||
var httpRequest = _requestBuilder.Create()
|
||||
SetCustomProvider();
|
||||
|
||||
var httpRequest = customerRequestBuilder.Create()
|
||||
.SetSegment("route", "artists/" + foreignArtistId)
|
||||
.Build();
|
||||
|
||||
|
@ -99,7 +106,9 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
|||
}
|
||||
}
|
||||
|
||||
var httpRequest = _requestBuilder.Create()
|
||||
SetCustomProvider();
|
||||
|
||||
var httpRequest = customerRequestBuilder.Create()
|
||||
.SetSegment("route", "search")
|
||||
.AddQueryParam("type", "artist")
|
||||
.AddQueryParam("query", title.ToLower().Trim())
|
||||
|
@ -113,12 +122,12 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
|||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
throw new SkyHookException("Search for '{0}' failed. Unable to communicate with SkyHook.", title);
|
||||
throw new SkyHookException("Search for '{0}' failed. Unable to communicate with LidarrAPI.", title);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Warn(ex, ex.Message);
|
||||
throw new SkyHookException("Search for '{0}' failed. Invalid response received from SkyHook.", title);
|
||||
throw new SkyHookException("Search for '{0}' failed. Invalid response received from LidarrAPI.", title);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -268,5 +277,17 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
|||
return MediaCoverTypes.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetCustomProvider()
|
||||
{
|
||||
if (_configService.MetadataSource.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
customerRequestBuilder = new HttpRequestBuilder(_configService.MetadataSource + "{route}/").CreateFactory();
|
||||
}
|
||||
else
|
||||
{
|
||||
customerRequestBuilder = _requestBuilder;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue