...
 
Commits (4)
node_modules/
\ No newline at end of file
node_modules/
dist/
# CHANGELOG
## 1.0.9
- Fixed \k100 to \k90, not on comment lines anymore
- Fixed hours being on one character instead of two
- Fixed fad+k effect on beginning of line.
## 1.0.8
- Detect CRLF on txt data and turns it into LF.
......
{
"name": "toyunda2ass",
"version": "1.0.8",
"version": "1.0.9",
"description": "Convert Epitanime Toyunda karaoke files to ASS files",
"main": "dist/index.js",
"bin": {
......
......@@ -127,7 +127,6 @@ export const dialogue = {
}
};
export const dialogueScript = '{\\fad(90,20)\\k100}';
export const commentScript = '{\\k100}';
export const dialogueScript = '{\\k90\\fad(300,200)}';
export const scriptFX = 'template pre-line all keeptags';
export const script = '!retime("line",$start < 0 and -$start or -0,200)!{!$start < 0 and "\\\\k" .. ($start/10) or "\\\\k0"!\\fad(!$start < 0 and $start or 300!,200)}';
......@@ -10,7 +10,7 @@ export function splitTime(txt: string): ToyundaData {
const lyr = [];
const frm = [];
let position = '';
if (getLineBreakChar(txt) === 'CRLF') txt = txt.replace(/\r\n/g, '\n');
if (getLineBreakChar(txt) === 'CRLF') txt = txt.replace(/\r\n/g, '\n');
for (const line of txt.split('\n')) {
if (line === '# --- LYRICS - GENERATE AGAIN AFTER YOU EDIT ---') {
position = 'lyr';
......@@ -99,19 +99,18 @@ export function convertToASS(time: ToyundaData, fps: number): string {
const dialogue = clone(ass.dialogue);
const comment = clone(ass.dialogue);
let dialogueScript = ass.dialogueScript;
let commentScript = ass.commentScript;
if (startMs === 0) {
// if song starts at the beginning, remove the \k100 delay
dialogueScript = dialogueScript.replace(/\\k100/,'');
commentScript = '';
}
dialogue.value.Start = comment.value.Start = msToAss(startMs);
dialogue.value.Start = msToAss(startMs)
comment.value.Start = msToAss(startMs + 1000);
dialogue.value.End = comment.value.End = msToAss(stopMs);
dialogue.value.Text = dialogueScript + ASSLine.join('');
dialogue.value.Effect = 'karaoke';
comment.value.Effect = 'fx';
comment.key = 'Comment';
comment.value.Text = commentScript + ASSLine.join('');
comment.value.Text = ASSLine.join('');
// Add it to our kara
dialogues.push(clone(dialogue));
comments.push(clone(comment));
......@@ -136,7 +135,7 @@ async function mainCLI() {
const txtFile = process.argv[2];
fps = +process.argv[3];
if (!await asyncExists(txtFile)) throw `File ${txtFile} does not exist`;
aviFile = txtFile.replace('.txt', '.avi');
aviFile = txtFile.replace('.txt', '.avi');
const txt = await asyncReadFile(txtFile, 'utf8');
const data = splitTime(txt);
lyr = data.lyrics.join('\n');
......@@ -155,7 +154,7 @@ async function mainCLI() {
if (!fps || isNaN(fps)) {
// Trying to guess FPS from video file
fps = await findFPS(aviFile);
}
}
return convertToASS({lyrics: lyr.split('\n'), frames: frm.split('\n')}, fps);
}
......
......@@ -14,7 +14,7 @@ export const asyncWriteFile = (...args: any) => passThroughFunction(writeFile, a
export function msToAss(ms: number): string {
const date = new Date(ms);
const hour = date.getUTCHours();
const hourStr = `${hour}`.padStart(2, '0');
const hourStr = `${hour}`.padStart(1, '0');
const min = date.getUTCMinutes();
const minStr = `${min}`.padStart(2, '0');
const sec = date.getUTCSeconds();
......