foley.sources.music_library.credit_parser#

Which titles a video credits, by library: the credit-block parser and the titles file.

titles_by_library() reads a video description’s credits (From Epidemic Sound: blocks, Music by Kevin MacLeod headers, the "Title" Author (site) attribution form) into {library: [titles]} over the registered libraries’ names and aliases. titles_from_json() reads a titles file: a list of titles, or {title: {metadata}}.

Functions

titles_by_library(description, *[, libraries])

The titles a video description credits, by library (default: the registered ones).

titles_from_json(text)

A titles file's JSON: a list of titles, or {title: {metadata}}.

foley.sources.music_library.credit_parser.titles_by_library(description, *, libraries=None)[source]#

The titles a video description credits, by library (default: the registered ones).

A line naming a library (by name or alias, with From/Music by/ Music: and a parenthetical allowed around it) opens its block, and each following line is a title until a blank line; a timestamp, a Song:/Track: label, quotes and bullets are stripped, and links and licence lines skipped. The attribution form ("Title" Kevin MacLeod (incompetech.com)) credits its title wherever it stands.

>>> text = '''Music:
... From Epidemic Sound:
... - 0:00 Night Owl
... - Song: "Morning Light"
... https://www.epidemicsound.com/
...
... "Sneaky Snitch" Kevin MacLeod (incompetech.com)
... Licensed under Creative Commons: By Attribution 4.0 License'''
>>> titles_by_library(text)
{'epidemic_sound': ['Night Owl', 'Morning Light'], 'incompetech': ['Sneaky Snitch']}
Return type:

dict[str, list[str]]

foley.sources.music_library.credit_parser.titles_from_json(text)[source]#

A titles file’s JSON: a list of titles, or {title: {metadata}}.

>>> titles_from_json('["A", "B"]'), titles_from_json('{"A": {"feel": "Bright"}}')
(['A', 'B'], {'A': {'feel': 'Bright'}})
Raises:

MusicLibraryError – If text is not JSON, or not one of those two shapes.

Return type:

Union[list[str], dict[str, dict[str, Any]]]