Initial clean project import
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
// 读取 TypeScript 配置文件
|
||||
const tsFile = path.join(__dirname, '../src/config/systemSubtitleTemplates.ts');
|
||||
const content = fs.readFileSync(tsFile, 'utf-8');
|
||||
|
||||
// 提取每个模板的关键信息
|
||||
const templates = [];
|
||||
const templateRegex = /id: "template_system_(\d+)",[\s\S]*?name: "(\d+)",[\s\S]*?titleSubtitleConfig: \{[\s\S]*?maxCharsPerLine: (\d+),[\s\S]*?sourceTitle: "([^"]+)",[\s\S]*?lines: \[([\s\S]*?)\],[\s\S]*?\},[\s\S]*?\},[\s\S]*?isSystem: true/g;
|
||||
|
||||
let match;
|
||||
while ((match = templateRegex.exec(content)) !== null) {
|
||||
const id = match[1];
|
||||
const name = match[2];
|
||||
const maxCharsPerLine = parseInt(match[3]);
|
||||
const sourceTitle = match[4];
|
||||
const linesContent = match[5];
|
||||
|
||||
// 提取行信息
|
||||
const lines = [];
|
||||
const fontNames = [];
|
||||
const lineRegex = /\{[^}]*text: "([^"]+)"[^}]*fontName: "([^"]+)"[^}]*fontColor: "([^"]+)"[^}]*\}/g;
|
||||
let lineMatch;
|
||||
while ((lineMatch = lineRegex.exec(linesContent)) !== null) {
|
||||
lines.push({
|
||||
text: lineMatch[1],
|
||||
fontName: lineMatch[2],
|
||||
fontColor: lineMatch[3]
|
||||
});
|
||||
if (!fontNames.includes(lineMatch[2])) {
|
||||
fontNames.push(lineMatch[2]);
|
||||
}
|
||||
}
|
||||
|
||||
templates.push({
|
||||
id,
|
||||
name,
|
||||
maxCharsPerLine,
|
||||
sourceTitle,
|
||||
lines,
|
||||
fontNames
|
||||
});
|
||||
}
|
||||
|
||||
console.log('=== 模板标题字幕配置对比 ===\n');
|
||||
|
||||
templates.forEach(t => {
|
||||
console.log(`模板 ${t.name}:`);
|
||||
console.log(` - 每行字符数: ${t.maxCharsPerLine}`);
|
||||
console.log(` - 行数: ${t.lines.length}`);
|
||||
console.log(` - 字体: ${t.fontNames.join(', ')}`);
|
||||
t.lines.forEach((line, idx) => {
|
||||
console.log(` - 第${idx + 1}行: "${line.text}" (${line.fontName}, ${line.fontColor})`);
|
||||
});
|
||||
console.log('');
|
||||
});
|
||||
|
||||
// 找出相同的模板
|
||||
console.log('\n=== 相同配置的模板组 ===\n');
|
||||
|
||||
const groups = {};
|
||||
templates.forEach(t => {
|
||||
const key = `${t.maxCharsPerLine}-${t.lines.length}-${t.fontNames.join(',')}-${t.lines.map(l => `${l.text}:${l.fontName}:${l.fontColor}`).join('|')}`;
|
||||
if (!groups[key]) {
|
||||
groups[key] = [];
|
||||
}
|
||||
groups[key].push(t.name);
|
||||
});
|
||||
|
||||
Object.keys(groups).forEach(key => {
|
||||
if (groups[key].length > 1) {
|
||||
console.log(`模板 ${groups[key].join(', ')} 配置相同`);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user