Skip to main content

Module media

Module media 

Source
Expand description

Audio and video: listed in a package’s logoxide.toml by URL, size, and SHA-256, never stored in it, so a package stays a small git repository and the media stays wherever its owner serves it. A host downloads a file when it’s first played, from url or else each of its mirrors in turn (MediaFile::urls), checks it (verify), and keeps it by its hash (store_path), so versions that list the same file share it. The hash makes every copy as good as the first, so anyone may serve one.

[media]
timings = "timings/"             # each verse's start and end in each file: timings/audio/JHN.vtt

[[media.files]]
path = "audio/JHN.mp3"           # what timings name it by
url = "https://example.org/audio/JHN.mp3"
mirrors = ["https://archive.org/download/bsb-audio/JHN.mp3"]  # tried in order when it fails
size = 31457280
sha256 = "sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
book = "JHN"                     # the book it reads, if one
# timings = "subtitles/john.vtt" # its timings, if not in the timings folder

The transcript is the package’s text ([formats], read like any other), which topos searches; a recording names the edition it reads as a dependency. Releases are judged by the text, so a new hash for the same words is a patch.

Audio only: a recording need not carry a text of its own. [media] text names the dependency whose text it reads, and versification the versification it’s numbered by (SWORD’s names, whose verse counts logoxide has: KJV, NRSV, …); a package with either may have no [formats]. Its timings are checked against that text, else that versification’s counts:

[dependencies]
bsb = { git = "https://example.org/bsb", version = "1" }

[media]
text = "bsb"
versification = "KJV"
timings = "timings/"

Timings say where each verse is in a recording, so an audio Bible can play from a verse and show the verse being read. Each file has a WebVTT file in the timings folder, at its own path with .vtt for its extension (audio/JHN.mp3 → timings/audio/JHN.vtt, so video/JHN.mp4’s are apart), or wherever its own timings says, whose cues are named by the verse they read (a USFM reference; JHN 3:16-17 for a bridge). The cue’s text may be the verse’s, or empty; cues not named by a verse (an introduction, music) are left out. Verse 0 (a psalm’s title) is a verse where the text has one. Any player that reads subtitles shows it:

WEBVTT

JHN 3:16
00:04:31.200 --> 00:04:38.950
For God so loved the world…

Structs§

Media
A package’s [media]
MediaFile
One audio or video file, by where it’s served and what it hashes to
VerseTiming
One verse’s place in a recording (or a bridge’s: verse to last)

Functions§

check_package_timings
Every listed file’s timings checked against the package’s text (logoxide-text’s check_timings), with a problem for a file whose timings aren’t where they should be (in the timings folder, or at its own timings), and for a timings file anywhere under the folder that no listed file has. Empty when all is well. For a recording whose [media] text names a dependency, see check_package_timings_with: here its verses aren’t checked
check_package_timings_with
check_package_timings, with the package [media] text names (text, as installed): the verses are checked against it. Without one, the package’s own text; with none, the counts of [media] versification (SWORD’s systems; another name is a problem); with neither, a problem. When [media] text names a dependency that isn’t given, verses aren’t checked (only their order and the files)
check_sha256
Whether a listed SHA-256 is one: sha256: and 64 hex digits, or the 64 digits alone. It names where the file is kept (store_path), so nothing else is allowed
sha256_digits
The hex digits of a listed SHA-256, with or without its sha256: prefix (the prefix is what logoxide writes; the bare digits are read too)
sha256_hex
A file’s SHA-256 as logoxide lists it: sha256: and lowercase hex
sha256_matches
Whether actual, a hash’s lowercase hex digits, is the SHA-256 listed (in either form, either case)
store_path
Where a host keeps a media file, by its hash: media/9f/9f86… (relative to its cache), so every version that lists it shares one copy
timings
A listed file’s timings from its package, if it has any
timings_path
Where a file’s timings are in its package: its own timings, else its path in the timings folder with .vtt for its extension (timings/audio/JHN.vtt for audio/JHN.mp3); None when it has neither
verify
Whether downloaded bytes are the file listed: its size, then its hash