Misc

Get Frontend Migrations

getMigrationsFrontend Operator user required

Retrieve list of migrations with a flag to tell if they have been done or not. Frontend migrations are just pages the frontend loads with information for the user on new features or improtant notices. With a new installation all migrations are marked as done already.

Response
[
    {
        name: 'KMOnline'
        flag_done: false
    }
]

If a migration is false, you should display it to the user.

Response
{
    code: 500
}

Set frontend migration

setFrontendMigration Operator user required

Set a migration as done/undone.

Request
{
    mig: {
        name: 'KMOnline'
        flag_done: true
    }
}

Promise just ersolves

Response
{
    code: 500
}

Get remote status

getRemoteData Operator user required Frontend needs to be open

Returns information about if the current app instance is available via remote access (through xxx.kara.moe)

Response
{
    active: true,
    info: {
        host: 'kara.moe',
        code: 'kkkk',
        token: 'blah',
    },
    token: 'remoteToken' // Token from the settings table
}

If active is false, no other information is returned.

Response
{
    code: 500
}

Reset remote token

resetRemoteToken Operator user required Frontend needs to be open

Resets the remote token used to enable remote access and communicate with a KM Server instance. Use this if the token has been compromised.

Actions taken by this command :

  • destroy the remote access
  • reinitialize token in settings table
  • initialize new remote

Promise just resolves.

Response
{
    code: 500,
}

Shutdown application

shutdown Operator user required Frontend needs to be open

Shutdowns the entire application.

Get Settings

getSettings No authentication needed Frontend can be closed, restricted or open

Return settings, state and version.

Response
{
    version: {
        name: 'Axel Acrobate',
        number: '26.1.1',
        image: 'AxelAcrobate.jpg',
        sha: <git commit SHA>
    },
    config: { // Depending on user level, not all configuration is returned
        ...
    },
    state: { // Application state depending on user level
        currentPlaid: 1,
        publicPlaid: 1,
        appPath: '...' // only for admins, undefined for others
        dataPath: '...' // same
        os: 'win32' // same
        electron: // does the app run on electron or node ?
        defaultLocale: 'fr',
        supportedLyrics: [
            'ass',
            'srt',
            'kar',
            'txt',
            'kfn',
            'lrc'
        ],
        supportedMedias: [
            'avi',
            'mkv',
            'mp4',
            'webm',
            'mov',
            'wmv',
            'mpg',
            'm2ts',
            'rmvb',
            'ts',
            'm4v',
            'ogg',
            'm4a',
            'mp3',
            'wav',
            'flac',
            'mid'
        ],
        environment: 'production',
        sentrytest: false // Sentry is enabled if false.
        url: 'http://kara.moe',
    }
}

For more information about configuration, see sample file in the git repo

Response
{
    code: 500,
}

Update setting

updateSettings Operator user required Frontend needs to be open

Updates one or more configuration options.

Request
{
    Frontend: {
        GeneratePreviews: false
    }
}

Configuration is returned as a result.

For more information about configuration, see sample file in the git repo

Response
{
    code: 500,
    message: {
        code: 'SETTINGS_UPDATE_ERROR'
    }
}

Get displays

getDisplays Operator user required Frontend can be closed, restricted or open

Return the list of displays the host computer has and their names. Only displays with positive resolutions are returned.

Returns an array of displays. See systeminformation module's documentation

Get Stats

getStats Operator user required Frontend can be closed, restricted or open

Get basic database statistics

Request
{
    tags: 15029,
    singers: 2039,
    songwriters: 8021,
    creators: 1122,
    authors: 250,
    karas: 11203,
    languages: 26,
    whitelist: 880, // number of songs whitelisted
    blacklist: 2, // number of songs blacklisted
    series: 5002,
    played: 12913 // number of songs played,
    playlists: 5,
    duration: 102391823908 // duration of all songs in database in seconds.
}

Request simply returns.

Response
{
    code: 500,
    message: {
        code: 'STATS_ERROR'
    }
}

Refresh user quotas

refreshUserQuotas Authentication needed Frontend needs to be open

Forces a refresh of the current user's quota (uses the authorization token)

Promise resolves immediately, but you'll receive a websocket event once calculations are complete

Get player state

getPlayerStatus Authentication needed Frontend needs to be restricted or open

Returns the media player's state

Response
{
    volume: 98,
    playing: true,
    playerStatus: 'play', // 'stop' or 'pause' too,
    _playing: true, // internal delay flag,
    timeposition: 57.2, // in seconds
    mute: false,
    currentSong: {
        ...PlaylistContent,
        avatar: '...' // Path to avatar file ,
        infos: '...' // ASS script to display song information in the player
    },
    currentMedia: { // If a playlist media is playing instead of a song
        series: 'One Piece',
        filename: 'One Piece - EC1.mp4',
        type: 'Jingles'
    },
    mediaType: 'song',
    showSubs: true,
    onTop: true,
    fullscreen: true,
    border: true,
    url: 'http://abcd.kara.moe',
    monitorEnabled: false // Second player monitor enabled?
    songNearEnd: false // Is the song about to end (8 seconds left or less),
    nextSongNotifSent: false,
    isOperating: false // Player lock status to avoid sending multiple commands
    currentSessionID: <uuid>, // Current karaoke session,
    currentRequester: 'Axel', // Who asked the current song,
    stopping: false // true if player is going to stop after current song
    defaultLocale: 'fr',
    songsBeforeJingle: 22,
    songsbeforeSponsors: 42
}

