Chapters v1.0.1 Chapters.Chapter View Source
One chapter entry.
Link to this section Summary
Types
start
- milliseconds since start. e.g. "00:01:30.000" would be90_000
(mandatory)title
- title of that chapter (mandatory)href
- link to jump to that chapter (optional)image
- url to a chapter image (optional)
Functions
Sanitizes the href and image values. Trims them and nils them out if they are an empty string.
Produces an ordered keylist :start, :title, :href, :image
with the start already formatted top a normal playtime for use in output formats
Link to this section Types
t()
View Source
t() :: %Chapters.Chapter{
href: String.t() | nil,
image: String.t() | nil,
start: non_neg_integer(),
title: String.t()
}
t() :: %Chapters.Chapter{ href: String.t() | nil, image: String.t() | nil, start: non_neg_integer(), title: String.t() }
start
- milliseconds since start. e.g. "00:01:30.000" would be90_000
(mandatory)title
- title of that chapter (mandatory)href
- link to jump to that chapter (optional)image
- url to a chapter image (optional)
Link to this section Functions
sanitize(chapter) View Source
Sanitizes the href and image values. Trims them and nils them out if they are an empty string.
iex> %Chapters.Chapter{href: " //foo ", image: " ", start: 0, title: "Title"} |> Chapter.sanitize()
%Chapters.Chapter{href: "//foo", image: nil, start: 0, title: "Title"}
iex> %Chapters.Chapter{href: " ", image: " ", start: 0, title: "Title"} |> Chapter.sanitize()
%Chapters.Chapter{href: nil, image: nil, start: 0, title: "Title"}
to_keylist(chapter) View Source
Produces an ordered keylist :start, :title, :href, :image
with the start already formatted top a normal playtime for use in output formats
iex> %Chapters.Chapter{href: "//foo", image: nil, start: 1234, title: "Title"} |> Chapter.to_keylist() [start: "00:00:01.234", title: "Title", href: "//foo"]
iex> %Chapters.Chapter{href: "", image: "//foo.jpeg", start: 1234, title: "Title"} |> Chapter.to_keylist() [start: "00:00:01.234", title: "Title", image: "//foo.jpeg"]