Skip to content

Commit

Permalink
wip: 默认并发数最多为 8
Browse files Browse the repository at this point in the history
  • Loading branch information
renxia committed Jul 5, 2023
1 parent 72058ba commit 7e29ae0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib/m3u8-download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async function formatOptions(url: string, opts: M3u8DLOptions) {
}
const urlMd5 = md5(url, false);

if (!options.threadNum || +options.threadNum <= 0) options.threadNum = cpus().length * 2;
if (!options.threadNum || +options.threadNum <= 0) options.threadNum = Math.min(cpus().length * 2, 8);
if (!options.filename) options.filename = urlMd5;
if (!options.filename.endsWith('.mp4')) options.filename += '.mp4';
if (!options.cacheDir) options.cacheDir = `cache/${urlMd5}`;
Expand Down
2 changes: 1 addition & 1 deletion src/types/m3u8.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export interface M3u8DLOptions {
showProgress?: boolean;
/** 每当 ts 文件下载完成时回调,可用于自定义进度控制 */
onProgress?: (finished: number, total: number, currentInfo: TsItemInfo) => void;
/** 并发下载线程数。取决于服务器限制,过多可能会容易下载失败。一般建议不超过 4 个。默认为 cpu 数量 */
/** 并发下载线程数。取决于服务器限制,过多可能会容易下载失败。一般建议不超过 8 个。默认为 cpu数 * 2,但不超过 8 */
threadNum?: number;
/** 要保存的文件名(路径) */
filename?: string;
Expand Down

0 comments on commit 7e29ae0

Please sign in to comment.