Liking cljdoc? Tell your friends :D

dk.simongray.podcast.feed

The feed model: canonical Hiccup in, maps out, and back again, by a tag registry.

A feed is the channel map itself, with the items under :rss/items and the live items under :podcast/live-items. In the map:

  • a scalar element becomes a coerced scalar
  • an element with attributes or children becomes a map
  • a repeatable element becomes a vector
  • an element that the registry doesn't know stays as Hiccup under :xml/unknown

Nothing throws on a bad value, which stays a string, and the report says so. The report is in the metadata of the result under :podcast/report.

The feed model: canonical Hiccup in, maps out, and back again, by a tag
registry.

A feed is the channel map itself, with the items under :rss/items and
the live items under :podcast/live-items. In the map:

- a scalar element becomes a coerced scalar
- an element with attributes or children becomes a map
- a repeatable element becomes a vector
- an element that the registry doesn't know stays as Hiccup under
  :xml/unknown

Nothing throws on a bad value, which stays a string, and the report says
so. The report is in the metadata of the result under :podcast/report.
raw docstring

diffclj/s

(diff before after)

What changed from the feed before to the feed after, by item identity:

{:added [item ...] :removed [item ...] :changed [{:before :after} ...]
 :renamed [{:before :after} ...]
 :unchanged 42
 :live-items {:added [...] :removed [...] :changed [...] :unchanged 1}
 :channel-changed? false}

Items without an identity, with neither a guid nor an enclosure, aren't compared, and neither are the later of the items that share one. An item that's a removed one under a new guid is :renamed rather than added and removed: one with the same enclosure URL, or else the same title and a date a day apart at most, when only one item on each side matches. The channel counts as changed when anything but its items, live items and timestamps differs.

What changed from the feed `before` to the feed `after`, by item identity:

    {:added [item ...] :removed [item ...] :changed [{:before :after} ...]
     :renamed [{:before :after} ...]
     :unchanged 42
     :live-items {:added [...] :removed [...] :changed [...] :unchanged 1}
     :channel-changed? false}

Items without an identity, with neither a guid nor an enclosure, aren't
compared, and neither are the later of the items that share one. An
item that's a removed one under a new guid is :renamed rather than added
and removed: one with the same enclosure URL, or else the same title and
a date a day apart at most, when only one item on each side matches. The
channel counts as changed when anything but its items, live items and
timestamps differs.
sourceraw docstring

emitclj/s

(emit feed)
(emit feed {:keys [registry namespaces] :or {registry spec/default} :as opts})

The canonical Hiccup document of feed, with the opts below:

  • :registry, the tag registry, spec/default by default
  • :namespaces, a map from alias to URI for the elements of namespaces that the feed wasn't parsed with, or for another URI of one that it was

It takes the shorthand that a producer can write, and leaves out nil values. The known namespaces, those of :namespaces, and the foreign namespaces recorded when the feed was parsed go along as metadata under :xml/namespaces, for the document to declare.

The canonical Hiccup document of `feed`, with the `opts` below:

- :registry, the tag registry, spec/default by default
- :namespaces, a map from alias to URI for the elements of namespaces
  that the feed wasn't parsed with, or for another URI of one that it was

It takes the shorthand that a producer can write, and leaves out nil
values. The known namespaces, those of :namespaces, and the foreign
namespaces recorded when the feed was parsed go along as metadata under
:xml/namespaces, for the document to declare.
sourceraw docstring

join-pagesclj/s

(join-pages pages)

One feed of pages, the parsed pages of a feed that comes in pages, in their order, or nil for no pages.

The feed is the channel of the first page, with the items of all the pages. A feed can gain items while its pages are read, so an item of a later page is left out when an earlier page has it.

The report has the diagnostics of the first page. From a later page, it has the diagnostics of the items that the feed takes from the page, and the diagnostics without a path. The path of a diagnostic names the item where the feed has it.

One feed of `pages`, the parsed pages of a feed that comes in pages, in
their order, or nil for no pages.

