1
0
Fork 0
mirror of https://github.com/sbrl/PolyFeed.git synced 2024-06-27 09:44:55 +00:00

Compare commits

...

10 commits

5 changed files with 92 additions and 9 deletions

View file

@ -111,24 +111,32 @@ namespace PolyFeed
);
}
if (source.Entries.Published != null) {
if (source.Entries.LastUpdated != null) {
nextItem.LastUpdated = DateTime.Parse(
nextNode.QuerySelectorAttributeOrText(
source.Entries.LastUpdated
)
);
}
else if (source.Entries.Published != null) // Use the publish date if available
nextItem.LastUpdated = nextItem.Published;
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);

View file

@ -96,7 +96,14 @@ namespace PolyFeed
/// </summary>
public SelectorSettings LastUpdated { get; set; }
/// <summary>
/// The selector for the name of the author of an entry.
/// </summary>
public SelectorSettings AuthorName { get; set; }
/// <summary>
/// The selector for the url that points to a page that represents
/// the author of an entry.
/// </summary>
public SelectorSettings AuthorUrl { get; set; }
}

View file

@ -15,6 +15,12 @@ namespace PolyFeed.Helpers
if (selectedNode == null)
throw new ApplicationException($"Error: Selector {settings.Selector} failed to find any elements.");
// Hack: Add physical newlines to <br />s to make date parsing easier for LastUpdated / Published.
// Also means that we match Firefox functionality.
foreach (HtmlNode nextNode in htmlNode.QuerySelectorAll("br")) {
nextNode.InnerHtml = "\n";
}
if (string.IsNullOrWhiteSpace(settings.Attribute))
return selectedNode.InnerText;
@ -48,7 +54,7 @@ namespace PolyFeed.Helpers
if (node.Attributes["href"] != null) attributeName = "href";
if (node.Attributes["src"] != null) attributeName = "src";
if (node.Attributes[attributeName] == null)
if (attributeName == null || node.Attributes[attributeName] == null)
return;
node.Attributes[attributeName].Value = new Uri(

View file

@ -0,0 +1,30 @@
[feed]
output = "OCReMix-Remix-Albums.atom"
# Actual Official Feed: http://ocremix.org/feeds/ten20/
url = "https://ocremix.org/albums/"
source_type = "html"
title = "OCReMix Albums"
subtitle = "Latest Albums on OC ReMix"
logo_url = { selector = ".header", attribute = "src" }
[entries]
selector = ".area-link"
title = "{{a.main.featured}}"
content = """
<p>{td:first-child}</p>
<p>{td:nth-child(2)}</p>
"""
url = { selector = "a.main.featured", attribute = "href" }
# or, for a direct link to YouTube:
#url = { selector = "a.main.featured", attribute = "data-preview" }
# author_name = { selector = "" }
# author_url = { selector = "" }
published = { selector = "td:nth-child(4)", attribute = "" }
# last_updated = { selector = "", attribute = "" }

View file

@ -0,0 +1,32 @@
[feed]
output = "OCReMix-Remixes.atom"
# Actual Official Feed: http://ocremix.org/feeds/ten20/
url = "https://ocremix.org/remixes/?&offset=0&sort=datedesc"
source_type = "html"
title = "OCReMixes"
subtitle = "Latest remixes on OC ReMix"
logo_url = { selector = ".header", attribute = "src" }
[entries]
selector = ".area-link"
title = "{{a.main.featured}} by {{td:nth-child(2) a.featured}} - {{.color-secondary}}"
content = """
<p>{a}</p>
<p><strong>{a.main.featured}</strong></p>
<p>{td:nth-child(2)}</p>
<p>Remixing {.color-secondary}</p>
"""
url = { selector = "a.main.featured", attribute = "href" }
# or, for a direct link to YouTube:
#url = { selector = "a.main.featured", attribute = "data-preview" }
author_name = { selector = "td:nth-child(2) a.featured" }
author_url = { selector = "td:nth-child(2) a.featured", attribute = "href" }
published = { selector = "td:nth-child(3)", attribute = "" }
# last_updated = { selector = "", attribute = "" }