Global

Global

Members

actions constant

Naming convention:

CRUD:

  • create
  • delete

actions constant

Naming convention:

CRUD:

  • create
  • delete

actions constant

Naming convention:

CRUD:

  • create
  • delete

aliases constant

To avoid duplicate aliases. The commander doesn’t complain about duplicates.

converted Set constant

A set of output file paths. To avoid duplicate rendering by a second run of the script.

First run: 01 Hintergrund.MP3 -> 01-Hintergrund.m4a

Second run:

  • not:
    1. 01 Hintergrund.MP3 -> 01-Hintergrund.m4a
    2. 01-Hintergrund.m4a -> 01-Hintergrund.m4a (bad)
  • but:
    1. 01 Hintergrund.MP3 -> 01-Hintergrund.m4a

entity

let entity = {
  id: 'Q202698',
  type: 'item',
  modified: '2020-03-20T20:27:33Z',
  labels: { de: 'Yesterday', en: 'Yesterday' },
  descriptions: {
    en: 'original song written and composed by Lennon-McCartney',
    de: 'Lied von The Beatles'
  },
  aliases: {},
  claims: {
    P175: [ 'Q1299' ],
    P31: [ 'Q207628', 'Q7366' ],
    P435: [ '0c80db24-389e-3620-8e0b-84dc2b7c009a' ],
    P646: [ '/m/01227d' ]
  },
  sitelinks: {
    arwiki: 'يسترداي',
    cawiki: 'Yesterday',
    cswiki: 'Yesterday (píseň)',
    dawiki: 'Yesterday',
    dewiki: 'Yesterday',
    elwiki: 'Yesterday (τραγούδι, The Beatles)',
    enwiki: 'Yesterday (Beatles song)'
  }
}

mutations constant

Naming convention:

CRUD:

  • create
  • delete

mutations constant

Naming convention:

CRUD:

  • create
  • delete

mutations constant

Naming convention:

CRUD:

  • create
  • delete

resolvedTexImages constant

For images in the TeX file which appear multiple times in one file.

state constant

To create virtual video devices on linux run this commands:

sudo apt install v4l2loopback-dkms
sudo apt install apt install v4l2loopback-utils
sudo modprobe v4l2loopback devices=2

Capture desktop

ffmpeg -f x11grab -r 15 -s 1280x720 -i :0.0+0,0 -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video0

Show image

ffmpeg -loop 1 -re -i image.jpg -f v4l2 -vcodec rawvideo -pix_fmt yuv420p /dev/video0

For example

ffmpeg -loop 1 -re -i /usr/share/backgrounds/Headstock_by_Bernhard_Hanakam.jpg -f v4l2 -vcodec rawvideo -pix_fmt yuv420p /dev/video0
ffmpeg -loop 1 -re -i /usr/share/backgrounds/More_Kamikochi_by_mendhak.jpg  -f v4l2 -vcodec rawvideo -pix_fmt yuv420p /dev/video1

Show video

ffmpeg -re -i video.mp4 -f v4l2 /dev/video2

For example

ffmpeg -re -i /var/data/baldr/media/09/10_Romantik/10_Programmmusik/60_Berlioz-Symphonie-fantasique/Hector-Berlioz_Arte-Dokumentation.mp4 -f v4l2 /dev/video1

https://webrtc.github.io/samples/

mediaStream.getVideoTracks()[0].getConstraints()
navigator.mediaDevices.getSupportedConstraints()
{
  "aspectRatio": true,
  "channelCount": true,
  "depthFar": true,
  "depthNear": true,
  "deviceId": true,
  "echoCancellation": true,
  "facingMode": true,
  "focalLengthX": true,
  "focalLengthY": true,
  "frameRate": true,
  "groupId": true,
  "height": true,
  "latency": true,
  "sampleRate": true,
  "sampleSize": true,
  "videoKind": true,
  "volume": true,
  "width": true
}
navigator.mediaDevices.enumerateDevices()
[
  {
    "deviceId": "21c19a409344f4bee3a71d7b1b14d1bb452dcd86cba8c9c5136a992c33241c08",
    "kind": "videoinput",
    "label": "USB Webcam (0bda:5727)",
    "groupId": ""
  }
]

Secure contexts:

Chrome

