parent
8eb0f33718
commit
efeb216383
@ -0,0 +1,43 @@
|
||||
using NLog;
|
||||
using NzbDrone.Common.Cloud;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.MetadataSource;
|
||||
using NzbDrone.Core.Parser;
|
||||
|
||||
namespace NzbDrone.Core.ImportLists.TMDb.Company
|
||||
{
|
||||
public class TMDbCompanyImport : TMDbImportListBase<TMDbCompanySettings>
|
||||
{
|
||||
public TMDbCompanyImport(IRadarrCloudRequestBuilder requestBuilder,
|
||||
IHttpClient httpClient,
|
||||
IImportListStatusService importListStatusService,
|
||||
IConfigService configService,
|
||||
IParsingService parsingService,
|
||||
ISearchForNewMovie searchForNewMovie,
|
||||
Logger logger)
|
||||
: base(requestBuilder, httpClient, importListStatusService, configService, parsingService, searchForNewMovie, logger)
|
||||
{
|
||||
}
|
||||
|
||||
public override string Name => "TMDb Company";
|
||||
public override bool Enabled => true;
|
||||
public override bool EnableAuto => false;
|
||||
|
||||
public override IParseImportListResponse GetParser()
|
||||
{
|
||||
return new TMDbCompanyParser();
|
||||
}
|
||||
|
||||
public override IImportListRequestGenerator GetRequestGenerator()
|
||||
{
|
||||
return new TMDbCompanyRequestGenerator()
|
||||
{
|
||||
RequestBuilder = _requestBuilder,
|
||||
Settings = Settings,
|
||||
Logger = _logger,
|
||||
HttpClient = _httpClient
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.ImportLists.ImportListMovies;
|
||||
|
||||
namespace NzbDrone.Core.ImportLists.TMDb.Company
|
||||
{
|
||||
public class TMDbCompanyParser : TMDbParser
|
||||
{
|
||||
public override IList<ImportListMovie> ParseResponse(ImportListResponse importResponse)
|
||||
{
|
||||
var movies = new List<ImportListMovie>();
|
||||
|
||||
if (!PreProcess(importResponse))
|
||||
{
|
||||
return movies;
|
||||
}
|
||||
|
||||
var jsonResponse = JsonConvert.DeserializeObject<MovieSearchResource>(importResponse.Content);
|
||||
|
||||
// no movies were return
|
||||
if (jsonResponse == null)
|
||||
{
|
||||
return movies;
|
||||
}
|
||||
|
||||
foreach (var movie in jsonResponse.Results)
|
||||
{
|
||||
// Movies with no Year Fix
|
||||
if (string.IsNullOrWhiteSpace(movie.ReleaseDate))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
movies.AddIfNotNull(MapListMovie(movie));
|
||||
}
|
||||
|
||||
return movies;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using FluentValidation;
|
||||
using NzbDrone.Core.Annotations;
|
||||
|
||||
namespace NzbDrone.Core.ImportLists.TMDb.Company
|
||||
{
|
||||
public class TMDbCompanySettingsValidator : TMDbSettingsBaseValidator<TMDbCompanySettings>
|
||||
{
|
||||
public TMDbCompanySettingsValidator()
|
||||
: base()
|
||||
{
|
||||
RuleFor(c => c.CompanyId).Matches(@"^[1-9][0-9]*$", RegexOptions.IgnoreCase);
|
||||
}
|
||||
}
|
||||
|
||||
public class TMDbCompanySettings : TMDbSettingsBase<TMDbCompanySettings>
|
||||
{
|
||||
protected override AbstractValidator<TMDbCompanySettings> Validator => new TMDbCompanySettingsValidator();
|
||||
|
||||
public TMDbCompanySettings()
|
||||
{
|
||||
CompanyId = "";
|
||||
}
|
||||
|
||||
[FieldDefinition(1, Label = "Company Id", Type = FieldType.Textbox, HelpText = "TMDb Id of Company to Follow")]
|
||||
public string CompanyId { get; set; }
|
||||
}
|
||||
}
|
Loading…
Reference in new issue