HLS playlists, the streams that feeds offer as alternate enclosures: what a multivariant playlist says of its variants and renditions, and what a media playlist says of its duration.
A multivariant playlist reads as a map like this, with the URLs made absolute against the playlist's own:
{:kind :multivariant
:version 6
:variants [{:url "https://…/720p.m3u8" :bandwidth 1352370
:average-bandwidth 831345
:codecs "hvc1.1.6.L93.90,mp4a.40.2"
:width 1280 :height 720 :frame-rate 29.97
:subtitles "subs"}]
:renditions [{:type :subtitles :group-id "subs" :name "English"
:language "en" :default? true :autoselect? true
:url "https://…"}]}
A media playlist reads as one like this:
{:kind :media :target-duration 6 :segments 816 :duration 4895.9
:playlist-type "VOD" :ended? true}
The reading follows RFC 8216 and never throws on content.
HLS playlists, the streams that feeds offer as alternate enclosures:
what a multivariant playlist says of its variants and renditions, and
what a media playlist says of its duration.
A multivariant playlist reads as a map like this, with the URLs made
absolute against the playlist's own:
{:kind :multivariant
:version 6
:variants [{:url "https://…/720p.m3u8" :bandwidth 1352370
:average-bandwidth 831345
:codecs "hvc1.1.6.L93.90,mp4a.40.2"
:width 1280 :height 720 :frame-rate 29.97
:subtitles "subs"}]
:renditions [{:type :subtitles :group-id "subs" :name "English"
:language "en" :default? true :autoselect? true
:url "https://…"}]}
A media playlist reads as one like this:
{:kind :media :target-duration 6 :segments 816 :duration 4895.9
:playlist-type "VOD" :ended? true}
The reading follows RFC 8216 and never throws on content.(parse s)(parse s url)The HLS playlist s, with its URIs made absolute against url, the
playlist's own, as a map whose :kind is :multivariant or :media, or nil
when s isn't a playlist.
The HLS playlist `s`, with its URIs made absolute against `url`, the playlist's own, as a map whose :kind is :multivariant or :media, or nil when `s` isn't a playlist.
(playlist? {:keys [url type] :as enclosure})Whether the enclosure, or any map of a :url and a :type, is an HLS
playlist: by its type, or by a path that ends in .m3u8 or .m3u.
Whether the `enclosure`, or any map of a :url and a :type, is an HLS playlist: by its type, or by a path that ends in .m3u8 or .m3u.
(read! url)(read! url opts)Read the HLS playlist at url with opts, and give what parse gives,
on the JVM at once and in ClojureScript as a promise.
For a multivariant playlist, the media playlist of its first variant is read too, for the :duration, :segments and :ended? of the stream. A failure there leaves those out, with the diagnostic under :report.
The opts are :send, :allow-pred, :headers, :timeout-seconds,
:max-bytes and :user-agent, as for any request. Nothing that the network
or the server does throws: a failed request gives :file/unreachable under
:error, and a text that isn't a playlist gives :file/malformed.
Read the HLS playlist at `url` with `opts`, and give what parse gives, on the JVM at once and in ClojureScript as a promise. For a multivariant playlist, the media playlist of its first variant is read too, for the :duration, :segments and :ended? of the stream. A failure there leaves those out, with the diagnostic under :report. The `opts` are :send, :allow-pred, :headers, :timeout-seconds, :max-bytes and :user-agent, as for any request. Nothing that the network or the server does throws: a failed request gives :file/unreachable under :error, and a text that isn't a playlist gives :file/malformed.
The media types of an HLS playlist, in lower case.
The media types of an HLS playlist, in lower case.
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 |