fast-dirpy 0.1.0 → 0.1.1
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 +52 -18
- package/bin/fast-dirpy.js +1 -1
- package/dist/chunk-LP3GSA6N.js +1 -0
- package/dist/chunk-OTOEWWYP.js +1 -0
- package/dist/chunk-WYAG3YFC.js +2 -0
- package/dist/cli.js +1 -1
- package/dist/config-CsHryMou.d.ts +12 -0
- package/dist/config.d.ts +1 -0
- package/dist/config.js +1 -0
- package/dist/index.d.ts +6 -5
- package/dist/index.js +1 -1
- package/package.json +28 -23
- package/dist/chunk-KX4T6SEL.js +0 -2
package/README.md
CHANGED
|
@@ -6,23 +6,38 @@
|
|
|
6
6
|
[![JSDocs][jsdocs-src]][jsdocs-href]
|
|
7
7
|
[![License][license-src]][license-href]
|
|
8
8
|
|
|
9
|
-
A simple library/CLI to download
|
|
9
|
+
A simple library/CLI to download youtube(etc.) videos.
|
|
10
10
|
|
|
11
11
|
## Installation
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
### As a library
|
|
14
14
|
```shell
|
|
15
15
|
npm i fast-dirpy
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
### As a **command line tool**
|
|
19
19
|
```shell
|
|
20
20
|
npm i fast-dirpy -g
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
|
|
24
23
|
## Usage
|
|
25
24
|
|
|
25
|
+
### Config file
|
|
26
|
+
You can create a `fast-dirpy.config.ts` file in your library root or same location in command line.
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { defineConfig } from 'fast-dirpy'
|
|
30
|
+
|
|
31
|
+
export default defineConfig({
|
|
32
|
+
proxy: {
|
|
33
|
+
protocol: 'http',
|
|
34
|
+
host: '127.0.0.1',
|
|
35
|
+
port: 7890,
|
|
36
|
+
},
|
|
37
|
+
timeout: 20000, // request timeout: 20s
|
|
38
|
+
})
|
|
39
|
+
```
|
|
40
|
+
|
|
26
41
|
### Use in command line
|
|
27
42
|
|
|
28
43
|
#### Get Direct Link
|
|
@@ -32,13 +47,20 @@ npm i fast-dirpy -g
|
|
|
32
47
|
# Proxy:
|
|
33
48
|
# -H, --proxyHost: proxy host
|
|
34
49
|
# -P, --proxyPort: proxy port
|
|
50
|
+
|
|
35
51
|
fast-dirpy get https\://www.youtube.com/watch\?v\=SAXpBgkXt60 -H 127.0.0.1 -P 7890
|
|
36
52
|
```
|
|
37
53
|
|
|
54
|
+
if you have set your proxy config in `fast-dirpy.config.ts`, you can omit proxy parameters:
|
|
55
|
+
|
|
56
|
+
```shell
|
|
57
|
+
fast-dirpy get https\://www.youtube.com/watch\?v\=SAXpBgkXt60
|
|
58
|
+
```
|
|
59
|
+
|
|
38
60
|
#### Download Video
|
|
39
61
|
```shell
|
|
40
62
|
# get video direct link
|
|
41
|
-
# Path: --path, -
|
|
63
|
+
# Path: --path, -p: Downloaded video save path.
|
|
42
64
|
#
|
|
43
65
|
# Proxy:
|
|
44
66
|
# -H, --proxyHost: proxy host.
|
|
@@ -46,27 +68,39 @@ fast-dirpy get https\://www.youtube.com/watch\?v\=SAXpBgkXt60 -H 127.0.0.1 -P 78
|
|
|
46
68
|
fast-dirpy download https\://www.youtube.com/watch\?v\=SAXpBgkXt60 -p ./test.mp4 -H 127.0.0.1 -P 7890
|
|
47
69
|
```
|
|
48
70
|
|
|
71
|
+
if you have set your proxy config in `fast-dirpy.config.ts`, you can omit proxy parameters:
|
|
72
|
+
|
|
73
|
+
```shell
|
|
74
|
+
fast-dirpy download https\://www.youtube.com/watch\?v\=SAXpBgkXt60 -p ./test.mp4
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
For further CLI help:
|
|
78
|
+
|
|
79
|
+
```shell
|
|
80
|
+
fast-dirpy --help
|
|
81
|
+
```
|
|
82
|
+
|
|
49
83
|
### Use as a library
|
|
50
84
|
```ts
|
|
51
|
-
import {
|
|
85
|
+
import { downloadVideoFromRawLink, getDirectLink } from 'fast-dirpy'
|
|
52
86
|
|
|
53
87
|
// get direct link
|
|
54
88
|
const link = await getDirectLink(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
89
|
+
'<url>',
|
|
90
|
+
{
|
|
91
|
+
host: '127.0.0.1',
|
|
92
|
+
port: 7890
|
|
93
|
+
}
|
|
60
94
|
)
|
|
61
95
|
|
|
62
96
|
// download video
|
|
63
|
-
downloadVideoFromRawLink({
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
97
|
+
await downloadVideoFromRawLink({
|
|
98
|
+
url,
|
|
99
|
+
path: './download.mp4',
|
|
100
|
+
proxy: {
|
|
101
|
+
host: '127.0.0.1',
|
|
102
|
+
port: 7890
|
|
103
|
+
}
|
|
70
104
|
})
|
|
71
105
|
```
|
|
72
106
|
|
package/bin/fast-dirpy.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var n=Object.create;var i=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var c=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty;var l=(t,e)=>()=>(t&&(e=t(t=0)),e);var d=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var s=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let m of p(e))!f.call(t,m)&&m!==o&&i(t,m,{get:()=>e[m],enumerable:!(r=a(e,m))||r.enumerable});return t};var g=(t,e,o)=>(o=t!=null?n(c(t)):{},s(e||!t||!t.__esModule?i(o,"default",{value:t,enumerable:!0}):o,t));var _=l(()=>{"use strict"});export{d as a,g as b,_ as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as i}from"./chunk-LP3GSA6N.js";i();function o(p){return p}export{o as a};
|
|
@@ -0,0 +1,2 @@
|
|
|
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};
|
package/dist/cli.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as p,b as d}from"./chunk-WYAG3YFC.js";import{c as n}from"./chunk-LP3GSA6N.js";n();import{cac as y}from"cac";import l from"restore-cursor";var a={name:"fast-dirpy",type:"module",version:"0.1.1",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.14",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.0.9"}};var o=y("fast-dirpy");o.command("get <url>","get video direct link.").option("--proxyHost, -H <proxyHost>","Proxy host.").option("--proxyPort, -P <proxyPort>","Proxy port.").action(async(e,i)=>{let{host:t,port:s}=i,c=await p(e,t?{proxy:{host:t,port:s}}:void 0);console.log(c)});o.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.").action(async(e,i)=>{let{host:t,port:s}=i,r=t?{proxy:{host:t,port:s}}:void 0;d({url:e,path:i.path||"./download.mp4"},r)});o.help();o.version(a.version);o.parse();l();
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { d as defineConfig } from './config-CsHryMou.js';
|
package/dist/config.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./chunk-OTOEWWYP.js";import"./chunk-LP3GSA6N.js";export{a as defineConfig};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { D as DirpyOptions } from './config-CsHryMou.js';
|
|
2
|
+
export { d as defineConfig } from './config-CsHryMou.js';
|
|
3
|
+
|
|
4
|
+
declare function getDirectLink(url: string, options?: Partial<DirpyOptions>): Promise<string>;
|
|
2
5
|
interface DownloadParams {
|
|
3
6
|
url: string;
|
|
4
7
|
path: string;
|
|
5
|
-
puppeteer?: boolean;
|
|
6
|
-
proxy?: Record<string, any>;
|
|
7
8
|
}
|
|
8
|
-
declare function downloadVideoFromRawLink(params: DownloadParams): Promise<void>;
|
|
9
|
+
declare function downloadVideoFromRawLink(params: DownloadParams, options?: Partial<DirpyOptions>): Promise<void>;
|
|
9
10
|
|
|
10
|
-
export { downloadVideoFromRawLink, getDirectLink };
|
|
11
|
+
export { DirpyOptions, downloadVideoFromRawLink, getDirectLink };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as r,b as e}from"./chunk-WYAG3YFC.js";import{a as f}from"./chunk-OTOEWWYP.js";import{c as o}from"./chunk-LP3GSA6N.js";o();export{f as defineConfig,e as downloadVideoFromRawLink,r as getDirectLink};
|
package/package.json
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fast-dirpy",
|
|
3
|
-
"version": "0.1.0",
|
|
4
3
|
"type": "module",
|
|
4
|
+
"version": "0.1.1",
|
|
5
5
|
"description": "A simple library/CLI to download video using dirpy.com",
|
|
6
6
|
"author": "Vincent-the-gamer",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"homepage": "https://github.com/Vincent-the-gamer/fast-dirpy#readme",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/Vincent-the-gamer/fast-dirpy.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/Vincent-the-gamer/fast-dirpy/issues"
|
|
15
|
+
},
|
|
16
|
+
"sideEffects": false,
|
|
7
17
|
"main": "dist/index.js",
|
|
8
18
|
"module": "dist/index.js",
|
|
9
19
|
"types": "dist/index.d.ts",
|
|
10
|
-
"files": [
|
|
11
|
-
"dist"
|
|
12
|
-
],
|
|
13
|
-
"bin": {
|
|
14
|
-
"fast-dirpy": "bin/fast-dirpy.js"
|
|
15
|
-
},
|
|
16
20
|
"typesVersions": {
|
|
17
21
|
"*": {
|
|
18
22
|
".": [
|
|
@@ -21,39 +25,40 @@
|
|
|
21
25
|
]
|
|
22
26
|
}
|
|
23
27
|
},
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
"repository": {
|
|
27
|
-
"type": "git",
|
|
28
|
-
"url": "git+https://github.com/Vincent-the-gamer/fast-dirpy.git"
|
|
29
|
-
},
|
|
30
|
-
"bugs": {
|
|
31
|
-
"url": "https://github.com/Vincent-the-gamer/fast-dirpy/issues"
|
|
28
|
+
"bin": {
|
|
29
|
+
"fast-dirpy": "bin/fast-dirpy.js"
|
|
32
30
|
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist"
|
|
33
|
+
],
|
|
33
34
|
"publishConfig": {
|
|
34
35
|
"registry": "https://registry.npmjs.com",
|
|
35
36
|
"access": "public"
|
|
36
37
|
},
|
|
37
|
-
"
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"axios": "^1.8.4",
|
|
40
|
+
"cac": "^6.7.14",
|
|
41
|
+
"jsdom": "^26.0.0",
|
|
42
|
+
"restore-cursor": "^5.1.0",
|
|
43
|
+
"unconfig": "^7.3.1"
|
|
44
|
+
},
|
|
38
45
|
"devDependencies": {
|
|
46
|
+
"@antfu/eslint-config": "^4.11.0",
|
|
39
47
|
"@types/node": "^22.13.14",
|
|
40
|
-
"
|
|
48
|
+
"deepmerge": "^4.3.1",
|
|
49
|
+
"eslint": "^9.23.0",
|
|
50
|
+
"taze": "^19.0.4",
|
|
41
51
|
"tsup": "^8.4.0",
|
|
42
52
|
"tsx": "^4.19.3",
|
|
43
53
|
"typescript": "^5.8.2",
|
|
44
54
|
"vitest": "^3.0.9"
|
|
45
55
|
},
|
|
46
|
-
"dependencies": {
|
|
47
|
-
"axios": "^1.8.4",
|
|
48
|
-
"cac": "^6.7.14",
|
|
49
|
-
"jsdom": "^26.0.0",
|
|
50
|
-
"restore-cursor": "^5.1.0"
|
|
51
|
-
},
|
|
52
56
|
"scripts": {
|
|
53
57
|
"tsx": "tsx",
|
|
54
58
|
"build": "tsup",
|
|
55
59
|
"test": "vitest",
|
|
56
60
|
"dep": "taze major",
|
|
61
|
+
"lint:fix": "eslint . --fix",
|
|
57
62
|
"login": "pnpm login --registry https://registry.npmjs.com"
|
|
58
63
|
}
|
|
59
64
|
}
|
package/dist/chunk-KX4T6SEL.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import p from"axios";import f from"jsdom";import y from"fs";function c(o){return o?.host&&o.port?{protocol:"http",host:o?.host,port:o?.port}:void 0}var{JSDOM:w}=f;async function h(o,r){let t=c(r||{}),{data:n}=await p.get("https://dirpy.com/studio",{params:{url:encodeURIComponent(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"},proxy:t,timeout:3e4}),{window:e}=new w(n),{src:s}=e.document.getElementById("media-source");return s}async function x(o){let{proxy:r,path:t,url:n}=o,e=c(r||{}),s=y.createWriteStream(t);return(await p({url:n,method:"GET",responseType:"stream",proxy:e,onDownloadProgress:i=>{let{loaded:a,total:d,progress:m}=i,l=`loaded:${a} total: ${d} progress: ${(m*100).toFixed(2)}%
|
|
2
|
-
`;console.log(l)}})).data.pipe(s),new Promise((i,a)=>{s.on("finish",i),s.on("error",a)})}async function S(o){let{proxy:r,path:t,url:n}=o,e=await h(n,r);await x({url:e,path:t,proxy:r})}export{h as a,S as b};
|