From 78fc03c7c6b9b82b27020a971b00e72120edd67d Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Mon, 5 Aug 2019 01:05:49 +0100 Subject: [PATCH] Make author stuff optional --- PolyFeed/FeedBuilder.cs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/PolyFeed/FeedBuilder.cs b/PolyFeed/FeedBuilder.cs index 635e461..38ceb9a 100644 --- a/PolyFeed/FeedBuilder.cs +++ b/PolyFeed/FeedBuilder.cs @@ -123,14 +123,20 @@ namespace PolyFeed else // It requires one, apparently nextItem.LastUpdated = DateTimeOffset.Now; - SyndicationPerson author = new SyndicationPerson( - nextNode.QuerySelectorAttributeOrText(source.Entries.AuthorName).Trim(), - "" - ); - if(source.Entries.AuthorUrl != null) - author.Uri = nextNode.QuerySelectorAttributeOrText(source.Entries.AuthorUrl); - nextItem.AddContributor(author); + if (source.Entries.AuthorName != null) { + SyndicationPerson author = new SyndicationPerson( + nextNode.QuerySelectorAttributeOrText(source.Entries.AuthorName).Trim(), + "" + ); + if (source.Entries.AuthorUrl != null) + author.Uri = nextNode.QuerySelectorAttributeOrText(source.Entries.AuthorUrl); + + nextItem.AddContributor(author); + } + else + nextItem.AddContributor(new SyndicationPerson("Unknown", "")); + await feed.Write(nextItem);