Minor cleanup in RssImport

pull/5643/head
Bogdan 1 year ago committed by Mark McDowall
parent c6b543e072
commit 477bfb7835

@ -8,6 +8,10 @@ namespace NzbDrone.Core.ImportLists.Rss.Plex
{
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,
IImportListStatusService importListStatusService,
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()
{
return new PlexRssImportParser(_logger);

@ -8,18 +8,13 @@ namespace NzbDrone.Core.ImportLists.Rss.Plex
{
public class PlexRssImportParser : RssImportBaseParser
{
private readonly Logger _logger;
public PlexRssImportParser(Logger logger)
: base(logger)
: base(logger)
{
_logger = logger;
}
protected override ImportListItemInfo ProcessItem(XElement item)
{
var info = new ImportListItemInfo();
var guid = item.TryGetValue("guid", string.Empty);
var category = item.TryGetValue("category");
if (category != "show")
@ -27,7 +22,12 @@ namespace NzbDrone.Core.ImportLists.Rss.Plex
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))
{

@ -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")]
public override string Url { get; set; }

@ -11,6 +11,10 @@ namespace NzbDrone.Core.ImportLists.Rss
public class RssImportBase<TSettings> : HttpImportListBase<TSettings>
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,
IImportListStatusService importListStatusService,
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()
{
return FetchItems(g => g.GetListItems());
@ -36,7 +36,7 @@ namespace NzbDrone.Core.ImportLists.Rss
public override IImportListRequestGenerator GetRequestGenerator()
{
return new RssImportRequestGenerator()
return new RssImportRequestGenerator
{
Settings = Settings
};

@ -83,10 +83,9 @@ namespace NzbDrone.Core.ImportLists.Rss
var content = XmlCleaner.ReplaceEntities(importListResponse.Content);
content = XmlCleaner.ReplaceUnicode(content);
using (var xmlTextReader = XmlReader.Create(new StringReader(content), new XmlReaderSettings { DtdProcessing = DtdProcessing.Ignore, IgnoreComments = true }))
{
return XDocument.Load(xmlTextReader);
}
using var xmlTextReader = XmlReader.Create(new StringReader(content), new XmlReaderSettings { DtdProcessing = DtdProcessing.Ignore, IgnoreComments = true });
return XDocument.Load(xmlTextReader);
}
catch (XmlException ex)
{
@ -120,19 +119,18 @@ namespace NzbDrone.Core.ImportLists.Rss
protected virtual ImportListItemInfo ProcessItem(XElement item)
{
var info = new ImportListItemInfo();
var info = new ImportListItemInfo
{
Title = item.TryGetValue("title", "Unknown")
};
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)
{
throw new UnsupportedFeedException("Each item in the RSS feed must have a guid element with a TVDB ID");

@ -14,7 +14,7 @@ namespace NzbDrone.Core.ImportLists.Rss
public class RssImportBaseSettings : IImportListSettings
{
private RssImportSettingsValidator Validator => new RssImportSettingsValidator();
private RssImportSettingsValidator Validator => new ();
public string BaseUrl { get; set; }

Loading…
Cancel
Save