The feed is the channel of the first page, with the items of all the
pages. A feed can gain items while its pages are read, so an item of a
later page is left out when an earlier page has it.

The report has the diagnostics of the first page. From a later page, it
has the diagnostics of the items that the feed takes from the page, and
the diagnostics without a path. The path of a diagnostic names the item
where the feed has it.
sourceraw docstring

new-episodesclj/s

(new-episodes url before after)
(new-episodes url
              before
              after
              {:keys [only-newer?] :or {only-newer? true} :as opts})

The ids of the episodes that the parse after of the feed at url has and the parse before hadn't, by the opts below, as a map:

{:added      [[feed-guid item-guid] …]  ; the new ones, oldest first
 :backfilled [[feed-guid item-guid] …]  ; older ones that appeared
 :renamed    [[old-id new-id] …]}       ; those under a new guid

An episode is new unless it's older than the newest one of before, so that a host that publishes its back catalogue again, or rewrites guids that diff can't pair, adds no old episodes. One without a date is new. Without before, there are none, since a first parse finds the back catalogue. The opts are:

  • :only-newer?, false to count every episode that appeared as new
The ids of the episodes that the parse `after` of the feed at `url` has
and the parse `before` hadn't, by the `opts` below, as a map:

    {:added      [[feed-guid item-guid] …]  ; the new ones, oldest first
     :backfilled [[feed-guid item-guid] …]  ; older ones that appeared
     :renamed    [[old-id new-id] …]}       ; those under a new guid

An episode is new unless it's older than the newest one of `before`, so
that a host that publishes its back catalogue again, or rewrites guids
that diff can't pair, adds no old episodes. One without a date is new.
Without `before`, there are none, since a first parse finds the back
catalogue. The `opts` are:

- :only-newer?, false to count every episode that appeared as new
sourceraw docstring

normalizeclj/s

(normalize feed)
(normalize feed opts)

The feed in the shape of the model, by the :registry of opts, spec/default by default.

It expands the shorthand that a producer can write, e.g.:

{:rss/guid "x"}            ; for {:rss/guid {:content "x"}}
{:podcast/transcripts {…}}  ; for {:podcast/transcripts [{…}]}

A string where the model takes another type is read as parse reads the text of XML, e.g. a date, a duration such as "30:00" or "no" for false, and its report has :feed/string-value for each. A string that doesn't read stays, so that the validator reports it. A parsed feed comes back unchanged.

The `feed` in the shape of the model, by the :registry of `opts`,
spec/default by default.

It expands the shorthand that a producer can write, e.g.:

    {:rss/guid "x"}            ; for {:rss/guid {:content "x"}}
    {:podcast/transcripts {…}}  ; for {:podcast/transcripts [{…}]}

A string where the model takes another type is read as parse reads the
text of XML, e.g. a date, a duration such as "30:00" or "no" for false,
and its report has :feed/string-value for each. A string that doesn't
read stays, so that the validator reports it. A parsed feed comes back
unchanged.
sourceraw docstring

parseclj/s

(parse tree)
(parse tree {:keys [registry] :or {registry spec/default} :as opts})

Parse the canonical Hiccup tree of an RSS 2.0 document into a feed map by the :registry of opts, spec/default by default.

The diagnostics go along as metadata under :podcast/report, and the foreign namespaces that the document used under :xml/namespaces. What resolving the namespaces found stays under :xml/report on the tree. The attributes of rss other than its version, and those of channel, have no place in the model, and the report says when there are any.

Parse the canonical Hiccup `tree` of an RSS 2.0 document into a feed map
by the :registry of `opts`, spec/default by default.

The diagnostics go along as metadata under :podcast/report, and the
foreign namespaces that the document used under :xml/namespaces. What
resolving the namespaces found stays under :xml/report on the tree. The
attributes of rss other than its version, and those of channel, have no
place in the model, and the report says when there are any.
sourceraw docstring

reportclj/s

(report feed)

The diagnostics recorded while parsing feed, each with its message from the catalogue of diagnostics.

The diagnostics recorded while parsing `feed`, each with its message from
the catalogue of diagnostics.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close