|
|
@@ -1465,21 +1465,26 @@ async function isDirectory(filePath: string): Promise<boolean> {
|
|
|
interface VideoNameParts {
|
|
|
nonNumeric: string;
|
|
|
numeric: number;
|
|
|
+ suffix:string;
|
|
|
}
|
|
|
|
|
|
-// 提取文件名中的非数字和数字部分
|
|
|
function extractParts(name: string): VideoNameParts {
|
|
|
- // Adjust the regex to handle names that start with numbers
|
|
|
- const match = name.match(/^(\D*?)(\d+)(\.\w+)?$/);
|
|
|
+ // 更完善的正则表达式,处理各种情况
|
|
|
+ // 匹配:非数字前缀 + 数字部分 + 可选的剩余部分
|
|
|
+ const match = name.match(/^(\D*)(\d+)(.*)$/);
|
|
|
if (match) {
|
|
|
return {
|
|
|
- nonNumeric: match[1] || '', // Ensure nonNumeric is not undefined
|
|
|
- numeric: parseInt(match[2], 10),
|
|
|
+ nonNumeric: match[1] || '', // 非数字前缀
|
|
|
+ numeric: parseInt(match[2], 10), // 数字部分
|
|
|
+ suffix: match[3] || '' // 剩余部分(可能包含扩展名等)
|
|
|
};
|
|
|
}
|
|
|
+
|
|
|
+ // 如果没有找到数字模式,将整个名称作为非数字部分
|
|
|
return {
|
|
|
nonNumeric: name,
|
|
|
numeric: 0,
|
|
|
+ suffix: ''
|
|
|
};
|
|
|
}
|
|
|
|