diff --git a/src/main/core/downloader/n-m3u8dl-cli-downloader.ts b/src/main/core/downloader/n-m3u8dl-cli-downloader.ts index 4329ec7..2d95bd2 100644 --- a/src/main/core/downloader/n-m3u8dl-cli-downloader.ts +++ b/src/main/core/downloader/n-m3u8dl-cli-downloader.ts @@ -32,7 +32,7 @@ class NM3u8dlCliDownloader extends Downloader { .reduce((prev: string[], [key, value]) => { if (key === "url") return prev; if (value && typeof value === "boolean") prev.push(`--${key}`); - if (value && typeof value === "string") + if (value && (typeof value === "string" || typeof value === "number")) prev.push(`--${key} "${value}"`); return prev; }, []) diff --git a/src/renderer/components/HeaderEdit/index.tsx b/src/renderer/components/HeaderEdit/index.tsx index 19a1e9a..103938c 100644 --- a/src/renderer/components/HeaderEdit/index.tsx +++ b/src/renderer/components/HeaderEdit/index.tsx @@ -58,8 +58,7 @@ interface FormItem { const renderItem = ( item: FormItem, onChange: (item: FormItem) => void, - onDelete: (item: FormItem) => void, - onInputBlur: () => void + onDelete: (item: FormItem) => void ) => { return ( @@ -79,7 +78,6 @@ const renderItem = ( onChange={(value) => { onChange({ ...item, key: value }); }} - onBlur={onInputBlur} /> @@ -88,7 +86,6 @@ const renderItem = ( onChange={(e) => { onChange({ ...item, value: e.target.value }); }} - onBlur={onInputBlur} /> @@ -138,16 +135,17 @@ const HeaderFieldInput: FC = ({ value, onChange }) => { changeItem.value = item.value; setFormValues(copiedFormValues); + onChange?.(postHeader(copiedFormValues)); }; const onInputDelete = (item: FormItem) => { const changeItemIndex = formValues.findIndex((i) => i.id === item.id); if (changeItemIndex < 0) return; - const copiedFormItem = formValues.slice(); - copiedFormItem.splice(changeItemIndex, 1); - setFormValues(copiedFormItem); - onChange?.(postHeader(copiedFormItem)); + const copiedFormValues = formValues.slice(); + copiedFormValues.splice(changeItemIndex, 1); + setFormValues(copiedFormValues); + onChange?.(postHeader(copiedFormValues)); }; const onInputAdd = () => { @@ -155,26 +153,23 @@ const HeaderFieldInput: FC = ({ value, onChange }) => { setFormValues(changedValue); }; - const onInputBlur = () => { - onChange?.(postHeader(formValues)); - }; - return ( {formValues.length > 0 && ( - + {formValues.map((formItem) => { - return renderItem( - formItem, - onInputChange, - onInputDelete, - onInputBlur - ); + return renderItem(formItem, onInputChange, onInputDelete); })} )} - - diff --git a/src/renderer/nodes/main/elements/DownloadList/index.tsx b/src/renderer/nodes/main/elements/DownloadList/index.tsx index 43778d5..69579ae 100644 --- a/src/renderer/nodes/main/elements/DownloadList/index.tsx +++ b/src/renderer/nodes/main/elements/DownloadList/index.tsx @@ -82,10 +82,6 @@ interface Props { updateTableData: () => Promise; } -const headersPlaceholder = `[可空] 请输入一行一个Header,例如: -Origin: https://www.sample.com -Referer: https://www.sample.com`; - const colorMap = { ready: "#108ee9", downloading: "#2db7f5", @@ -224,11 +220,12 @@ const DownloadList: React.FC = ({ const insertUpdateTableData = async ( item: SourceItemForm ): Promise => { - const { workspace } = settings; + const { workspace, exeFile } = settings; const sourceItem: SourceItem = { id: nanoid(), status: SourceStatus.Ready, type: SourceType.M3u8, + exeFile, directory: workspace, title: item.title, duration: 0, @@ -300,9 +297,10 @@ const DownloadList: React.FC = ({ const downloadFile = async (item: SourceItem): Promise => { await changeSourceStatus(item, SourceStatus.Downloading); onEvent.tableStartDownload(); - const exeFile = await window.electron.store.get("exeFile"); + const { title, headers, url, exeFile: formExeFile } = item; + + const exeFile = formExeFile || (await window.electron.store.get("exeFile")); const workspace = await window.electron.store.get("workspace"); - const { title, headers, url } = item; let args: MediaGoArgs | M3u8DLArgs; if (exeFile === "mediago") { @@ -316,6 +314,22 @@ const DownloadList: React.FC = ({ headers: headersString, }; } else { + const { + checkbox, + maxThreads, + minThreads, + retryCount, + timeOut, + stopSpeed, + maxSpeed, + } = item; + const checkboxObj = Object.values(checkbox! || []).reduce( + (prev: Record, cur) => { + prev[cur] = true; + return prev; + }, + {} + ); const headersString = Object.entries(headers || {}) .map(([key, value]) => `${key}:${value}`) .join("|"); @@ -325,8 +339,16 @@ const DownloadList: React.FC = ({ saveName: title, // 设定存储文件名(不包括后缀) headers: headersString, enableDelAfterDone: item.deleteSegments, + ...checkboxObj, + maxThreads, + minThreads, + retryCount, + timeOut, + stopSpeed, + maxSpeed, }; } + console.log("args: ", args); const { code, msg } = await ipcExec(exeFile, args); if (code === 0) { @@ -625,9 +647,11 @@ const DownloadList: React.FC = ({ flex={1} className={"list-item-inner"} onClick={() => { + const { exeFile } = settings; setCurrentSourceItem(item); - detailForm.setFieldsValue(item); + detailForm.setFieldsValue({ ...item, exeFile }); calcMaxWidth(); + setMoreOptions(exeFile !== "mediago"); dispatch(updateNotifyCount(0)); }} > @@ -737,35 +761,56 @@ const DownloadList: React.FC = ({ {!expanded && ( <> - + - 合并后删除分片 + + 合并后删除分片 + - 不写入日期 + + 不写入日期 + - 不使用系统代理 + + 不使用系统代理 + - 仅解析m3u8 + + 仅解析m3u8 + - 混流MP4 + + 混流MP4 + - 下载完不合并 + + 下载完不合并 + - 使用二进制合并 + + 使用二进制合并 + - 仅合并音频轨道 + + 仅合并音频轨道 + - 关闭完整性检查 + + 关闭完整性检查 + @@ -773,80 +818,68 @@ const DownloadList: React.FC = ({ - + - + - + - + - + - + @@ -925,13 +958,7 @@ const DownloadList: React.FC = ({ > - - - +