fast-dirpy 0.1.3 → 0.1.5
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 +41 -10
- package/dist/chunk-MLOFRCSF.js +2 -0
- package/dist/cli.js +1 -1
- package/dist/config-BzOW2OFi.d.ts +21 -0
- package/dist/config.d.ts +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-WYAG3YFC.js +0 -2
- package/dist/config-CsHryMou.d.ts +0 -12
package/README.md
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src=".github/fast-dirpy.png" style="width: 90px;"/>
|
|
3
|
+
<h1>fast-dirpy</h1>
|
|
4
|
+
</div>
|
|
2
5
|
|
|
3
6
|
[![npm version][npm-version-src]][npm-version-href]
|
|
4
7
|
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
5
|
-
[![bundle][bundle-src]][bundle-href]
|
|
6
8
|
[![JSDocs][jsdocs-src]][jsdocs-href]
|
|
7
9
|
[![License][license-src]][license-href]
|
|
8
10
|
|
|
9
11
|
A simple library/CLI to download youtube(etc.) videos.
|
|
10
12
|
|
|
13
|
+
## Supported Websites
|
|
14
|
+
|
|
15
|
+
- [YouTube](https://www.youtube.com/)
|
|
16
|
+
- [Bilibili](https://www.bilibili.com/)
|
|
17
|
+
|
|
11
18
|
## Installation
|
|
12
19
|
|
|
13
20
|
### As a library
|
|
@@ -25,9 +32,9 @@ npm i fast-dirpy -g
|
|
|
25
32
|
### Config file
|
|
26
33
|
|
|
27
34
|
> [!IMPORTANT]
|
|
28
|
-
> `fast-dirpy.config` can be `fast-dirpy.config.['ts', 'mts', 'cts', 'js', 'mjs', 'cjs']`
|
|
35
|
+
> `fast-dirpy.config` can be `fast-dirpy.config.['ts', 'mts', 'cts', 'js', 'mjs', 'cjs', 'json']`
|
|
29
36
|
|
|
30
|
-
You can create a `fast-dirpy.config
|
|
37
|
+
You can create a `fast-dirpy.config` file in your library root or same location in command line.
|
|
31
38
|
|
|
32
39
|
```ts
|
|
33
40
|
import { defineConfig } from 'fast-dirpy'
|
|
@@ -51,8 +58,13 @@ export default defineConfig({
|
|
|
51
58
|
# Proxy:
|
|
52
59
|
# -H, --proxyHost: proxy host
|
|
53
60
|
# -P, --proxyPort: proxy port
|
|
54
|
-
|
|
61
|
+
# -c, --config: Specified external config file.
|
|
62
|
+
# e.g.: fast-dirpy get https://xxx -c ~/Downloads/fast-dirpy.config.json
|
|
55
63
|
fast-dirpy get https\://www.youtube.com/watch\?v\=SAXpBgkXt60 -H 127.0.0.1 -P 7890
|
|
64
|
+
|
|
65
|
+
# No proxy needed for Bilibili videos
|
|
66
|
+
# --bilibili: Tell fast-dirpy to get direct link from Bilibili, then bypass proxy.
|
|
67
|
+
fast-dirpy get --bilibili https://www.bilibili.com/video/BV1TSPeeGE35
|
|
56
68
|
```
|
|
57
69
|
|
|
58
70
|
if you have set your proxy config in `fast-dirpy.config.ts`, you can omit proxy parameters:
|
|
@@ -69,7 +81,13 @@ fast-dirpy get https\://www.youtube.com/watch\?v\=SAXpBgkXt60
|
|
|
69
81
|
# Proxy:
|
|
70
82
|
# -H, --proxyHost: proxy host.
|
|
71
83
|
# -P, --proxyPort: proxy port.
|
|
84
|
+
# -c, --config: Specified external config file.
|
|
85
|
+
# e.g.: fast-dirpy get https://xxx -c ~/Downloads/fast-dirpy.config.json
|
|
72
86
|
fast-dirpy download https\://www.youtube.com/watch\?v\=SAXpBgkXt60 -p ./test.mp4 -H 127.0.0.1 -P 7890
|
|
87
|
+
|
|
88
|
+
# No proxy needed for Bilibili videos
|
|
89
|
+
# --bilibili: Tell fast-dirpy to download from a Bilibili link.
|
|
90
|
+
fast-dirpy download --bilibili https://www.bilibili.com/video/BV1TSPeeGE35 -p ./test.mp4
|
|
73
91
|
```
|
|
74
92
|
|
|
75
93
|
if you have set your proxy config in `fast-dirpy.config.ts`, you can omit proxy parameters:
|
|
@@ -86,26 +104,41 @@ fast-dirpy --help
|
|
|
86
104
|
|
|
87
105
|
### Use as a library
|
|
88
106
|
```ts
|
|
89
|
-
import { downloadVideoFromRawLink, getDirectLink } from 'fast-dirpy'
|
|
107
|
+
import { downloadVideoFromRawLink, getDirectLink, getBilibiliLink } from 'fast-dirpy'
|
|
90
108
|
|
|
91
109
|
// get direct link
|
|
92
110
|
const link = await getDirectLink(
|
|
93
|
-
|
|
111
|
+
{
|
|
112
|
+
url: '<url>',
|
|
113
|
+
cwd: '/path/to/external-config' // Optional: You can specify an external config file.
|
|
114
|
+
},
|
|
94
115
|
{
|
|
95
116
|
host: '127.0.0.1',
|
|
96
117
|
port: 7890
|
|
97
118
|
}
|
|
98
119
|
)
|
|
99
120
|
|
|
121
|
+
// get bilibili direct link
|
|
122
|
+
const link = await getBilibiliLink(
|
|
123
|
+
'<url>',
|
|
124
|
+
)
|
|
125
|
+
|
|
100
126
|
// download video
|
|
101
127
|
await downloadVideoFromRawLink({
|
|
102
|
-
url,
|
|
128
|
+
url: '<url>',
|
|
103
129
|
path: './download.mp4',
|
|
130
|
+
cwd: '/path/to/external-config', // Optional: You can specify an external config file.
|
|
104
131
|
proxy: {
|
|
105
132
|
host: '127.0.0.1',
|
|
106
133
|
port: 7890
|
|
107
134
|
}
|
|
108
135
|
})
|
|
136
|
+
|
|
137
|
+
// download bilibili video
|
|
138
|
+
await downloadBilibiliVideo({
|
|
139
|
+
url: '<url>',
|
|
140
|
+
path: './myvideo.mp4'
|
|
141
|
+
})
|
|
109
142
|
```
|
|
110
143
|
|
|
111
144
|
## License
|
|
@@ -118,8 +151,6 @@ await downloadVideoFromRawLink({
|
|
|
118
151
|
[npm-version-href]: https://npmjs.com/package/fast-dirpy
|
|
119
152
|
[npm-downloads-src]: https://img.shields.io/npm/dm/fast-dirpy?style=flat&colorA=080f12&colorB=1fa669
|
|
120
153
|
[npm-downloads-href]: https://npmjs.com/package/fast-dirpy
|
|
121
|
-
[bundle-src]: https://img.shields.io/bundlephobia/minzip/fast-dirpy?style=flat&colorA=080f12&colorB=1fa669&label=minzip
|
|
122
|
-
[bundle-href]: https://bundlephobia.com/result?p=fast-dirpy
|
|
123
154
|
[license-src]: https://img.shields.io/github/license/Vincent-the-gamer/fast-dirpy.svg?style=flat&colorA=080f12&colorB=1fa669
|
|
124
155
|
[license-href]: https://github.com/Vincent-the-gamer/fast-dirpy/blob/main/LICENSE
|
|
125
156
|
[jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-080f12?style=flat&colorA=080f12&colorB=1fa669
|
|
@@ -0,0 +1,2 @@
|
|
|
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/cli.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as d,
|
|
1
|
+
import{a as d,c,d as y,e as m}from"./chunk-MLOFRCSF.js";import{c as a}from"./chunk-LP3GSA6N.js";a();import{cac as x}from"cac";import h from"restore-cursor";var f={name:"fast-dirpy",type:"module",version:"0.1.5",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:{axios:"^1.8.4",cac:"^6.7.14",jsdom:"^26.0.0","restore-cursor":"^5.1.0",unconfig:"^7.3.1"},devDependencies:{"@antfu/eslint-config":"^4.11.0","@types/node":"^22.13.17",deepmerge:"^4.3.1",eslint:"^9.23.0",taze:"^19.0.4",tsup:"^8.4.0",tsx:"^4.19.3",typescript:"^5.8.2",vitest:"^3.1.1"}};var e=x("fast-dirpy");e.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.").action(async(i,r)=>{let{proxyHost:o,proxyPort:p,bilibili:s,config:n}=r;if(s){if(!i.includes("bilibili.com")){console.error("Please provide a valid Bilibili URL.");return}let t=await y(i);console.log(t)}else{let t=o?{proxy:{host:o,port:p}}:void 0;console.log(n);let l=await d({url:i,cwd:n},t);console.log(l)}});e.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.").action(async(i,r)=>{let{proxyHost:o,proxyPort:p,path:s,bilibili:n,config:t}=r;n?await m({url:i,path:s}):c({url:i,path:s||"./download.mp4",cwd:t},o?{proxy:{host:o,port:p}}:void 0)});e.help();e.version(f.version);e.parse();h();
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
interface DirpyOptions {
|
|
2
|
+
proxy?: {
|
|
3
|
+
protocol?: string;
|
|
4
|
+
host: string;
|
|
5
|
+
port: number;
|
|
6
|
+
};
|
|
7
|
+
timeout?: number;
|
|
8
|
+
}
|
|
9
|
+
interface DirectLinkParams {
|
|
10
|
+
url: string;
|
|
11
|
+
cwd?: string;
|
|
12
|
+
}
|
|
13
|
+
interface DownloadParams {
|
|
14
|
+
url: string;
|
|
15
|
+
path: string;
|
|
16
|
+
cwd?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare function defineConfig(options: DirpyOptions): DirpyOptions;
|
|
20
|
+
|
|
21
|
+
export { type DirectLinkParams as D, type DirpyOptions as a, type DownloadParams 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-BzOW2OFi.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { D as DirpyOptions } from './config-
|
|
2
|
-
export { d as defineConfig } from './config-
|
|
1
|
+
import { D as DirectLinkParams, a as DirpyOptions, b as DownloadParams } from './config-BzOW2OFi.js';
|
|
2
|
+
export { d as defineConfig } from './config-BzOW2OFi.js';
|
|
3
3
|
|
|
4
|
-
declare function getDirectLink(
|
|
5
|
-
|
|
6
|
-
url: string;
|
|
7
|
-
path: string;
|
|
8
|
-
}
|
|
4
|
+
declare function getDirectLink(params: DirectLinkParams, options?: Partial<DirpyOptions>): Promise<string>;
|
|
5
|
+
declare function downloadVideo(params: DownloadParams, options?: Partial<DirpyOptions>): Promise<void>;
|
|
9
6
|
declare function downloadVideoFromRawLink(params: DownloadParams, options?: Partial<DirpyOptions>): Promise<void>;
|
|
10
7
|
|
|
11
|
-
|
|
8
|
+
declare function getBilibiliDirectLink(link: string): string;
|
|
9
|
+
declare function downloadBilibiliVideo(params: DownloadParams): Promise<void>;
|
|
10
|
+
|
|
11
|
+
export { DirectLinkParams, DirpyOptions, DownloadParams, downloadBilibiliVideo, downloadVideo, downloadVideoFromRawLink, getBilibiliDirectLink, getDirectLink };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as r,b as e}from"./chunk-
|
|
1
|
+
import{a as r,b as e,c as f,d as m,e as p}from"./chunk-MLOFRCSF.js";import{a as t}from"./chunk-OTOEWWYP.js";import{c as o}from"./chunk-LP3GSA6N.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
package/dist/chunk-WYAG3YFC.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as E,b as x,c as s}from"./chunk-LP3GSA6N.js";var j=E((J,h)=>{"use strict";s();var T=function(r){return _(r)&&!I(r)};function _(e){return!!e&&typeof e=="object"}function I(e){var r=Object.prototype.toString.call(e);return r==="[object RegExp]"||r==="[object Date]"||U(e)}var L=typeof Symbol=="function"&&Symbol.for,v=L?Symbol.for("react.element"):60103;function U(e){return e.$$typeof===v}function R(e){return Array.isArray(e)?[]:{}}function l(e,r){return r.clone!==!1&&r.isMergeableObject(e)?a(R(e),e,r):e}function C(e,r,t){return e.concat(r).map(function(o){return l(o,t)})}function $(e,r){if(!r.customMerge)return a;var t=r.customMerge(e);return typeof t=="function"?t:a}function F(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(r){return Object.propertyIsEnumerable.call(e,r)}):[]}function b(e){return Object.keys(e).concat(F(e))}function M(e,r){try{return r in e}catch{return!1}}function K(e,r){return M(e,r)&&!(Object.hasOwnProperty.call(e,r)&&Object.propertyIsEnumerable.call(e,r))}function N(e,r,t){var o={};return t.isMergeableObject(e)&&b(e).forEach(function(n){o[n]=l(e[n],t)}),b(r).forEach(function(n){K(e,n)||(M(e,n)&&t.isMergeableObject(r[n])?o[n]=$(n,t)(e[n],r[n],t):o[n]=l(r[n],t))}),o}function a(e,r,t){t=t||{},t.arrayMerge=t.arrayMerge||C,t.isMergeableObject=t.isMergeableObject||T,t.cloneUnlessOtherwiseSpecified=l;var o=Array.isArray(r),n=Array.isArray(e),c=o===n;return c?o?t.arrayMerge(e,r,t):N(e,r,t):l(r,t)}a.all=function(r,t){if(!Array.isArray(r))throw new Error("first argument should be an array");return r.reduce(function(o,n){return a(o,n,t)},{})};var G=a;h.exports=G});s();import V from"node:fs";import P from"axios";import W from"jsdom";s();var u=x(j(),1);import{createConfigLoader as H}from"unconfig";var f={timeout:2e4};async function g(e){let r=f,t=H({sources:[{files:["fast-dirpy.config"],extensions:["ts","mts","cts","js","mjs","cjs"]}],cwd:process.cwd(),merge:!1}),{config:o,sources:n}=await t.load();return n.length?(0,u.default)((0,u.default)(r,o),e):(0,u.default)(r,e)}var Y={"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:z}=W;async function X(e,r=f){let{proxy:t,timeout:o}=await g(r),n=t?.host!==""?t:void 0,{data:c}=await P.get("https://dirpy.com/studio",{params:{url:e},headers:{...Y,Referer:`https://dirpy.com/studio?url=${e}`},proxy:n,timeout:o}),{window:p}=new z(c),i="",m=p.document.getElementById("media-source");return m&&(i=m.src),i}async function B(e,r=f){let{path:t,url:o}=e,{proxy:n,timeout:c}=await g(r),p=n?.host!==""?n:void 0;if(o==="")return Promise.reject("Extract direct link failed!");let i=V.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:p,timeout:c,onDownloadProgress:d=>{let{loaded:y,total:D,progress:A}=d,S=`loaded:${y} total: ${D} progress: ${(A*100).toFixed(2)}%
|
|
2
|
-
`;console.log(S)}})).data.pipe(i),new Promise((d,y)=>{i.on("finish",d),i.on("error",y)})}async function oe(e,r=f){let{path:t,url:o}=e,n=await X(o,r);await B({url:n,path:t},r)}export{X as a,oe as b};
|