fast-dirpy 0.1.5 → 0.1.6
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/README.md +7 -7
- package/dist/chunk-DK24QP3J.js +2 -0
- package/dist/chunk-OYM7YQEE.js +1 -0
- package/dist/cli.js +1 -1
- package/dist/{config-BzOW2OFi.d.ts → config-DKxT5hQw.d.ts} +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +1 -1
- package/package.json +8 -6
- package/dist/chunk-MLOFRCSF.js +0 -2
- package/dist/chunk-OTOEWWYP.js +0 -1
- /package/dist/{chunk-LP3GSA6N.js → chunk-HD53P4DN.js} +0 -0
package/README.md
CHANGED
|
@@ -58,9 +58,9 @@ export default defineConfig({
|
|
|
58
58
|
# Proxy:
|
|
59
59
|
# -H, --proxyHost: proxy host
|
|
60
60
|
# -P, --proxyPort: proxy port
|
|
61
|
-
# -c, --config: Specified external config file.
|
|
61
|
+
# -c, --config: Specified external config file.
|
|
62
62
|
# e.g.: fast-dirpy get https://xxx -c ~/Downloads/fast-dirpy.config.json
|
|
63
|
-
fast-dirpy get https\://www.youtube.com/watch\?v\=
|
|
63
|
+
fast-dirpy get https\://www.youtube.com/watch\?v\=6c28qWDMPBA -H 127.0.0.1 -P 7890
|
|
64
64
|
|
|
65
65
|
# No proxy needed for Bilibili videos
|
|
66
66
|
# --bilibili: Tell fast-dirpy to get direct link from Bilibili, then bypass proxy.
|
|
@@ -70,7 +70,7 @@ fast-dirpy get --bilibili https://www.bilibili.com/video/BV1TSPeeGE35
|
|
|
70
70
|
if you have set your proxy config in `fast-dirpy.config.ts`, you can omit proxy parameters:
|
|
71
71
|
|
|
72
72
|
```shell
|
|
73
|
-
fast-dirpy get https\://www.youtube.com/watch\?v\=
|
|
73
|
+
fast-dirpy get https\://www.youtube.com/watch\?v\=6c28qWDMPBA
|
|
74
74
|
```
|
|
75
75
|
|
|
76
76
|
#### Download Video
|
|
@@ -81,9 +81,9 @@ fast-dirpy get https\://www.youtube.com/watch\?v\=SAXpBgkXt60
|
|
|
81
81
|
# Proxy:
|
|
82
82
|
# -H, --proxyHost: proxy host.
|
|
83
83
|
# -P, --proxyPort: proxy port.
|
|
84
|
-
# -c, --config: Specified external config file.
|
|
84
|
+
# -c, --config: Specified external config file.
|
|
85
85
|
# e.g.: fast-dirpy get https://xxx -c ~/Downloads/fast-dirpy.config.json
|
|
86
|
-
fast-dirpy download https\://www.youtube.com/watch\?v\=
|
|
86
|
+
fast-dirpy download https\://www.youtube.com/watch\?v\=6c28qWDMPBA -p ./test.mp4 -H 127.0.0.1 -P 7890
|
|
87
87
|
|
|
88
88
|
# No proxy needed for Bilibili videos
|
|
89
89
|
# --bilibili: Tell fast-dirpy to download from a Bilibili link.
|
|
@@ -93,7 +93,7 @@ fast-dirpy download --bilibili https://www.bilibili.com/video/BV1TSPeeGE35 -p ./
|
|
|
93
93
|
if you have set your proxy config in `fast-dirpy.config.ts`, you can omit proxy parameters:
|
|
94
94
|
|
|
95
95
|
```shell
|
|
96
|
-
fast-dirpy download https\://www.youtube.com/watch\?v\=
|
|
96
|
+
fast-dirpy download https\://www.youtube.com/watch\?v\=6c28qWDMPBA -p ./test.mp4
|
|
97
97
|
```
|
|
98
98
|
|
|
99
99
|
For further CLI help:
|
|
@@ -104,7 +104,7 @@ fast-dirpy --help
|
|
|
104
104
|
|
|
105
105
|
### Use as a library
|
|
106
106
|
```ts
|
|
107
|
-
import { downloadVideoFromRawLink,
|
|
107
|
+
import { downloadVideoFromRawLink, getBilibiliLink, getDirectLink } from 'fast-dirpy'
|
|
108
108
|
|
|
109
109
|
// get direct link
|
|
110
110
|
const link = await getDirectLink(
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as L,b as I,c as a}from"./chunk-HD53P4DN.js";var P=L((ne,M)=>{"use strict";a();var v=function(r){return C(r)&&!U(r)};function C(e){return!!e&&typeof e=="object"}function U(e){var r=Object.prototype.toString.call(e);return r==="[object RegExp]"||r==="[object Date]"||R(e)}var V=typeof Symbol=="function"&&Symbol.for,$=V?Symbol.for("react.element"):60103;function R(e){return e.$$typeof===$}function N(e){return Array.isArray(e)?[]:{}}function m(e,r){return r.clone!==!1&&r.isMergeableObject(e)?l(N(e),e,r):e}function k(e,r,t){return e.concat(r).map(function(n){return m(n,t)})}function B(e,r){if(!r.customMerge)return l;var t=r.customMerge(e);return typeof t=="function"?t:l}function F(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(r){return Object.propertyIsEnumerable.call(e,r)}):[]}function j(e){return Object.keys(e).concat(F(e))}function D(e,r){try{return r in e}catch{return!1}}function K(e,r){return D(e,r)&&!(Object.hasOwnProperty.call(e,r)&&Object.propertyIsEnumerable.call(e,r))}function z(e,r,t){var n={};return t.isMergeableObject(e)&&j(e).forEach(function(o){n[o]=m(e[o],t)}),j(r).forEach(function(o){K(e,o)||(D(e,o)&&t.isMergeableObject(r[o])?n[o]=B(o,t)(e[o],r[o],t):n[o]=m(r[o],t))}),n}function l(e,r,t){t=t||{},t.arrayMerge=t.arrayMerge||k,t.isMergeableObject=t.isMergeableObject||v,t.cloneUnlessOtherwiseSpecified=m;var n=Array.isArray(r),o=Array.isArray(e),i=n===o;return i?n?t.arrayMerge(e,r,t):z(e,r,t):m(r,t)}l.all=function(r,t){if(!Array.isArray(r))throw new Error("first argument should be an array");return r.reduce(function(n,o){return l(n,o,t)},{})};var G=l;M.exports=G});a();import T from"node:process";import{consola as _}from"consola";var p=_.withTag("fast-dirpy");function re(e){"CONSOLA_LEVEL"in T.env||(p.level=e?0:3)}a();import W from"node:fs";import x from"axios";import Y from"jsdom";a();var g=I(P(),1);import{createConfigLoader as H}from"unconfig";var u={timeout:2e4};async function O(e,r){let t=u,n=H({sources:[{files:["fast-dirpy.config"],extensions:["ts","mts","cts","js","mjs","cjs","json"]}],cwd:r||process.cwd(),merge:!1}),{config:o,sources:i}=await n.load();return i.length?(p.info(`Config file found: ${i[0]}`),(0,g.default)((0,g.default)(t,o),e)):(0,g.default)(t,e)}var X={"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36"},{JSDOM:J}=Y;async function Z(e,r=u){let{url:t,cwd:n}=e,{proxy:o,timeout:i}=await O(r,n),b=o?.host!==""?o:void 0,{data:f}=await x.get("https://dirpy.com/studio",{params:{url:t},headers:{...X,Referer:`https://dirpy.com/studio?url=${t}`},proxy:b,timeout:i}),{window:h}=new J(f),s="",c=h.document.getElementById("media-source");return c&&(s=c.src),s}async function w(e,r=u){let{path:t,url:n}=e,{proxy:o,timeout:i}=await O(r),b=o?.host!==""?o:void 0;if(n==="")return Promise.reject("Extract direct link failed!");let f=W.createWriteStream(t);return(await x({url:n,headers:{"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36"},method:"GET",responseType:"stream",proxy:b,timeout:i,onDownloadProgress:s=>{let{loaded:c,total:A,progress:S}=s,E=`loaded:${c} total: ${A} progress: ${(S*100).toFixed(2)}%
|
|
2
|
+
`;p.info(E)}})).data.pipe(f),new Promise((s,c)=>{f.on("finish",s),f.on("error",c)})}async function ye(e,r=u){let{path:t,url:n,cwd:o}=e,i=await Z({url:n},r);await w({url:i,path:t,cwd:o},r)}a();function q(e){let r=e.match(/BV[a-zA-Z0-9]+/);return r?`https://bilibili-real-url.deno.dev/${r[0]}.mp4`:""}async function we(e){let{path:r,url:t}=e,n=q(t);n!==""?await w({url:n,path:r||"./download.mp4"}):console.error("Extract direct link failed!")}export{p as a,re as b,Z as c,w as d,ye as e,q as f,we as g};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as i}from"./chunk-HD53P4DN.js";i();function o(p){return p}export{o as a};
|
package/dist/cli.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as d,c
|
|
1
|
+
import{a as n,b as d,c as f,e as g,f as x,g as h}from"./chunk-DK24QP3J.js";import{c as m}from"./chunk-HD53P4DN.js";m();import{bold as b,dim as u}from"ansis";import{cac as P}from"cac";import k from"restore-cursor";var c={name:"fast-dirpy",type:"module",version:"0.1.6",description:"A simple library/CLI to download video using dirpy.com",author:"Vincent-the-gamer",license:"MIT",homepage:"https://github.com/Vincent-the-gamer/fast-dirpy#readme",repository:{type:"git",url:"git+https://github.com/Vincent-the-gamer/fast-dirpy.git"},bugs:{url:"https://github.com/Vincent-the-gamer/fast-dirpy/issues"},sideEffects:!1,main:"dist/index.js",module:"dist/index.js",types:"dist/index.d.ts",typesVersions:{"*":{".":["./dist/index.d.ts","./dist/cli.d.ts"]}},bin:{"fast-dirpy":"bin/fast-dirpy.js"},files:["dist"],scripts:{tsx:"tsx",build:"tsup",test:"vitest",dep:"taze major","lint:fix":"eslint . --fix",login:"pnpm login --registry https://registry.npmjs.com"},publishConfig:{registry:"https://registry.npmjs.com",access:"public"},dependencies:{ansis:"^3.17.0",axios:"^1.8.4",cac:"^6.7.14",consola:"^3.4.2",jsdom:"^26.1.0","restore-cursor":"^5.1.0",unconfig:"^7.3.1"},devDependencies:{"@antfu/eslint-config":"^4.12.0","@types/node":"^22.14.1",deepmerge:"^4.3.1",eslint:"^9.25.0",taze:"^19.0.4",tsup:"^8.4.0",tsx:"^4.19.3",typescript:"^5.8.3",vitest:"^3.1.1"}};var t=P("fast-dirpy"),{version:v}=c;t.command("get <url>","get video direct link.").option("--proxyHost, -H <proxyHost>","Proxy host.").option("--proxyPort, -P <proxyPort>","Proxy port.").option("--bilibili","Tell fast-dirpy to fetch a Bilibili link, then bypass proxy.").option("--config, -c <path>","Specify an external config file.").option("--silent","Suppress non-error logs").action(async(i,r)=>{let{proxyHost:o,proxyPort:p,bilibili:e,config:l,silent:a}=r;if(d(!!a),n.info(`fast-dirpy ${u(`v${v}`)} : ${b("Direct Link Getter")}.`),e){if(!i.includes("bilibili.com")){n.error("Please provide a valid Bilibili URL.");return}let s=await x(i);console.log(s)}else{let y=await f({url:i,cwd:l},o?{proxy:{host:o,port:p}}:void 0);console.log(y)}});t.command("download <url>","download a video.").option("--path, -p <path>","Download destination path + filename. e.g. /xxx/example.mp4.").option("--proxyHost, -H <proxyHost>","Proxy host.").option("--proxyPort, -P <proxyPort>","Proxy port.").option("--bilibili","Tell fast-dirpy to download from a Bilibili link.").option("--config, -c <path>","Specify an external config file.").option("--silent","Suppress non-error logs").action(async(i,r)=>{let{proxyHost:o,proxyPort:p,path:e,bilibili:l,config:a,silent:s}=r;d(!!s),n.info(`fast-dirpy ${u(`v${v}`)} : ${b("Video Downloader")}.`),l?await h({url:i,path:e}):g({url:i,path:e||"./download.mp4",cwd:a},o?{proxy:{host:o,port:p}}:void 0)});t.help();t.version(c.version);t.parse();k();
|
|
@@ -18,4 +18,4 @@ interface DownloadParams {
|
|
|
18
18
|
|
|
19
19
|
declare function defineConfig(options: DirpyOptions): DirpyOptions;
|
|
20
20
|
|
|
21
|
-
export { type
|
|
21
|
+
export { type DownloadParams as D, type DirectLinkParams as a, type DirpyOptions as b, defineConfig as d };
|
package/dist/config.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { d as defineConfig } from './config-
|
|
1
|
+
export { d as defineConfig } from './config-DKxT5hQw.js';
|
package/dist/config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-OYM7YQEE.js";import"./chunk-HD53P4DN.js";export{a as defineConfig};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { D as
|
|
2
|
-
export { d as defineConfig } from './config-
|
|
1
|
+
import { D as DownloadParams, a as DirectLinkParams, b as DirpyOptions } from './config-DKxT5hQw.js';
|
|
2
|
+
export { d as defineConfig } from './config-DKxT5hQw.js';
|
|
3
|
+
|
|
4
|
+
declare function getBilibiliDirectLink(link: string): string;
|
|
5
|
+
declare function downloadBilibiliVideo(params: DownloadParams): Promise<void>;
|
|
3
6
|
|
|
4
7
|
declare function getDirectLink(params: DirectLinkParams, options?: Partial<DirpyOptions>): Promise<string>;
|
|
5
8
|
declare function downloadVideo(params: DownloadParams, options?: Partial<DirpyOptions>): Promise<void>;
|
|
6
9
|
declare function downloadVideoFromRawLink(params: DownloadParams, options?: Partial<DirpyOptions>): Promise<void>;
|
|
7
10
|
|
|
8
|
-
declare function getBilibiliDirectLink(link: string): string;
|
|
9
|
-
declare function downloadBilibiliVideo(params: DownloadParams): Promise<void>;
|
|
10
|
-
|
|
11
11
|
export { DirectLinkParams, DirpyOptions, DownloadParams, downloadBilibiliVideo, downloadVideo, downloadVideoFromRawLink, getBilibiliDirectLink, getDirectLink };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{c as r,d as e,e as f,f as m,g as p}from"./chunk-DK24QP3J.js";import{a as t}from"./chunk-OYM7YQEE.js";import{c as o}from"./chunk-HD53P4DN.js";o();export{t as defineConfig,p as downloadBilibiliVideo,e as downloadVideo,f as downloadVideoFromRawLink,m as getBilibiliDirectLink,r as getDirectLink};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fast-dirpy",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.6",
|
|
5
5
|
"description": "A simple library/CLI to download video using dirpy.com",
|
|
6
6
|
"author": "Vincent-the-gamer",
|
|
7
7
|
"license": "MIT",
|
|
@@ -36,21 +36,23 @@
|
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
+
"ansis": "^3.17.0",
|
|
39
40
|
"axios": "^1.8.4",
|
|
40
41
|
"cac": "^6.7.14",
|
|
41
|
-
"
|
|
42
|
+
"consola": "^3.4.2",
|
|
43
|
+
"jsdom": "^26.1.0",
|
|
42
44
|
"restore-cursor": "^5.1.0",
|
|
43
45
|
"unconfig": "^7.3.1"
|
|
44
46
|
},
|
|
45
47
|
"devDependencies": {
|
|
46
|
-
"@antfu/eslint-config": "^4.
|
|
47
|
-
"@types/node": "^22.
|
|
48
|
+
"@antfu/eslint-config": "^4.12.0",
|
|
49
|
+
"@types/node": "^22.14.1",
|
|
48
50
|
"deepmerge": "^4.3.1",
|
|
49
|
-
"eslint": "^9.
|
|
51
|
+
"eslint": "^9.25.0",
|
|
50
52
|
"taze": "^19.0.4",
|
|
51
53
|
"tsup": "^8.4.0",
|
|
52
54
|
"tsx": "^4.19.3",
|
|
53
|
-
"typescript": "^5.8.
|
|
55
|
+
"typescript": "^5.8.3",
|
|
54
56
|
"vitest": "^3.1.1"
|
|
55
57
|
},
|
|
56
58
|
"scripts": {
|
package/dist/chunk-MLOFRCSF.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as E,b as T,c as a}from"./chunk-LP3GSA6N.js";var M=E((J,D)=>{"use strict";a();var _=function(r){return I(r)&&!L(r)};function I(e){return!!e&&typeof e=="object"}function L(e){var r=Object.prototype.toString.call(e);return r==="[object RegExp]"||r==="[object Date]"||R(e)}var v=typeof Symbol=="function"&&Symbol.for,U=v?Symbol.for("react.element"):60103;function R(e){return e.$$typeof===U}function V(e){return Array.isArray(e)?[]:{}}function p(e,r){return r.clone!==!1&&r.isMergeableObject(e)?l(V(e),e,r):e}function $(e,r,t){return e.concat(r).map(function(o){return p(o,t)})}function C(e,r){if(!r.customMerge)return l;var t=r.customMerge(e);return typeof t=="function"?t:l}function k(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(r){return Object.propertyIsEnumerable.call(e,r)}):[]}function h(e){return Object.keys(e).concat(k(e))}function j(e,r){try{return r in e}catch{return!1}}function B(e,r){return j(e,r)&&!(Object.hasOwnProperty.call(e,r)&&Object.propertyIsEnumerable.call(e,r))}function F(e,r,t){var o={};return t.isMergeableObject(e)&&h(e).forEach(function(n){o[n]=p(e[n],t)}),h(r).forEach(function(n){B(e,n)||(j(e,n)&&t.isMergeableObject(r[n])?o[n]=C(n,t)(e[n],r[n],t):o[n]=p(r[n],t))}),o}function l(e,r,t){t=t||{},t.arrayMerge=t.arrayMerge||$,t.isMergeableObject=t.isMergeableObject||_,t.cloneUnlessOtherwiseSpecified=p;var o=Array.isArray(r),n=Array.isArray(e),i=o===n;return i?o?t.arrayMerge(e,r,t):F(e,r,t):p(r,t)}l.all=function(r,t){if(!Array.isArray(r))throw new Error("first argument should be an array");return r.reduce(function(o,n){return l(o,n,t)},{})};var K=l;D.exports=K});a();import z from"node:fs";import P from"axios";import G from"jsdom";a();var m=T(M(),1);import{createConfigLoader as N}from"unconfig";var u={timeout:2e4};async function g(e,r){let t=u,o=N({sources:[{files:["fast-dirpy.config"],extensions:["ts","mts","cts","js","mjs","cjs","json"]}],cwd:r||process.cwd(),merge:!1}),{config:n,sources:i}=await o.load();return i.length?(0,m.default)((0,m.default)(t,n),e):(0,m.default)(t,e)}var H={"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36"},{JSDOM:W}=G;async function Y(e,r=u){let{url:t,cwd:o}=e,{proxy:n,timeout:i}=await g(r,o),d=n?.host!==""?n:void 0,{data:f}=await P.get("https://dirpy.com/studio",{params:{url:t},headers:{...H,Referer:`https://dirpy.com/studio?url=${t}`},proxy:d,timeout:i}),{window:w}=new W(f),s="",c=w.document.getElementById("media-source");return c&&(s=c.src),s}async function O(e,r=u){let{path:t,url:o}=e,{proxy:n,timeout:i}=await g(r),d=n?.host!==""?n:void 0;if(o==="")return Promise.reject("Extract direct link failed!");let f=z.createWriteStream(t);return(await P({url:o,headers:{"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36"},method:"GET",responseType:"stream",proxy:d,timeout:i,onDownloadProgress:s=>{let{loaded:c,total:x,progress:A}=s,S=`loaded:${c} total: ${x} progress: ${(A*100).toFixed(2)}%
|
|
2
|
-
`;console.log(S)}})).data.pipe(f),new Promise((s,c)=>{f.on("finish",s),f.on("error",c)})}async function ie(e,r=u){let{path:t,url:o,cwd:n}=e,i=await Y({url:o},r);await O({url:i,path:t,cwd:n},r)}a();function X(e){let r=e.match(/BV[a-zA-Z0-9]+/);return r?`https://bilibili-real-url.deno.dev/${r[0]}.mp4`:""}async function le(e){let{path:r,url:t}=e,o=X(t);o!==""?await O({url:o,path:r||"./download.mp4"}):console.error("Extract direct link failed!")}export{Y as a,O as b,ie as c,X as d,le as e};
|
package/dist/chunk-OTOEWWYP.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as i}from"./chunk-LP3GSA6N.js";i();function o(p){return p}export{o as a};
|
|
File without changes
|