currentMedia.type can be :

  • Jingles
  • Sponsors,
  • Outros,
  • Intros,
  • Encores

mediaType can be :

  • one of currentMedia.type
  • song
  • background : when the player is stopped
  • pauseScreen : when the player is inbetween songs in classic or streamer mode

Get news feed

getNewsFeed No authentication needed Frontend needs to be open

Returns a news feed from the lab and KM's mastodon account.

Response
[
    {
        name: 'git_base',
        body: <stringified JSON>
    },
    {
        name: 'git_app',
        body: <stringified JSON>
    },
    {
        name: 'mastodon',
        body: <stringified JSON>
    }
]

For info on feeds, check the feed tool code

Response
{
    code: 500,
}

Get catchphrase

getCatchphrase Authentication needed Frontend needs to be open

Returns a random catchphrase string

Response is in plain text.

Response
Blablabla

Get logs

getLogs Operator user required Frontend can be closed, restricted or open

Get Karaoke Mugen system logs.

This aligns logs from websocket to the ones you'll have received through this route.

Request
{
    level: 'info'
}
Response
[
    {
        level: 'info',
        service: 'Player',
        message: 'Hey! Listen!',
        timestamp: '2021-03-03T15:43:52.755Z',
        obj: {} // optional detail object, usually for errors
    }
]
Response
{
    code: 500,
    message: {
        code: 'ERROR_READING_LOGS'
    }
}

Backup settings

backupSettings Operator user required Frontend can be closed, restricted or open

Saves configuration as another file `config.backup.yml`

Response
[
    code: 200,
    message: {
        code: 'CONFIG_BACKUPED'
    }
]
Response
{
    code: 500,
    message: {
        code: 'CONFIG_BACKUPED_ERROR'
    }
}

Generate database

generateDatabase Operator user required

Triggers a new database generation from the current data files.

A new Task will start with progress immediately after the call is made.

Once completed you'll get :

Response
{
    code: 200,
    message: {
        code: 'DATABASE_GENERATED'
    }
}
Response
{
    code: 500,
    message: {
        code: 'DATABASE_GENERATED_ERROR'
    }
}

Validate files

validateFiles Operator user required

Triggers a data files validation process. Files are read and verified. Any inconsistency is fixed (wrong subchecksum, wrong media metadata, etc.) Useful when files have been modified from outside Karaoke Mugen.

A new Task will start with progress immediately after the call is made.

Once completed you'll get :

Response
{
    code: 200,
    message: {
        code: 'FILES_VALIDATED'
    }
}
Response
{
    code: 500,
    message: {
        code: 'FILES_VALIDATED_ERROR'
    }
}

Dump database

dumpDatabase Operator user required

Dumps database to a SQL file. This works only on installation relying on the bundled PostgreSQL server.

The file is saved as karaokemugen.sql in dataPath.

Response
{
    code: 200,
    message: {
        code: 'DATABASE_DUMPED'
    }
}
Response
{
    code: 500,
    message: {
        code: 'DATABASE_DUMPED_ERROR'
    }
}

Restore database

restoreDatabase Operator user required

Restores database from the `karaokemugen.sql` file in `dataPath`.

WARNING: This obviously destroys any data not dumped previously.

Response
{
    code: 200,
    message: {
        code: 'DATABASE_RESTORED'
    }
}
Response
{
    code: 500,
    message: {
        code: 'DATABASE_RESTORED_ERROR'
    }
}

Get directory from filesystem

getFS Operator user required

Returns a list of files and folders in the choosen `path`. Useful to provide browsing capabilities to your app without Electron's native open file dialogs.

Response
{
    contents: [
        {
            name: 'KaraokeMugen',
            isDirectory: true
        },
        ...
    ]
    drives: [
        // Windows only.
    ],
    fullPath: 'C:\Users\something\'
}

For drives, please refer to systeminformation's documentation : blockDevices

Response
{
    code: 500,
    message: {
        code: 'FS_ERROR'
    }
}

Get Electron Versions

getElectronVersions Authentication needed

Returns `process.versions` from Electron.

See Electron and Node's API for process.versions.

Get audio devices

getAudioDevices Operator user required Frontend can be closed, restricted or open

Returns a list of audio devices MPV supports

[ ['auto', 'Autoselect device'], ['wasapi/{d5df6e9d-1ff9-4318-bc82-a79bed31abb0}', 'Haut-parleurs (Realtek(R) Audio)'], ['openal', 'Default (openal)'], ['sdl' 'Default (sdl)'] ]

Open current log file

openLogFile Operator user required Frontend can be closed, restricted or open

Stats a file explorer on the host computer with the current log file selected.

On Linux, it'll try xdg-open then nautilus and then dolphin before giving up.

Simply resolves.