Merge pull request 'feat:新增集数识别' (#34) from dev into main
Reviewed-on: #34
This commit is contained in:
commit
1f37019715
@ -4,6 +4,9 @@ import path from 'path';
|
||||
|
||||
|
||||
let pattern = new RegExp(/s(eason)?(\d+)/);
|
||||
let eNumPatternArr = [new RegExp(/e(\d+)/), new RegExp(/\((\d+)\)/), new RegExp(/((\d+))/), new RegExp(/\.(\d+)\./), new RegExp(/-(\d+)-/), new RegExp(/(\d+)/)];
|
||||
let resolutionPattern = new RegExp(/(\d+[pP])/);
|
||||
let resolutionArr = ['1k', '1K', '2k', '2K', '4k', '4K', '8k', '8K'];
|
||||
let charSet = new Set([' ', '[', '.', '(', '(']);
|
||||
export default class InsertRule implements RuleInterface {
|
||||
|
||||
@ -19,6 +22,7 @@ export default class InsertRule implements RuleInterface {
|
||||
* 后面追加
|
||||
*/
|
||||
endAdd: string;
|
||||
eNumWidth: number;
|
||||
|
||||
constructor(data: any) {
|
||||
this.type = data.type;
|
||||
@ -52,11 +56,34 @@ export default class InsertRule implements RuleInterface {
|
||||
}
|
||||
getStr += char;
|
||||
}
|
||||
} else if (this.type === 'eNum') {
|
||||
let lowName = file.originName.toLocaleLowerCase();
|
||||
for (let i in eNumPatternArr) {
|
||||
let patternRes = lowName.match(eNumPatternArr[i]);
|
||||
if (patternRes && patternRes.length > 1) {
|
||||
getStr = patternRes[1];
|
||||
for (let i = 0; i < this.eNumWidth - getStr.length; i++) {
|
||||
getStr = '0' + getStr;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (this.type === 'resolution') {
|
||||
let res = file.originName.match(resolutionPattern);
|
||||
if (res && res.length > 1) {
|
||||
getStr = res[1];
|
||||
} else {
|
||||
for (let i = 0; i < resolutionArr.length; i++) {
|
||||
if (file.originName.indexOf(resolutionArr[i]) > -1) {
|
||||
getStr = resolutionArr[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (getStr && getStr.length > 0) {
|
||||
file.realName = file.realName + this.frontAdd + getStr + this.endAdd;
|
||||
file.name = file.realName + file.expandName;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="">
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
|
@ -2,20 +2,18 @@
|
||||
<div class="flex">
|
||||
<span class="left">识别类型:</span>
|
||||
<div class="location">
|
||||
<el-radio v-model="ruleObj.data.type" label="season"
|
||||
>季号识别
|
||||
<el-tooltip effect="dark" :content="message2" placement="top">
|
||||
<el-icon><InfoFilled /></el-icon>
|
||||
</el-tooltip>
|
||||
</el-radio>
|
||||
<el-radio v-model="ruleObj.data.type" label="name"
|
||||
>剧名/电影名识别
|
||||
<el-tooltip effect="dark" :content="message2" placement="top">
|
||||
<el-radio v-for="item in radioList" :key="item.code" v-model="ruleObj.data.type" :label="item.code"
|
||||
>{{ item.label }}
|
||||
<el-tooltip effect="dark" :content="item.message" placement="top">
|
||||
<el-icon><InfoFilled /></el-icon>
|
||||
</el-tooltip>
|
||||
</el-radio>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex" v-if="ruleObj.data.type == 'eNum'">
|
||||
<div class="left">集数宽度:</div>
|
||||
<el-input-number :min="1" v-model="ruleObj.data.eNumWidth" />
|
||||
</div>
|
||||
<div class="flex">
|
||||
<div class="left">前面追加:</div>
|
||||
<el-input v-model="ruleObj.data.frontAdd" placeholder="识别内容前面追加,未识别到不会追加" style="width: 20em" />
|
||||
@ -34,9 +32,29 @@ export default {
|
||||
components: { InfoFilled },
|
||||
data() {
|
||||
return {
|
||||
message1: '通过识别文件夹名称获取季号,放在插入文本最后,可识别"s1","s01","season 01","season01"等以s或season开头后接数字的',
|
||||
message2:
|
||||
"如果父文件夹包含season字段,那么会从父文件夹的父文件夹名称中取剧名,否则将从父文件夹名称中取电影名。规则为从开头开始取,直到遇见第一个空格/./[等符号",
|
||||
radioList: [
|
||||
{
|
||||
label: "季号识别",
|
||||
message: '通过识别文件夹名称获取季号,放在插入文本最后,可识别"s1","s01","season 01","season01"等以s或season开头后接数字的',
|
||||
code: "season",
|
||||
},
|
||||
{
|
||||
label: "集数识别",
|
||||
message: "通过提取文件名称来提取集数,支持 E数字/e数字/(数字)/(数字)/.数字/-数字/纯数字 。优先级依次递减,如果存在多组纯数字,选择第一组",
|
||||
code: "eNum",
|
||||
},
|
||||
{
|
||||
label: "剧名/电影名识别",
|
||||
message:
|
||||
"如果父文件夹包含season字段,那么会从父文件夹的父文件夹名称中取剧名,否则将从父文件夹名称中取电影名。规则为从开头开始取,直到遇见第一个空格/./[等符号",
|
||||
code: "name",
|
||||
},
|
||||
{
|
||||
label: "分辨率识别",
|
||||
message: "通过文件名提取出分辨率,支持 数字P/数字p/1k/1K/2k/2K/4k/4K",
|
||||
code: "resolution",
|
||||
},
|
||||
],
|
||||
ruleObj: {
|
||||
type: "auto",
|
||||
message: "",
|
||||
@ -44,6 +62,7 @@ export default {
|
||||
type: "",
|
||||
frontAdd: "",
|
||||
endAdd: "",
|
||||
eNumWidth: 2,
|
||||
},
|
||||
},
|
||||
};
|
||||
@ -60,7 +79,10 @@ export default {
|
||||
this.$message({ message: "请选择识别类型", type: "warning" });
|
||||
return null;
|
||||
}
|
||||
this.ruleObj.message = `自动识别:"${this.ruleObj.data.type == "season" ? "季号" : "剧名/电影名识别"}";`;
|
||||
this.ruleObj.message = `自动识别:"${this.radioList.filter((item) => item.code == this.ruleObj.data.type)[0].label}";`;
|
||||
if (this.ruleObj.data.type == "eNum") {
|
||||
this.ruleObj.message += "集数宽度:" + this.ruleObj.data.eNumWidth + ";";
|
||||
}
|
||||
if (this.ruleObj.data.frontAdd.length > 0) {
|
||||
this.ruleObj.message += `前缀添加:${this.ruleObj.data.frontAdd}`;
|
||||
}
|
||||
|
@ -25,18 +25,16 @@
|
||||
<div>
|
||||
<el-button type="primary" size="small" @click="selectAllFiles">反选</el-button>
|
||||
<el-button type="danger" size="small" @click="deleteCheckedFiles">删除</el-button>
|
||||
<template v-if="showMove">
|
||||
<el-button type="primary" size="small" @click="moveIndex('top')">
|
||||
<el-tooltip effect="dark" content="上移规则" placement="top">
|
||||
<el-icon><top /></el-icon>
|
||||
</el-tooltip>
|
||||
</el-button>
|
||||
<el-button type="primary" size="small" @click="moveIndex('bottom')">
|
||||
<el-tooltip effect="dark" content="下移规则" placement="top"
|
||||
><el-icon><bottom /></el-icon
|
||||
></el-tooltip>
|
||||
</el-button>
|
||||
</template>
|
||||
<el-button type="primary" size="small" @click="moveIndex('top')">
|
||||
<el-tooltip effect="dark" content="上移规则" placement="top">
|
||||
<el-icon><top /></el-icon>
|
||||
</el-tooltip>
|
||||
</el-button>
|
||||
<el-button type="primary" size="small" @click="moveIndex('bottom')">
|
||||
<el-tooltip effect="dark" content="下移规则" placement="top"
|
||||
><el-icon><bottom /></el-icon
|
||||
></el-tooltip>
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="fileBlock">
|
||||
<!-- 左侧原始文件名 -->
|
||||
@ -94,11 +92,7 @@ export default {
|
||||
timer: null, //修改顺序计时器
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
showMove() {
|
||||
return this.fileList.filter((item) => item.checked == true).length == 1;
|
||||
},
|
||||
},
|
||||
computed: {},
|
||||
async created() {
|
||||
this.savePathList = await HttpUtil.get("/file/path");
|
||||
window.isWindows = await HttpUtil.get("/file/isWindows");
|
||||
@ -180,22 +174,30 @@ export default {
|
||||
},
|
||||
//移动文件顺序
|
||||
async moveIndex(type) {
|
||||
let temp = this.fileList.filter((item) => item.checked == true)[0];
|
||||
let index = this.fileList.indexOf(temp);
|
||||
let newIndex;
|
||||
if (type == "top") {
|
||||
if (index == 0) {
|
||||
return;
|
||||
}
|
||||
newIndex = index - 1;
|
||||
} else {
|
||||
if (index == this.fileList.length - 1) {
|
||||
return;
|
||||
}
|
||||
newIndex = index + 1;
|
||||
let temps = this.fileList.filter((item) => item.checked == true);
|
||||
if (temps.length == 0) {
|
||||
this.$message({ type: "warning", message: "未选中文件,无法移动" });
|
||||
return;
|
||||
}
|
||||
if (type == "top") {
|
||||
if (this.fileList.indexOf(temps[0]) == 0) {
|
||||
this.$message({ type: "warning", message: "无法上移" });
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (this.fileList.indexOf(temps[temps.length - 1]) == this.fileList.length - 1) {
|
||||
this.$message({ type: "warning", message: "无法下移" });
|
||||
return;
|
||||
}
|
||||
temps = temps.reverse();
|
||||
}
|
||||
for (let i in temps) {
|
||||
let temp = temps[i];
|
||||
let index = this.fileList.indexOf(temp);
|
||||
let newIndex = index + (type == "top" ? -1 : 1);
|
||||
this.fileList[index] = this.fileList[newIndex];
|
||||
this.fileList[newIndex] = temp;
|
||||
}
|
||||
this.fileList[index] = this.fileList[newIndex];
|
||||
this.fileList[newIndex] = temp;
|
||||
this.fileList = [...this.fileList];
|
||||
this.needPreview = true;
|
||||
if (this.timer != null) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user