feat:优化季识别
This commit is contained in:
parent
11f28f12fa
commit
9a55460f11
@ -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 {
|
||||||
|
@ -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":
|
||||||
|
@ -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 "";
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user