@secret-momo/utils 1.4.2 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/download/aria2.js +1 -1
- package/package.json +5 -5
package/lib/download/aria2.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{mkdirSync as
|
|
1
|
+
import{mkdirSync as m,existsSync as f}from"node:fs";import{rm as l}from"node:fs/promises";import{join as d,basename as p}from"node:path";import{execFile as w}from"node:child_process";import{promisify as E}from"node:util";import{dateTimeToNow as h}from"../date-time.js";import{fetch as y}from"../fetch.js";import{logger as D}from"../pino.js";import{pickVideoExtension as S}from"./extension.js";import{fileSize as g}from"../file.js";const u=E(w),c=D.child({name:"aria2DownloadVideo"});async function F(r,t){const o=[r,`${r}.aria2`].filter(a=>!t.has(a)),e=(await Promise.allSettled(o.map(a=>l(a,{force:!0})))).flatMap(a=>a.status==="rejected"?[a.reason]:[]);e.length>0&&c.error(new AggregateError(e,"\u6E05\u7406 aria2 \u4E0B\u8F7D\u4E2D\u95F4\u4EA7\u7269\u5931\u8D25"))}async function x(){try{await u("aria2c",["--version"])}catch(r){throw r.code==="ENOENT"?new Error("\u672A\u627E\u5230 aria2c \u547D\u4EE4\u884C\u5DE5\u5177\uFF0C\u8BF7\u5148\u4F7F\u7528 brew install aria2 \u5B89\u88C5\u3002",{cause:r}):r}}async function A(r){try{return(await y(r,{method:"HEAD"})).headers.get("content-type")}catch{return null}}async function M({url:r,dir:t,referer:o}){await x();let e;const a=new Set;try{m(t,{recursive:!0});const i=S(r,await A(r));e=d(t,`${h("YYYYMMDD_HHmmss")}.${i}`);for(const n of[e,`${e}.aria2`])f(n)&&a.add(n);const s=["-x8","-s8","-k1M","--auto-file-renaming=false",...o?["--referer",o]:[],"-d",t,"-o",p(e),r];return await u("aria2c",s),{isSuccess:!0,filePath:e,fileSize:await g(e)}}catch(i){return e&&await F(e,a),c.error(i),{isSuccess:!1,error:i}}}export{M as aria2DownloadVideo};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@secret-momo/utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"module": "src/index.ts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -38,19 +38,19 @@
|
|
|
38
38
|
"@eslint/config-helpers": "0.7.0",
|
|
39
39
|
"@eslint/js": "10.0.1",
|
|
40
40
|
"@types/bun": "1.4.0",
|
|
41
|
-
"eslint": "10.9.
|
|
41
|
+
"eslint": "10.9.1",
|
|
42
42
|
"eslint-plugin-import-x": "4.17.1",
|
|
43
43
|
"eslint-plugin-react": "7.37.5",
|
|
44
44
|
"eslint-plugin-react-hooks": "7.1.1",
|
|
45
45
|
"eslint-plugin-unused-imports": "4.4.1",
|
|
46
46
|
"husky": "9.1.7",
|
|
47
47
|
"jiti": "2.7.0",
|
|
48
|
-
"lint-staged": "17.
|
|
48
|
+
"lint-staged": "17.4.1",
|
|
49
49
|
"prettier": "3.9.6",
|
|
50
|
-
"rollup": "4.
|
|
50
|
+
"rollup": "4.63.1",
|
|
51
51
|
"rollup-plugin-esbuild": "6.2.1",
|
|
52
52
|
"typescript": "6.0.3",
|
|
53
|
-
"typescript-eslint": "8.
|
|
53
|
+
"typescript-eslint": "8.69.0"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"dayjs": "1.11.23",
|