Skip to content

Commit

Permalink
escape windows-hated characters
Browse files Browse the repository at this point in the history
  • Loading branch information
Last-Order committed Dec 18, 2018
1 parent 6d0bcc3 commit 40ac974
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "minyami",
"version": "2.1.1",
"version": "2.1.2",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
6 changes: 4 additions & 2 deletions src/core/archive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/core/downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class Downloader {
}

if (output) {
this.outputPath = output;
this.outputPath = output.replace(/[\/\*\\\:|\?<>]/ig, "");
}

if (key) {
Expand Down
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
},
});
Expand Down

0 comments on commit 40ac974

Please sign in to comment.