an.sound_fetch#
Add a sound from a URL, with its provenance and the cut taken (an#318).
A production that sources its music or an effect from the web used to write
the same script each time: download, cut with ffmpeg, type an AssetSource
by hand, an.sounds.add_sound(). add_sound_from_url() is that script:
the download is a seam,
fetcher=: any(url) -> Fetched(the bytes in any container ffmpeg reads, and what the source says about itself). The default,yb_fetcher(), uses yb when it is installed (pip install ybwith itsyt-dlpextra); it is never a dependency ofan. Another ingest (braidio’s) plugs in here;the cut (
start,duration,fade_out) is made by ffmpeg into a 16-bit WAV, and recorded with the source, soan creditssays which part of which page it is (“0:07.9–0:08.8 of <url>”);the licence is the caller’s statement, never guessed: required, and
"unknown"says so explicitly (the sound is then UNVERIFIED).
>>> fetched = Fetched(audio=b"...", url="https://example.org/a", id="a", author="Ann")
>>> fetched.provider
'web'
Module Attributes
how |
Functions
|
Fetch |
|
|
|
Fetch the audio of |
Classes
|
What a fetcher returns: the media's bytes, and what its page says about it. |
- class an.sound_fetch.Fetched(audio, url, id=None, title=None, author=None, provider='web')[source]#
Bases:
objectWhat a fetcher returns: the media’s bytes, and what its page says about it.
- an.sound_fetch.Fetcher#
how
add_sound_from_url()gets the media.- Type:
(url) -> Fetched
- an.sound_fetch.add_sound_from_url(store, key, url, *, license, fetcher=None, start=None, duration=None, fade_out=None, provider=None, author=None, description='')[source]#
Fetch
url, cut it, and put it in the soundsstoreunderkeywith its provenance.- Return type:
- license: the licence code the caller vouches for — required, never
guessed;
"unknown"(orNone) records that nobody has said
fetcher:
(url) -> Fetched(defaultyb_fetcher()) start, duration, fade_out: the cut, in seconds of the fetched media provider, author: override what the fetcher reported