Also you can add whiltelist by open chrome://flags and search for unsafely-treat-insecure-origin-as-secure: chrome://flags/#unsafely-treat-insecure-origin-as-secure

Methods

action (filePath)

Convert a Audacity text mark file into a YAML file.

1.488171	1.488171	Sample 1
11.635583	12.940996	Sample 2 (begin + end)
13.846082	13.846082	Sample 3
---
- id: sample 1
  title: Sample 1
  start_time: 1.488171
  end_time: 11.635583
- id: sample 2 (begin + end)
  title: Sample 2 (begin + end)
  start_time: 11.635583
  end_time: 12.940996
- id: '3'
  title: '3'
  start_time: 13.846082
Name Type Description
filePath String

The file path of the Audacity’s text mark file.

action ()

Generate from TeX files with cloze texts SVGs for baldr.

action (files, cmdObj)

Convert multiple files.

Name Type Description
files Array

An array of input files to convert.

cmdObj Object

The command object from the commander.

action (files)

Rename a media asset or all child asset of the parent working directory after the id in the meta data file.

Name Type Description
files Array

An array of input files, comes from the commanders’ variadic parameter [files...].

action (files)

Name Type Description
files Array

An array of input files, comes from the commanders’ variadic parameter [files...].

action ()

Open base path.

action (files)

Rename files.

Name Type Description
files Array

An array of input files, comes from the commanders’ variadic parameter [files...].

action (filesOrText)

Name Type Description
filesOrText Array

An array of input files, comes from the commanders’ variadic parameter [files...]

action (filesOrText)

Name Type Description
filesOrText Array

An array of input files, comes from the commanders’ variadic parameter [files...] or a text block in the first element of the array.

action (files)

Name Type Description
files Array

An array of input files, comes from the commanders’ variadic parameter [files...].

action (files) async

Name Type Description
files Array

An array of input files, comes from the commanders’ variadic parameter [files...].

action (files)

Name Type Description
files Array

An array of input files, comes from the commanders’ variadic parameter [files...].

action (files)

Name Type Description
files Array

An array of input files, comes from the commanders’ variadic parameter [files...].

action (metadataType, itemId, arg1, arg2) async

Name Type Description
metadataType String

For example group,instrument,person,song

itemId String

For example Q123

arg1 String
arg2 String

action (files)

Write the metadata YAML file.

Name Type Description
files Array

An array of input files, comes from the commanders’ variadic parameter [files...].

action (files)

Validate YAML files.

Name Type Description
files String

The media file path.

actionHandler (commandName)

We use a closure to be able te require the subcommands ad hoc on invocation. To avoid long loading times by many subcommands.

Name Type Description
commandName String

The name of the command.

cleanMatch (match, excludeCaptureGroups)

Name Type Description
match *
excludeCaptureGroups Array

An array of capture group strings to exclude in the result matches for example regexp: (itemize|compactitem|sub) -> ['itemize', 'compactitem', 'sub']

collectMusicMetaData (inputFile)object async

Output from music-metadata:

{
  format: {
    tagTypes: [ 'ID3v2.3', 'ID3v1' ],
    lossless: false,
    container: 'MPEG',
    codec: 'MP3',
    sampleRate: 44100,
    numberOfChannels: 2,
    bitrate: 192000,
    codecProfile: 'CBR',
    numberOfSamples: 18365184,
    duration: 416.4440816326531
  },
  native: undefined,
  quality: { warnings: [] },
  common: {
    track: { no: 2, of: 7 },
    disk: { no: 1, of: 1 },
    title: 'Symphonie fantastique, Op. 14: II. Un bal',
    artists: [ 'Hector Berlioz' ],
    artist: 'Hector Berlioz',
    album: 'Symphonie fantastique / Lélio',
    media: 'CD',
    originalyear: 1998,
    year: 1998,
    label: [ 'BMG Classics' ],
    artistsort: 'Berlioz, Hector',
    asin: 'B000006OPB',
    barcode: '090266893027',
    musicbrainz_recordingid: 'ca3b02af-b6be-4f95-8217-31126b2c2b67',
    catalognumber: [ '09026-68930-2' ],
    releasetype: [ 'album' ],
    releasecountry: 'US',
    acoustid_id: 'ed58118e-3b76-492b-9453-223d0ca72b86',
    musicbrainz_albumid: '986209e3-ce80-4b66-af78-22a035dde993',
    musicbrainz_artistid: [ '274774a7-1cde-486a-bc3d-375ec54d552d' ],
    albumartist: 'Berlioz; San Francisco Symphony & Chorus, Michael Tilson Thomas',
    musicbrainz_releasegroupid: '3a7e05b9-14fd-3cff-ac29-e568dd10a2a9',
    musicbrainz_trackid: 'c90eaa1c-2be5-4eba-a37e-fa3d1dfb0882',
    albumartistsort: 'Berlioz, Hector; San Francisco Symphony & San Francisco Symphony Chorus, Tilson Thomas, Michael',
    musicbrainz_albumartistid: [
      '274774a7-1cde-486a-bc3d-375ec54d552d',
      'deebc49a-6e06-418e-860f-8c7f770a8bac',
      '568d7c51-0573-4c65-9211-65bf8c8470c7',
      'f6df125a-a83c-4161-8cbe-48f4a3a7cad5'
    ],
    picture: [ [Object] ]
  }
}
Name Type Description
inputFile String
Returns:
Type Description
object

