Chapters in the two forms podcasts carry them: the JSON Chapters file that podcast:chapters links to, and Podlove Simple Chapters embedded in the feed as psc:chapters. Both read into one shape and write back out.
A chapters document is a map:
{:version "1.2.0"
:title "Episode 7" :author "…" :podcast-name "…" ; optional
:chapters [{:start-time 94 :title "Donation Segment"
:img "https://…" :url "https://…" :toc false
:end-time 120 :location {:name "…" :geo "geo:…"}}]}
Times are seconds. Chapters keep the order they're given in, and the keys that the format doesn't define are kept too. Reading never throws on content, and what it had to forgive is in the report, in the metadata.
Chapters in the two forms podcasts carry them: the JSON Chapters file
that podcast:chapters links to, and Podlove Simple Chapters embedded in
the feed as psc:chapters. Both read into one shape and write back out.
A chapters document is a map:
{:version "1.2.0"
:title "Episode 7" :author "…" :podcast-name "…" ; optional
:chapters [{:start-time 94 :title "Donation Segment"
:img "https://…" :url "https://…" :toc false
:end-time 120 :location {:name "…" :geo "geo:…"}}]}
Times are seconds. Chapters keep the order they're given in, and the keys
that the format doesn't define are kept too. Reading never throws on
content, and what it had to forgive is in the report, in the metadata.(at doc seconds)The chapter of doc that is playing seconds into the media, or nil
before the first chapter starts.
The chapter of `doc` that is playing `seconds` into the media, or nil before the first chapter starts.
(emit-json doc)(emit-json doc {:keys [pretty?] :or {pretty? true} :as opts})The chapters map doc as a JSON Chapters document, indented unless
opts has :pretty? false. A doc without a :version gets the version
that this namespace writes.
The chapters map `doc` as a JSON Chapters document, indented unless `opts` has :pretty? false. A `doc` without a :version gets the version that this namespace writes.
(from-lines lines)The chapters map of the timestamps in lines, the lines of the plain
text of show notes, or nil when they list no chapters.
Each chapter is on a line of its own, e.g. "12:34 The topic" or "The topic (12:34)". The time comes first, or last when no line starts with one. Two lines with the time first make a list, and so do three with the time last in rising order. The report says the chapters were inferred.
A caller that has the plain text of the notes already can give its lines here, so they're parsed once.
The chapters map of the timestamps in `lines`, the lines of the plain text of show notes, or nil when they list no chapters. Each chapter is on a line of its own, e.g. "12:34 The topic" or "The topic (12:34)". The time comes first, or last when no line starts with one. Two lines with the time first make a list, and so do three with the time last in rising order. The report says the chapters were inferred. A caller that has the plain text of the notes already can give its lines here, so they're parsed once.
(from-psc psc)The chapters map of the Podlove chapters psc, the :psc/chapters map of
a feed item. A chapter whose start isn't a timestamp is dropped, and the
report says so.
The chapters map of the Podlove chapters `psc`, the :psc/chapters map of a feed item. A chapter whose start isn't a timestamp is dropped, and the report says so.
(from-text s)The chapters map of the timestamps in the show notes s, HTML or plain
text, with each chapter on a line of its own.
The chapters map of the timestamps in the show notes `s`, HTML or plain text, with each chapter on a line of its own.
(jump doc seconds direction)(jump doc seconds direction opts)The position in seconds that a jump from seconds into the media goes
to, by the table of contents of doc. The direction is :next or
:previous, and opts can give the :restart seconds.
A jump to the next chapter goes to the first chapter that starts after
seconds. It's nil after the start of the last chapter. A jump back
goes to the start of the chapter that plays. In the first :restart
seconds of a chapter, it goes to the chapter before instead. Before the
first chapter, it goes to 0.
Chapters with :toc false aren't in the table of contents, as JSON Chapters has it, so no jump goes to them. No standard says where a jump back goes, so the default :restart is only a choice.
The position in seconds that a jump from `seconds` into the media goes to, by the table of contents of `doc`. The `direction` is :next or :previous, and `opts` can give the :restart seconds. A jump to the next chapter goes to the first chapter that starts after `seconds`. It's nil after the start of the last chapter. A jump back goes to the start of the chapter that plays. In the first :restart seconds of a chapter, it goes to the chapter before instead. Before the first chapter, it goes to 0. Chapters with :toc false aren't in the table of contents, as JSON Chapters has it, so no jump goes to them. No standard says where a jump back goes, so the default :restart is only a choice.
(parse-json s)The chapters map of the JSON Chapters document s.
Bad content doesn't throw. The report says what was left out instead:
The chapters map of the JSON Chapters document `s`. Bad content doesn't throw. The report says what was left out instead: - a document that isn't a JSON object reads as no chapters - a chapter that isn't an object is left out - a title, link or place name that isn't text is left out, but a number counts as text
(report doc)The diagnostics recorded while reading doc.
The diagnostics recorded while reading `doc`.
How many seconds of a chapter a listener can hear before a jump back goes to the start of that chapter. Earlier in the chapter, the jump goes to the chapter before it, as in most players.
How many seconds of a chapter a listener can hear before a jump back goes to the start of that chapter. Earlier in the chapter, the jump goes to the chapter before it, as in most players.
(sorted doc)The chapters of doc that have a start time, in order of it.
The chapters of `doc` that have a start time, in order of it.
(to-psc doc)The Podlove chapters of the chapters map doc, as the :psc/chapters map
of a feed item, which from-psc reads back, e.g. for a feed that embeds
chapters as well as linking to them. Podlove requires a start time, so
the chapters without one are left out.
(assoc item :psc/chapters (to-psc doc))
The Podlove chapters of the chapters map `doc`, as the :psc/chapters map
of a feed item, which from-psc reads back, e.g. for a feed that embeds
chapters as well as linking to them. Podlove requires a start time, so
the chapters without one are left out.
(assoc item :psc/chapters (to-psc doc))(update-image-urls doc f)The chapters map doc with the URL of each chapter's image replaced by
what f gives for it.
The images of an MP3 file's chapters come as data URLs, but JSON Chapters says that an image is a URL for a player to fetch. A host writes each one as a file before it serves the chapters file, e.g. with a function of its own, write-image!, that gives the URL of the file:
(update-image-urls doc #(if-let [{:keys [type data]}
(image/from-data-url %)]
(write-image! type data)
%))
The chapters map `doc` with the URL of each chapter's image replaced by
what `f` gives for it.
The images of an MP3 file's chapters come as data URLs, but JSON
Chapters says that an image is a URL for a player to fetch. A host
writes each one as a file before it serves the chapters file, e.g. with
a function of its own, write-image!, that gives the URL of the file:
(update-image-urls doc #(if-let [{:keys [type data]}
(image/from-data-url %)]
(write-image! type data)
%))The JSON Chapters format version this namespace writes: version 1.2 of 15 April 2021.
The JSON Chapters format version this namespace writes: version 1.2 of 15 April 2021.
(visible doc)The chapters of doc meant for the table of contents, in order: those
whose :toc isn't false.
The chapters of `doc` meant for the table of contents, in order: those whose :toc isn't false.
(with-end-times doc)The chapters of doc in order, each with the start of the next as its
:end-time when it has none.
The chapters of `doc` in order, each with the start of the next as its :end-time when it has none.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |