Changeset 834bcc3 in Klonkt for src/services/AudioTranscoder.js


Ignore:
Timestamp:
06/23/2026 06:14:27 PM (3 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
d774679
Parents:
bb42dfb
Message:

i18n: translate Dutch code comments to English across src/

Comments in routes/services/views/config/middleware/assets translated to
English for the public repo. A few dev-facing throw/console message strings
were Englished too. No user-facing UI strings or i18n dictionary values changed
(src/services/i18n.js untouched). Logic unchanged.

Co-Authored-By: Claude <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/services/AudioTranscoder.js

    rbb42dfb r834bcc3  
    126126      size: outStat.size,
    127127      mimeType: 'audio/mpeg',
    128       durationSec,   // hele seconden uit ffmpeg's codecData (null als onbekend)
     128      durationSec,   // whole seconds from ffmpeg's codecData (null if unknown)
    129129    };
    130130
     
    138138
    139139/**
    140  * Herschrijf de ID3-tags van een BESTAANDE mp3 zonder her-encoden (`-c copy`).
    141  * Gebruikt bij het bewerken van track-metadata (titel/artiest/album/credit/licentie)
    142  * zodat de eigendomsinfo in het bestand zelf meereist bij een download.
    143  * ffmpeg kan niet in-place editen → schrijf naar tmp en hernoem atomisch terug.
     140 * Rewrite the ID3 tags of an EXISTING mp3 without re-encoding (`-c copy`).
     141 * Used when editing track metadata (title/artist/album/credit/license) so that
     142 * ownership info travels with the file on download.
     143 * ffmpeg cannot edit in-place → write to tmp and atomically rename back.
    144144 */
    145145export async function retagMp3({ filePath, tags = {} }) {
    146146  if (!filePath) throw new Error('retagMp3: filePath required');
    147   await stat(filePath); // throws als 't bestand mist
     147  await stat(filePath); // throws if file is missing
    148148  const dir = path.dirname(filePath);
    149149  const base = path.basename(filePath, path.extname(filePath));
     
    152152    await new Promise((resolve, reject) => {
    153153      const cmd = ffmpeg(filePath)
    154         .audioCodec('copy')        // geen her-encode → snel, geen kwaliteitsverlies
     154        .audioCodec('copy')        // no re-encode → fast, no quality loss
    155155        .format('mp3')
    156156        .outputOptions('-id3v2_version', '3')
     
    167167    });
    168168    const s = await stat(tmpPath);
    169     if (s.size === 0) throw new Error('retag output is leeg');
     169    if (s.size === 0) throw new Error('retag output is empty');
    170170    await rename(tmpPath, filePath);
    171171    return { filePath, size: s.size };
    172172  } catch (err) {
    173     try { await unlink(tmpPath); } catch { /* tmp bestaat mogelijk niet */ }
     173    try { await unlink(tmpPath); } catch { /* tmp may not exist */ }
    174174    throw err;
    175175  }
     
    209209    if (tags.artist)    cmd.outputOptions('-metadata', `artist=${tags.artist}`);
    210210    if (tags.album)     cmd.outputOptions('-metadata', `album=${tags.album}`);
    211     if (tags.copyright) cmd.outputOptions('-metadata', `copyright=${tags.copyright}`); // ID3 TCOP — eigenaar/credit
    212     if (tags.comment)   cmd.outputOptions('-metadata', `comment=${tags.comment}`);     // ID3 COMM — licentie
     211    if (tags.copyright) cmd.outputOptions('-metadata', `copyright=${tags.copyright}`); // ID3 TCOP — owner/credit
     212    if (tags.comment)   cmd.outputOptions('-metadata', `comment=${tags.comment}`);     // ID3 COMM — license
    213213
    214214    cmd
    215       // codecData geeft de duur van de INPUT als "HH:MM:SS.xx" — zo bepalen we
    216       // de tracklengte automatisch zonder aparte ffprobe-binary.
     215      // codecData gives the INPUT duration as "HH:MM:SS.xx" — this lets us
     216      // determine the track length automatically without a separate ffprobe binary.
    217217      .on('codecData', (data) => { durationSec = parseHmsToSeconds(data && data.duration); })
    218218      .on('error', (err, stdout, stderr) => {
     
    230230
    231231/**
    232  * Parse een ffmpeg-duurstring "HH:MM:SS.xx" naar hele seconden. Geeft null bij
    233  * "N/A" of een onverwacht formaat.
     232 * Parse an ffmpeg duration string "HH:MM:SS.xx" to whole seconds. Returns null
     233 * for "N/A" or an unexpected format.
    234234 */
    235235function parseHmsToSeconds(hms) {
     
    242242
    243243/**
    244  * Lees de duur (hele seconden) van een audiobestand ZONDER te transcoderen.
    245  * Start een ffmpeg-pass en leest enkel het codecData-event (duur), waarna we het
    246  * proces direct stoppen — snel en zonder aparte ffprobe-binary (ffmpeg-static
    247  * levert alleen ffmpeg). Bedoeld voor het backfill-script.
     244 * Read the duration (whole seconds) of an audio file WITHOUT transcoding.
     245 * Starts an ffmpeg pass and reads only the codecData event (duration), then
     246 * kills the process immediately — fast and without a separate ffprobe binary
     247 * (ffmpeg-static ships only ffmpeg). Intended for the backfill script.
    248248 * @returns {Promise<number|null>}
    249249 */
     
    255255      .on('codecData', (data) => {
    256256        durationSec = parseHmsToSeconds(data && data.duration);
    257         try { cmd.kill('SIGKILL'); } catch { /* al klaar */ }
     257        try { cmd.kill('SIGKILL'); } catch { /* already done */ }
    258258        finish();
    259259      })
Note: See TracChangeset for help on using the changeset viewer.