convertOneFile (inputFile, cmdObj) async

Convert one input file.

Name Type Description
inputFile String

Path of the input file.

cmdObj Object

The command object from the commander.

convertTexToMarkdown (input)

Name Type Description
input String

A file path or a text string to convert.

createGimpPalette ()

Palette for Inkscape

~/.config/inkscape/palettes/baldr.gpl

GIMP Palette
Name: baldr
252 251 251  white-light
237 201  88  yellow-light

createGimpPaletteLine (color)

Name Type Description
color object
{ model: 'rgb', color: [ 252, 252, 251 ], valpha: 1 }

downloadFile (url, dest) async

Name Type Description
url String
dest String

downloadWikicommonsFile (filename, dest) async

Name Type Description
filename String
dest String

extractMatchAll (text, regexp, matches, excludeCaptureGroups)String

Name Type Description
text String

Text to search for matches

regexp String

Regular expressed gets compiled

matches Array

Array gets filled with cleaned matches.

excludeCaptureGroups Array

An array of capture group strings to exclude in the result matches for example regex: (itemize|compactitem|sub) -> ['itemize', 'compactitem', 'sub']

Returns:
Type Description
String

filePathToAssetType (filePath)

Name Type Description
filePath String

formatDate (date)String

Name Type Description
date Array | String

for example [ '1770-12-16T00:00:00.000Z' ]

Returns:
Type Description
String

getDescription (entity)

const entity = {
  id: 'Q1299',
  type: 'item',
  modified: '2020-03-15T20:18:33Z',
  descriptions: { en: 'English pop-rock band', de: 'Rockband aus Liverpool' }
}
Name Type Description
entity Object

getEntities (itemIds, props)Object async

Name Type Description
itemIds Array | String
props Array

for example ['labels']

Returns:
Type Description
Object

getLabel (entity)Array | String

const entity = {
  id: 'Q312609',
  type: 'item',
  modified: '2020-03-01T19:08:47Z',
  labels: { de: 'Cheb Khaled', en: 'Khaled' },
}
Name Type Description
entity Object
Returns:
Type Description
Array | String

getWikipediaTitle (entity)

entity = {
  sitelinks: {
    afwiki: 'The Beatles',
    akwiki: 'The Beatles',
  }
}
Name Type Description
entity Object

loadCommands (program)

Load all (sub)commands.

Name Type Description
program Object

An instance of the package “program”.

makeAsset (mediaFile)

Name Type Description
mediaFile String

move (oldPath, cmdObj)

Name Type Description
oldPath String

for example: /archive/10/10_Jazz/30_Stile/50_Modern-Jazz/Arbeitsblatt.tex

cmdObj Object

See commander docs.

moveAsset (oldPath, newPath, opts)

Move (rename) or copy a media asset and it’s corresponding meta data file (*.yml) and preview file (_preview.jpg).

Name Type Description
oldPath String

The old path of a media asset.

newPath String

The new path of a media asset.

opts Object

Some options

Properties:
Name Type Description
opts.copy Boolean
opts.dryRun Boolean

moveTex (oldPath, cmdObj)

Name Type Description
oldPath String

