mirror of
https://github.com/sbrl/PolyFeed.git
synced 2024-06-30 10:14:56 +00:00
Compare commits
10 commits
a060a10b55
...
a8a9a33fa6
Author | SHA1 | Date | |
---|---|---|---|
|
a8a9a33fa6 | ||
|
fe5f7bfbaa | ||
|
78fc03c7c6 | ||
|
54ab735562 | ||
|
86f983c22c | ||
|
132322801c | ||
|
cb4e730f98 | ||
|
39a068d14b | ||
|
ffb7318382 | ||
|
c179a77cc3 |
|
@ -111,16 +111,20 @@ 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;
|
||||
|
||||
|
||||
if (source.Entries.AuthorName != null) {
|
||||
SyndicationPerson author = new SyndicationPerson(
|
||||
nextNode.QuerySelectorAttributeOrText(source.Entries.AuthorName).Trim(),
|
||||
""
|
||||
|
@ -129,6 +133,10 @@ namespace PolyFeed
|
|||
author.Uri = nextNode.QuerySelectorAttributeOrText(source.Entries.AuthorUrl);
|
||||
|
||||
nextItem.AddContributor(author);
|
||||
}
|
||||
else
|
||||
nextItem.AddContributor(new SyndicationPerson("Unknown", ""));
|
||||
|
||||
|
||||
await feed.Write(nextItem);
|
||||
|
||||
|
|
|
@ -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; }
|
||||
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
30
examples/ocremix-albums.toml
Normal file
30
examples/ocremix-albums.toml
Normal 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 = "" }
|
32
examples/ocremix-remixes.toml
Normal file
32
examples/ocremix-remixes.toml
Normal 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 = "" }
|
Loading…
Reference in a new issue