Merge pull request 'dev' (#41) from dev into main

Reviewed-on: #41
This commit is contained in:
fanxb 2023-04-09 22:38:44 +08:00
commit 85f614f414
9 changed files with 122 additions and 101 deletions

View File

@ -1,7 +1,7 @@
FROM node:lts-buster-slim FROM node:lts-buster-slim
WORKDIR /app WORKDIR /app
COPY ./openRenamerBackend /app COPY ./openRenamerBackend /app
RUN chmod 777 -R /app RUN chmod 777 -R /app && npm install -g pnpm typescript --registry https://registry.npmmirror.com
ENV PORT 80 ENV PORT 80
CMD ["bash", "start.sh"] CMD ["bash", "start.sh"]

View File

@ -13,4 +13,4 @@ rm -rf openRenamerBackend/node_modules
#docker build -t fleyx/open-renamer:$0 --push . #docker build -t fleyx/open-renamer:$0 --push .
# 多平台打包并推送 # 多平台打包并推送
docker buildx build -t fleyx/open-renamer:$1 --platform linux/amd64,linux/arm64 --push . docker buildx build -t fleyx/open-renamer:$1 --platform linux/amd64,linux/arm64 --push .
docker buildx build -t fleyx/open-renamer:latset --platform linux/amd64,linux/arm64 --push . docker buildx build -t fleyx/open-renamer:latest --platform linux/amd64,linux/arm64 --push .

View File

@ -1,6 +1,7 @@
import RuleInterface from "./RuleInterface"; import RuleInterface from "./RuleInterface";
import FileObj from "../../vo/FileObj"; import FileObj from "../../vo/FileObj";
import path from 'path'; import path from 'path';
import {getSeason} from "../../../util/MediaUtil";
let pattern = new RegExp(/s(eason)?(\d+)/); let pattern = new RegExp(/s(eason)?(\d+)/);
@ -35,14 +36,12 @@ export default class InsertRule implements RuleInterface {
deal(file: FileObj): void { deal(file: FileObj): void {
//识别到的内容 //识别到的内容
let getStr = null; let getStr = null;
let patternRes = path.basename(file.path).replace(/[ ]+/, "").toLocaleLowerCase().match(pattern); let season = getSeason(path.basename(file.path));
if (this.type === 'season') { if (this.type === 'season') {
if (patternRes && patternRes[2]) { getStr = season;
getStr = patternRes[2];
}
} else if (this.type === 'name') { } else if (this.type === 'name') {
let originName = null; let originName = null;
if (patternRes && patternRes[2]) { if (season && season.length > 0) {
//说明是剧集,取父文件夹的父文件夹名称 //说明是剧集,取父文件夹的父文件夹名称
originName = path.basename(path.resolve(file.path, '..')); originName = path.basename(path.resolve(file.path, '..'));
} else { } else {

View File

@ -1,9 +1,9 @@
import RuleInterface from "./RuleInterface"; import RuleInterface from "./RuleInterface";
import FileObj from "../../vo/FileObj"; import FileObj from "../../vo/FileObj";
import path from 'path'; import path from 'path';
import {getSeason} from "../../../util/MediaUtil";
let pattern = new RegExp(/s(eason)?(\d+)/);
export default class InsertRule implements RuleInterface { export default class InsertRule implements RuleInterface {
/** /**
@ -60,10 +60,7 @@ export default class InsertRule implements RuleInterface {
let season = ''; let season = '';
if (this.autoSeason) { if (this.autoSeason) {
let patternRes = path.basename(file.path).replace(/[ ]+/, "").toLocaleLowerCase().match(pattern); season = getSeason(path.basename(file.path));
if (patternRes && patternRes[2]) {
season = patternRes[2];
}
} }
switch (this.type) { switch (this.type) {
case "front": case "front":

View File

@ -1 +1 @@
INSERT INTO application_rule (createdDate, updatedDate, name, comment, content, defaults) VALUES (1669648328180, 1678279879110, '推荐剧集模板', '此模板为系统创建12121212', '[{"type":"delete","message":"删除:全部删除","data":{"type":"deleteAll","start":{"type":"location","value":"1"},"end":{"type":"location","value":"1"},"ignorePostfix":true},"checked":false},{"type":"auto","message":"自动识别:\"剧名/电影名识别\";","data":{"type":"name","frontAdd":"","endAdd":"","eNumWidth":2},"checked":false},{"type":"auto","message":"自动识别:\"季号识别\";前缀添加:.s","data":{"type":"season","frontAdd":".s","endAdd":"","eNumWidth":2},"checked":false},{"type":"auto","message":"自动识别:\"集数识别\";集数宽度:3;前缀添加:e","data":{"type":"eNum","frontAdd":"e","endAdd":"","eNumWidth":3},"checked":false},{"type":"auto","message":"自动识别:\"分辨率识别\";前缀添加:.","data":{"type":"resolution","frontAdd":".","endAdd":"","eNumWidth":2},"checked":false}]', 0); INSERT INTO application_rule (createdDate, updatedDate, name, comment, content ) VALUES (1669648328180, 1678279879110, '推荐剧集模板', '此模板为系统创建12121212', '[{"type":"delete","message":"删除:全部删除","data":{"type":"deleteAll","start":{"type":"location","value":"1"},"end":{"type":"location","value":"1"},"ignorePostfix":true},"checked":false},{"type":"auto","message":"自动识别:\"剧名/电影名识别\";","data":{"type":"name","frontAdd":"","endAdd":"","eNumWidth":2},"checked":false},{"type":"auto","message":"自动识别:\"季号识别\";前缀添加:.s","data":{"type":"season","frontAdd":".s","endAdd":"","eNumWidth":2},"checked":false},{"type":"auto","message":"自动识别:\"集数识别\";集数宽度:3;前缀添加:e","data":{"type":"eNum","frontAdd":"e","endAdd":"","eNumWidth":3},"checked":false},{"type":"auto","message":"自动识别:\"分辨率识别\";前缀添加:.","data":{"type":"resolution","frontAdd":".","endAdd":"","eNumWidth":2},"checked":false}]');

View File

@ -1 +1 @@
npm install -g pnpm typescript --registry https://registry.npmmirror.com && pnpm install --registry https://registry.npmmirror.com && tsc && node dist/index.js pnpm install --registry https://registry.npmmirror.com && tsc && node dist/index.js

View File

@ -1,3 +1,4 @@
const path = require("path")
const videoSet = new Set(["flv", 'avi', 'wmv', 'dat', 'vob', 'mpg', 'mpeg', 'mp4', '3gp', '3g2', 'mkv', 'rm', 'rmvb', 'mov', 'qt', 'ogg', 'ogv', 'oga', 'mod']); const videoSet = new Set(["flv", 'avi', 'wmv', 'dat', 'vob', 'mpg', 'mpeg', 'mp4', '3gp', '3g2', 'mkv', 'rm', 'rmvb', 'mov', 'qt', 'ogg', 'ogv', 'oga', 'mod']);
/** /**
@ -34,3 +35,23 @@ export function isNfo(str: string) {
} }
return "nfo" == str; return "nfo" == str;
} }
let pattern1 = new RegExp(/s(eason)?\.?(\d+)/);
let pattern2 = new RegExp(/(\d+)/);
/**
*
* @param str
*/
export function getSeason(name: string) {
name = name.replace(/[ ]+/, "").toLocaleLowerCase();
let patternRes = name.match(pattern1);
if (patternRes && patternRes[2]) {
return patternRes[2];
}
patternRes = name.match(pattern2);
if (patternRes && patternRes[1]) {
return patternRes[1];
}
return "";
}

View File

@ -40,19 +40,19 @@ export default {
name: "Home", name: "Home",
data() { data() {
return { return {
version: 1.3, version: 1.4,
latestVersion: null, latestVersion: null,
activeIndex: location.pathname, activeIndex: location.pathname,
}; };
}, },
async beforeCreate() {
window.token = localStorage.getItem("token");
window.isWindows = await httpUtil.get("/file/isWindows");
},
async created() { async created() {
// //
let config = await httpUtil.get("https://s3.fleyx.com/picbed/openRenamer/config.json"); let config = await httpUtil.get("https://s3.fleyx.com/picbed/openRenamer/config.json");
this.latestVersion = config.version; this.latestVersion = config.version;
window.token = localStorage.getItem("token");
window.isWindows = await httpUtil.get("/file/isWindows");
console.log(this.$route);
console.log(this.activeIndex);
}, },
async mounted() { async mounted() {
console.log(this.$route); console.log(this.$route);

View File

@ -22,7 +22,7 @@
</el-tag> </el-tag>
</div> </div>
<div style="margin-top: 5px"> <div style="margin-top: 5px">
<el-button type="primary" size="small" @click="selectAllFiles">反选</el-button> <el-button type="primary" size="small" @click="selectAllFiles">{{ allChecked ? "不选" : "全选" }}</el-button>
<el-tooltip effect="dark" content="一键选中所有的非视频、字幕文件和小于5MB的视频文件" placement="bottom"> <el-tooltip effect="dark" content="一键选中所有的非视频、字幕文件和小于5MB的视频文件" placement="bottom">
<el-button type="success" size="small" @click="choseAdFile">一键选择</el-button> <el-button type="success" size="small" @click="choseAdFile">一键选择</el-button>
</el-tooltip> </el-tooltip>
@ -120,7 +120,11 @@ export default {
showNameEditDialog: false // showNameEditDialog: false //
}; };
}, },
computed: {}, computed: {
allChecked() {
return this.fileList.length > 0 && this.fileList.filter(item => item.checked).length === this.fileList.length;
}
},
async created() { async created() {
this.savePathList = await HttpUtil.get("/file/path"); this.savePathList = await HttpUtil.get("/file/path");
window.isWindows = await HttpUtil.get("/file/isWindows"); window.isWindows = await HttpUtil.get("/file/isWindows");
@ -214,9 +218,9 @@ export default {
this.showNameEditDialog = false; this.showNameEditDialog = false;
await this.showResult(); await this.showResult();
}, },
//
selectAllFiles() { selectAllFiles() {
this.fileList.forEach((item) => (item.checked = !item.checked)); let checked = !this.allChecked;
this.fileList.forEach((item) => (item.checked = checked));
}, },
// //
checkRuleAndFile() { checkRuleAndFile() {