for example: /archive/10/10_Jazz/30_Stile/50_Modern-Jazz/Arbeitsblatt.tex

cmdObj Object

See commander docs.

moveTexImage (oldPathTex, baseName, cmdObj)String

Move images which are linked in a Tex file.

Name Type Description
oldPathTex String

for example: /media/10/10_Jazz/30_Stile/50_Modern-Jazz/Arbeitsblatt.tex

baseName String

for example: My-little-Annie-so-sweet

cmdObj Object

See commander docs.

Returns:
Type Description
String
  • for example: BD/John-Coltrane.jpg

naturalSort ()

See:

normalizeMetaData (filePath, metaData)

Sort the keys and clean up some entires.

Name Type Description
filePath String

The media asset file path.

metaData Object

The object representation of the yaml meta data file.

normalizeOneFile (filePath)

Name Type Description
filePath String

The media asset file path.

patchTexFileWithTitles (filePath)

\setzetitel{
  jahrgangsstufe = {6},
  ebenei = {Musik und ihre Grundlagen},
  ebeneii = {Systeme und Strukturen},
  ebeneiii = {die Tongeschlechter Dur und Moll},
  titel = {Dur- und Moll-Tonleiter},
  untertitel = {Das Lied \emph{„Kol dodi“} in Moll und Dur},
}
Name Type Description
filePath String

The path of a TeX file.

presentationFromAssets (filePath) async

Create a Praesentation.baldr.yml file and insert all media assets in the presentation.

Name Type Description
filePath String

The file path of the new created presentation template.

queryLabels (itemIds) async

Name Type Description
itemIds Array

for example ['Q123', 'Q234']

readFile (filePath)String

Read the content of a file in the utf-8 format.

A wrapper around fs.readFileSync()

Name Type Description
filePath String
Returns:
Type Description
String
  • The content of the file in the utf-8 format.

relocate (oldPath, extension)

Relocate a media asset inside the main media folder. Move some media assets into two letter folders.

Name Type Description
oldPath String
extension String

removeComments (text)

Name Type Description
text String
See:

renameByRegex (filePath)String

Name Type Description
filePath String

The media file path.

Returns:
Type Description
String

renameFromIdOneFile (filePath)

Rename a media asset after the id in the meta data file.

Name Type Description
filePath String

The media asset file path.

renameOneFile (oldPath)String

Rename one file.

Name Type Description
oldPath String

The media file path.

Returns:
Type Description
String
  • The new file name.

runImagemagick (inputFile, outputFile, size)

TODO: replace code inside actionConvert() with this function.

Name Type Default Description
inputFile String
outputFile String
size String 2000x2000>

see http://www.imagemagick.org/Usage/resize

slidify (masterName, data)

Name Type Description
masterName String
data Array | Object

splitHtmlintoChunks (htmlString, charactersOnSlide)Array

Split a HTML text into smaller chunks by looping over the children.

Name Type Description
htmlString String
charactersOnSlide Number
Returns:
Type Description
Array

texReg (commandName)

Name Type Description
commandName String

A simple LaTeX macro / command name from example: emph \emph{.*}

texRep (commandName)

Name Type Description
commandName String

A simple LaTeX macro / command name from example: emph \emph{.*}

unpackArray (values)Array | String

If the array has only one item, return only this item, else return the original array.

Name Type Description
values Array
Returns:
Type Description
Array | String

validateYamlOneFile (filePath)

Name Type Description
filePath String

The media file path.

writeFile (filePath, content)

Name Type Description
filePath String
content String

writeMetaDataYaml (filePath, metaData, force)

Write the metadata YAML file for a corresponding media file specified by filePath.

Name Type Description
filePath String

The filePath gets asciified and a yml extension is appended.

metaData Object
force Boolean

Always create the yaml file. Overwrite the old one.

writeYamlFile (filePath, data)String

Convert some data (usually Javascript objets) into the YAML format and write the string into a text file.

Name Type Description
filePath String

The file path of the destination yaml file. The yml extension has to be included.

data Object

Some data to convert into yaml and write into a text file.

Returns:
Type Description
String
  • The data converted to YAML as a string.

yamlToTxt (data)

Convert a Javascript object into a text string, ready to be written into a text file.

Name Type Description
data Object

Some data to convert to YAML.