mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 14:03:29 -07:00
cleaned up scene mapping code.
This commit is contained in:
parent
c1fba9093d
commit
48880e4964
25 changed files with 222 additions and 319 deletions
|
@ -0,0 +1,47 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NLog;
|
||||
using Newtonsoft.Json;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Configuration;
|
||||
|
||||
namespace NzbDrone.Core.DataAugmentation.DailySeries
|
||||
{
|
||||
|
||||
public interface IDailySeriesDataProxy
|
||||
{
|
||||
IEnumerable<int> GetDailySeriesIds();
|
||||
}
|
||||
|
||||
public class DailySeriesDataProxy : IDailySeriesDataProxy
|
||||
{
|
||||
private readonly HttpProvider _httpProvider;
|
||||
private readonly IConfigService _configService;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public DailySeriesDataProxy(HttpProvider httpProvider, IConfigService configService, Logger logger)
|
||||
{
|
||||
_httpProvider = httpProvider;
|
||||
_configService = configService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public IEnumerable<int> GetDailySeriesIds()
|
||||
{
|
||||
try
|
||||
{
|
||||
var dailySeriesIds = _httpProvider.DownloadString(_configService.ServiceRootUrl + "/DailySeries/AllIds");
|
||||
|
||||
var seriesIds = JsonConvert.DeserializeObject<List<int>>(dailySeriesIds);
|
||||
|
||||
return seriesIds;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.WarnException("Failed to get Daily Series", ex);
|
||||
return new List<int>();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.DataAugmentation.DailySeries
|
||||
{
|
||||
public class DailySeriesService
|
||||
{
|
||||
private readonly IDailySeriesDataProxy _proxy;
|
||||
private readonly ISeriesService _seriesService;
|
||||
|
||||
public DailySeriesService(IDailySeriesDataProxy proxy, ISeriesService seriesService)
|
||||
{
|
||||
_proxy = proxy;
|
||||
_seriesService = seriesService;
|
||||
}
|
||||
|
||||
public virtual void UpdateDailySeries()
|
||||
{
|
||||
var dailySeries = _proxy.GetDailySeriesIds();
|
||||
|
||||
foreach (var tvdbId in dailySeries)
|
||||
{
|
||||
var series = _seriesService.FindByTvdbId(tvdbId);
|
||||
|
||||
if (series != null)
|
||||
{
|
||||
_seriesService.SetSeriesType(series.Id, SeriesTypes.Daily);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue