Minor cleanup in RssImport
This commit is contained in:
parent
c6b543e072
commit
477bfb7835
|
@ -8,6 +8,10 @@ namespace NzbDrone.Core.ImportLists.Rss.Plex
|
||||||
{
|
{
|
||||||
public class PlexRssImport : RssImportBase<PlexRssImportSettings>
|
public class PlexRssImport : RssImportBase<PlexRssImportSettings>
|
||||||
{
|
{
|
||||||
|
public override string Name => "Plex Watchlist RSS";
|
||||||
|
public override ImportListType ListType => ImportListType.Plex;
|
||||||
|
public override TimeSpan MinRefreshInterval => TimeSpan.FromHours(6);
|
||||||
|
|
||||||
public PlexRssImport(IHttpClient httpClient,
|
public PlexRssImport(IHttpClient httpClient,
|
||||||
IImportListStatusService importListStatusService,
|
IImportListStatusService importListStatusService,
|
||||||
IConfigService configService,
|
IConfigService configService,
|
||||||
|
@ -17,10 +21,6 @@ namespace NzbDrone.Core.ImportLists.Rss.Plex
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ImportListType ListType => ImportListType.Plex;
|
|
||||||
public override TimeSpan MinRefreshInterval => TimeSpan.FromHours(6);
|
|
||||||
public override string Name => "Plex Watchlist RSS";
|
|
||||||
|
|
||||||
public override IParseImportListResponse GetParser()
|
public override IParseImportListResponse GetParser()
|
||||||
{
|
{
|
||||||
return new PlexRssImportParser(_logger);
|
return new PlexRssImportParser(_logger);
|
||||||
|
|
|
@ -8,18 +8,13 @@ namespace NzbDrone.Core.ImportLists.Rss.Plex
|
||||||
{
|
{
|
||||||
public class PlexRssImportParser : RssImportBaseParser
|
public class PlexRssImportParser : RssImportBaseParser
|
||||||
{
|
{
|
||||||
private readonly Logger _logger;
|
|
||||||
|
|
||||||
public PlexRssImportParser(Logger logger)
|
public PlexRssImportParser(Logger logger)
|
||||||
: base(logger)
|
: base(logger)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override ImportListItemInfo ProcessItem(XElement item)
|
protected override ImportListItemInfo ProcessItem(XElement item)
|
||||||
{
|
{
|
||||||
var info = new ImportListItemInfo();
|
|
||||||
var guid = item.TryGetValue("guid", string.Empty);
|
|
||||||
var category = item.TryGetValue("category");
|
var category = item.TryGetValue("category");
|
||||||
|
|
||||||
if (category != "show")
|
if (category != "show")
|
||||||
|
@ -27,7 +22,12 @@ namespace NzbDrone.Core.ImportLists.Rss.Plex
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
info.Title = item.TryGetValue("title", "Unknown");
|
var info = new ImportListItemInfo
|
||||||
|
{
|
||||||
|
Title = item.TryGetValue("title", "Unknown")
|
||||||
|
};
|
||||||
|
|
||||||
|
var guid = item.TryGetValue("guid", string.Empty);
|
||||||
|
|
||||||
if (int.TryParse(guid.Replace("tvdb://", ""), out var tvdbId))
|
if (int.TryParse(guid.Replace("tvdb://", ""), out var tvdbId))
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,9 +12,9 @@ namespace NzbDrone.Core.ImportLists.Rss.Plex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PlexRssImportSettings : RssImportBaseSettings, IImportListSettings
|
public class PlexRssImportSettings : RssImportBaseSettings
|
||||||
{
|
{
|
||||||
private PlexRssImportSettingsValidator Validator => new PlexRssImportSettingsValidator();
|
private PlexRssImportSettingsValidator Validator => new ();
|
||||||
|
|
||||||
[FieldDefinition(0, Label = "Url", Type = FieldType.Textbox, HelpLink = "https://app.plex.tv/desktop/#!/settings/watchlist")]
|
[FieldDefinition(0, Label = "Url", Type = FieldType.Textbox, HelpLink = "https://app.plex.tv/desktop/#!/settings/watchlist")]
|
||||||
public override string Url { get; set; }
|
public override string Url { get; set; }
|
||||||
|
|
|
@ -11,6 +11,10 @@ namespace NzbDrone.Core.ImportLists.Rss
|
||||||
public class RssImportBase<TSettings> : HttpImportListBase<TSettings>
|
public class RssImportBase<TSettings> : HttpImportListBase<TSettings>
|
||||||
where TSettings : RssImportBaseSettings, new()
|
where TSettings : RssImportBaseSettings, new()
|
||||||
{
|
{
|
||||||
|
public override string Name => "RSS List Base";
|
||||||
|
public override ImportListType ListType => ImportListType.Advanced;
|
||||||
|
public override TimeSpan MinRefreshInterval => TimeSpan.FromHours(6);
|
||||||
|
|
||||||
public RssImportBase(IHttpClient httpClient,
|
public RssImportBase(IHttpClient httpClient,
|
||||||
IImportListStatusService importListStatusService,
|
IImportListStatusService importListStatusService,
|
||||||
IConfigService configService,
|
IConfigService configService,
|
||||||
|
@ -20,10 +24,6 @@ namespace NzbDrone.Core.ImportLists.Rss
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ImportListType ListType => ImportListType.Advanced;
|
|
||||||
public override TimeSpan MinRefreshInterval => TimeSpan.FromHours(6);
|
|
||||||
public override string Name => "RSS List Base";
|
|
||||||
|
|
||||||
public override IList<ImportListItemInfo> Fetch()
|
public override IList<ImportListItemInfo> Fetch()
|
||||||
{
|
{
|
||||||
return FetchItems(g => g.GetListItems());
|
return FetchItems(g => g.GetListItems());
|
||||||
|
@ -36,7 +36,7 @@ namespace NzbDrone.Core.ImportLists.Rss
|
||||||
|
|
||||||
public override IImportListRequestGenerator GetRequestGenerator()
|
public override IImportListRequestGenerator GetRequestGenerator()
|
||||||
{
|
{
|
||||||
return new RssImportRequestGenerator()
|
return new RssImportRequestGenerator
|
||||||
{
|
{
|
||||||
Settings = Settings
|
Settings = Settings
|
||||||
};
|
};
|
||||||
|
|
|
@ -83,11 +83,10 @@ namespace NzbDrone.Core.ImportLists.Rss
|
||||||
var content = XmlCleaner.ReplaceEntities(importListResponse.Content);
|
var content = XmlCleaner.ReplaceEntities(importListResponse.Content);
|
||||||
content = XmlCleaner.ReplaceUnicode(content);
|
content = XmlCleaner.ReplaceUnicode(content);
|
||||||
|
|
||||||
using (var xmlTextReader = XmlReader.Create(new StringReader(content), new XmlReaderSettings { DtdProcessing = DtdProcessing.Ignore, IgnoreComments = true }))
|
using var xmlTextReader = XmlReader.Create(new StringReader(content), new XmlReaderSettings { DtdProcessing = DtdProcessing.Ignore, IgnoreComments = true });
|
||||||
{
|
|
||||||
return XDocument.Load(xmlTextReader);
|
return XDocument.Load(xmlTextReader);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (XmlException ex)
|
catch (XmlException ex)
|
||||||
{
|
{
|
||||||
var contentSample = importListResponse.Content.Substring(0, Math.Min(importListResponse.Content.Length, 512));
|
var contentSample = importListResponse.Content.Substring(0, Math.Min(importListResponse.Content.Length, 512));
|
||||||
|
@ -120,18 +119,17 @@ namespace NzbDrone.Core.ImportLists.Rss
|
||||||
|
|
||||||
protected virtual ImportListItemInfo ProcessItem(XElement item)
|
protected virtual ImportListItemInfo ProcessItem(XElement item)
|
||||||
{
|
{
|
||||||
var info = new ImportListItemInfo();
|
var info = new ImportListItemInfo
|
||||||
|
{
|
||||||
|
Title = item.TryGetValue("title", "Unknown")
|
||||||
|
};
|
||||||
|
|
||||||
var guid = item.TryGetValue("guid");
|
var guid = item.TryGetValue("guid");
|
||||||
|
|
||||||
if (guid != null)
|
if (guid != null && int.TryParse(guid, out var tvdbId))
|
||||||
{
|
|
||||||
if (int.TryParse(guid, out var tvdbId))
|
|
||||||
{
|
{
|
||||||
info.TvdbId = tvdbId;
|
info.TvdbId = tvdbId;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
info.Title = item.TryGetValue("title", "Unknown");
|
|
||||||
|
|
||||||
if (info.TvdbId == 0)
|
if (info.TvdbId == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace NzbDrone.Core.ImportLists.Rss
|
||||||
|
|
||||||
public class RssImportBaseSettings : IImportListSettings
|
public class RssImportBaseSettings : IImportListSettings
|
||||||
{
|
{
|
||||||
private RssImportSettingsValidator Validator => new RssImportSettingsValidator();
|
private RssImportSettingsValidator Validator => new ();
|
||||||
|
|
||||||
public string BaseUrl { get; set; }
|
public string BaseUrl { get; set; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue