diff --git a/package.json b/package.json index 7b05616..6934074 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "minyami", - "version": "2.1.1", + "version": "2.1.2", "description": "", "main": "index.js", "scripts": { diff --git a/src/core/archive.ts b/src/core/archive.ts index 5ea3fcb..fe126a3 100644 --- a/src/core/archive.ts +++ b/src/core/archive.ts @@ -2,7 +2,7 @@ import Logger from '../utils/log'; import { mergeToMKV, mergeToTS } from '../utils/media'; import { deleteDirectory } from '../utils/system'; import M3U8 from './m3u8'; -import Downloader, { ArchiveDownloaderConfig, ChunkItem, isChunkGroup, Chunk, ChunkGroup } from './downloader'; +import Downloader, { ArchiveDownloaderConfig, ChunkItem, isChunkGroup, Chunk } from './downloader'; import * as fs from 'fs'; import { saveTask, deleteTask, getTask } from '../utils/task'; import { timeStringToSeconds } from '../utils/time'; @@ -17,7 +17,9 @@ class ArchiveDownloader extends Downloader { chunks: ChunkItem[] = []; allChunks: ChunkItem[] = []; pickedChunks: ChunkItem[] = []; - finishedFilenames: { [index: string]: any } = {}; + // 使用 Object 的原因是使用数组,检索需要遍历数组 1/2 * n^2 次 + // 当有数千块的时候有那么一点点不可接受 + finishedFilenames: { [index: string]: any } = {}; outputFileList: string[]; totalChunksCount: number; diff --git a/src/core/downloader.ts b/src/core/downloader.ts index 9caf5b2..7a57e2d 100644 --- a/src/core/downloader.ts +++ b/src/core/downloader.ts @@ -106,7 +106,7 @@ class Downloader { } if (output) { - this.outputPath = output; + this.outputPath = output.replace(/[\/\*\\\:|\?<>]/ig, ""); } if (key) { diff --git a/src/index.ts b/src/index.ts index d01c938..73e8140 100644 --- a/src/index.ts +++ b/src/index.ts @@ -132,8 +132,13 @@ Erii.addOption({ validate: (path: string, logger) => { if (!path.endsWith('.mkv') && !path.endsWith('.ts')) { logger('Output filename must ends with .mkv or .ts.'); + return false; + } + if (path.match(/[\/\*\\\:|\?<>]/)) { + logger('Filename should\'t contain \\, /, :, |, <, >.'); + return false; } - return !(!path.endsWith('.mkv') && !path.endsWith('.ts')); + return true; } }, });