Build OPML for Chicago Transit Authority feeds

This commit is contained in:
~lucidiot 2023-10-13 22:22:25 +02:00
parent c3ae653194
commit 8921e100fa
3 changed files with 34 additions and 1 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
opml/feeds.opml
opml/nhc.opml
opml/cta.opml
css/sprites.css
img/sprites.png

View File

@ -1,5 +1,5 @@
.PHONY: all
all: css/sprites.css opml/feeds.opml opml/nhc.opml
all: css/sprites.css opml/feeds.opml opml/nhc.opml opml/cta.opml
opml/feeds.opml: feed.xml xquery/feeds_opml.xqy
xidel --silent feed.xml --extract-kind=xquery3 --extract-file=xquery/feeds_opml.xqy --output-format=xml > $@
@ -9,6 +9,10 @@ opml/nhc.opml: bin/build_nhc_opml xquery/nhc_opml.xqy
bin/build_nhc_opml > $@
chmod a+r $@
opml/cta.opml: xquery/cta_opml.xqy
xidel --silent --extract-kind=xquery3 --extract-file=xquery/cta_opml.xqy --output-format=xml > $@
chmod a+r $@
sprites := $(wildcard img/sprites/*.png)
img/sprites.png: $(sprites)

28
xquery/cta_opml.xqy Normal file
View File

@ -0,0 +1,28 @@
<opml version="2.0">
<head>
<title>Chicago Transit Authority RSS feeds</title>
<dateModified>{format-dateTime(adjust-dateTime-to-timezone(current-dateTime(), xs:dayTimeDuration("PT0S")), "[FNn,*-3], [D01] [MNn,*-3] [Y0001] [H01]:[m01]:[s01] GMT")}</dateModified>
<ownerName>lucidiot</ownerName>
<ownerEmail>lucidiot@envs.net</ownerEmail>
<ownerId>https://tilde.town/~lucidiot/contact.html</ownerId>
<docs>http://dev.opml.org/spec2.html</docs>
</head>
<body>
{
(: Open the CTA RSS feeds page and grab the list items. :)
x:parse-html(x:request('https://www.transitchicago.com/rss/default.aspx')/raw)//ul[@class="rsslist"]/li
! <outline text="{substring-after(a/normalize-space(text()), 'All ')}">
{
(., ul/li)
! <outline
type="rss"
version="RSS"
text="{a/normalize-space(text())}"
xmlUrl="{resolve-uri(a/@href, 'https://www.transitchicago.com/rss/default.aspx')}"
language="en-us"
/>
}
</outline>
}
</body>
</opml>