2014-02-14 05:31:49 +00:00
|
|
|
|
using System;
|
2014-04-19 15:09:22 +00:00
|
|
|
|
using System.Linq;
|
2014-02-14 05:31:49 +00:00
|
|
|
|
using System.Collections.Generic;
|
2014-04-19 15:09:22 +00:00
|
|
|
|
using NzbDrone.Core.Indexers;
|
|
|
|
|
using NzbDrone.Core.Parser;
|
2014-02-14 05:31:49 +00:00
|
|
|
|
using NzbDrone.Core.Parser.Model;
|
|
|
|
|
using NzbDrone.Core.ThingiProvider;
|
2014-04-19 15:09:22 +00:00
|
|
|
|
using NLog;
|
2014-02-14 05:31:49 +00:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Download
|
|
|
|
|
{
|
2014-04-19 15:09:22 +00:00
|
|
|
|
public abstract class DownloadClientBase<TSettings> : IDownloadClient
|
|
|
|
|
where TSettings : IProviderConfig, new()
|
2014-02-14 05:31:49 +00:00
|
|
|
|
{
|
2014-04-19 15:09:22 +00:00
|
|
|
|
private readonly IParsingService _parsingService;
|
|
|
|
|
protected readonly Logger _logger;
|
|
|
|
|
|
2014-02-14 05:31:49 +00:00
|
|
|
|
public Type ConfigContract
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return typeof(TSettings);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEnumerable<ProviderDefinition> DefaultDefinitions
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return new List<ProviderDefinition>();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ProviderDefinition Definition { get; set; }
|
|
|
|
|
|
|
|
|
|
protected TSettings Settings
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return (TSettings)Definition.Settings;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-19 15:09:22 +00:00
|
|
|
|
protected DownloadClientBase(IParsingService parsingService, Logger logger)
|
|
|
|
|
{
|
|
|
|
|
_parsingService = parsingService;
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-14 05:31:49 +00:00
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return GetType().Name;
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-19 15:09:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public abstract DownloadProtocol Protocol
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public abstract string Download(RemoteEpisode remoteEpisode);
|
|
|
|
|
public abstract IEnumerable<DownloadClientItem> GetItems();
|
|
|
|
|
public abstract void RemoveItem(string id);
|
2014-04-01 20:07:41 +00:00
|
|
|
|
public abstract void RetryDownload(string id);
|
2014-02-26 05:40:47 +00:00
|
|
|
|
public abstract void Test();
|
2014-04-19 15:09:22 +00:00
|
|
|
|
|
|
|
|
|
protected RemoteEpisode GetRemoteEpisode(String title)
|
|
|
|
|
{
|
|
|
|
|
var parsedEpisodeInfo = Parser.Parser.ParseTitle(title);
|
|
|
|
|
if (parsedEpisodeInfo == null) return null;
|
|
|
|
|
|
|
|
|
|
var remoteEpisode = _parsingService.Map(parsedEpisodeInfo, 0);
|
|
|
|
|
if (remoteEpisode.Series == null) return null;
|
|
|
|
|
|
|
|
|
|
return remoteEpisode;
|
|
|
|
|
}
|
2014-02-14 05:31:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|