and improve doc
pull/1556/head
Mikael Finstad 2023-04-09 13:14:49 +09:00
rodzic 0f8bfb9704
commit 6547b7c9fb
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 25AB36E3E81CBC26
2 zmienionych plików z 10 dodań i 6 usunięć

Wyświetl plik

@ -8,7 +8,7 @@ import { IoIosHelpCircle } from 'react-icons/io';
import Swal from '../swal';
import HighlightedText from './HighlightedText';
import { defaultOutSegTemplate } from '../util/outputNameTemplate';
import { defaultOutSegTemplate, segNumVariable } from '../util/outputNameTemplate';
import useUserSettings from '../hooks/useUserSettings';
const ReactSwal = withReactContent(Swal);
@ -115,12 +115,14 @@ const OutSegTemplateEditor = memo(({ outSegTemplate, setOutSegTemplate, generate
<IconButton title={t('Close')} icon={TickIcon} height={20} onClick={onHideClick} marginLeft={5} intent="success" />
</div>
<div style={{ maxWidth: 600 }}>
{error != null && <div style={{ marginBottom: '1em' }}><ErrorIcon color="var(--red9)" /> {i18n.t('There is an error in the file name template:')} {error}</div>}
{error != null && <div style={{ marginBottom: '1em' }}><ErrorIcon color="var(--red9)" size={14} verticalAlign="baseline" /> {i18n.t('There is an error in the file name template:')} {error}</div>}
{isMissingExtension && <div style={{ marginBottom: '1em' }}><WarningSignIcon color="var(--amber9)" /> {i18n.t('The file name template is missing {{ext}} and will result in a file without the suggested extension. This may result in an unplayable output file.', { ext: extVar })}</div>}
<div style={{ fontSize: '.8em', color: 'var(--gray11)', display: 'flex', gap: '.3em', flexWrap: 'wrap', alignItems: 'center' }}>
{`${i18n.t('Variables')}:`}
<IoIosHelpCircle fontSize="1.3em" color="var(--gray12)" role="button" cursor="pointer" onClick={() => electron.shell.openExternal('https://github.com/mifi/lossless-cut/blob/master/import-export.md#customising-exported-file-names')} />
{['FILENAME', 'CUT_FROM', 'CUT_TO', 'SEG_NUM', 'SEG_LABEL', 'SEG_SUFFIX', 'EXT', 'SEG_TAGS.XX', 'EPOCH_MS'].map((variable) => (
{['FILENAME', 'CUT_FROM', 'CUT_TO', segNumVariable, 'SEG_LABEL', 'SEG_SUFFIX', 'EXT', 'SEG_TAGS.XX', 'EPOCH_MS'].map((variable) => (
<span key={variable} role="button" style={{ cursor: 'pointer', marginRight: '.2em' }} onClick={() => onVariableClick(variable)}>{variable}</span>
))}
</div>

Wyświetl plik

@ -6,6 +6,8 @@ import isDev from '../isDev';
import { getSegmentTags } from '../segments';
export const segNumVariable = 'SEG_NUM';
const { parse: parsePath, sep: pathSep, join: pathJoin, normalize: pathNormalize } = window.require('path');
// eslint-disable-next-line import/prefer-default-export
@ -57,7 +59,7 @@ export function getOutSegError({ fileNames, filePath, outputDir, safeOutputFileN
if (error != null) return error;
if (hasDuplicates(fileNames)) return i18n.t('Output file name template results in duplicate file names (you are trying to export multiple files with the same name.)');
if (hasDuplicates(fileNames)) return i18n.t('Output file name template results in duplicate file names (you are trying to export multiple files with the same name). You can fix this for example by adding the "{{segNumVariable}}" variable.', { segNumVariable });
return undefined;
}
@ -93,7 +95,7 @@ function formatSegNum(segIndex, segments) {
}
export function generateOutSegFileNames({ segments, template, forceSafeOutputFileName, formatTimecode, isCustomFormatSelected, fileFormat, filePath, safeOutputFileName, maxLabelLength }) {
const currentTimestamp = Date.now();
const epochMs = Date.now();
return segments.map((segment, i) => {
const { start, end, name = '' } = segment;
@ -114,7 +116,7 @@ export function generateOutSegFileNames({ segments, template, forceSafeOutputFil
const segFileName = interpolateSegmentFileName({
template,
epochMs: currentTimestamp + i, // for convenience: give each segment a unique timestamp
epochMs,
segNum,
inputFileNameWithoutExt,
segSuffix: getSegSuffix(),