fast-dirpy 0.1.0 → 0.1.2

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 CHANGED
@@ -6,23 +6,42 @@
6
6
  [![JSDocs][jsdocs-src]][jsdocs-href]
7
7
  [![License][license-src]][license-href]
8
8
 
9
- A simple library/CLI to download video using `dirpy.com`
9
+ A simple library/CLI to download youtube(etc.) videos.
10
10
 
11
11
  ## Installation
12
12
 
13
- ## As a library
13
+ ### As a library
14
14
  ```shell
15
15
  npm i fast-dirpy
16
16
  ```
17
17
 
18
- ## As a **command line tool**
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
+
27
+ > [!IMPORTANT]
28
+ > `fast-dirpy.config` can be `fast-dirpy.config.['ts', 'mts', 'cts', 'js', 'mjs', 'cjs']`
29
+
30
+ You can create a `fast-dirpy.config.ts` file in your library root or same location in command line.
31
+
32
+ ```ts
33
+ import { defineConfig } from 'fast-dirpy'
34
+
35
+ export default defineConfig({
36
+ proxy: {
37
+ protocol: 'http',
38
+ host: '127.0.0.1',
39
+ port: 7890,
40
+ },
41
+ timeout: 20000, // request timeout: 20s
42
+ })
43
+ ```
44
+
26
45
  ### Use in command line
27
46
 
28
47
  #### Get Direct Link
@@ -32,13 +51,20 @@ npm i fast-dirpy -g
32
51
  # Proxy:
33
52
  # -H, --proxyHost: proxy host
34
53
  # -P, --proxyPort: proxy port
54
+
35
55
  fast-dirpy get https\://www.youtube.com/watch\?v\=SAXpBgkXt60 -H 127.0.0.1 -P 7890
36
56
  ```
37
57
 
58
+ if you have set your proxy config in `fast-dirpy.config.ts`, you can omit proxy parameters:
59
+
60
+ ```shell
61
+ fast-dirpy get https\://www.youtube.com/watch\?v\=SAXpBgkXt60
62
+ ```
63
+
38
64
  #### Download Video
39
65
  ```shell
40
66
  # get video direct link
41
- # Path: --path, -P: Downloaded video save path.
67
+ # Path: --path, -p: Downloaded video save path.
42
68
  #
43
69
  # Proxy:
44
70
  # -H, --proxyHost: proxy host.
@@ -46,27 +72,39 @@ fast-dirpy get https\://www.youtube.com/watch\?v\=SAXpBgkXt60 -H 127.0.0.1 -P 78
46
72
  fast-dirpy download https\://www.youtube.com/watch\?v\=SAXpBgkXt60 -p ./test.mp4 -H 127.0.0.1 -P 7890
47
73
  ```
48
74
 
75
+ if you have set your proxy config in `fast-dirpy.config.ts`, you can omit proxy parameters:
76
+
77
+ ```shell
78
+ fast-dirpy download https\://www.youtube.com/watch\?v\=SAXpBgkXt60 -p ./test.mp4
79
+ ```
80
+
81
+ For further CLI help:
82
+
83
+ ```shell
84
+ fast-dirpy --help
85
+ ```
86
+
49
87
  ### Use as a library
50
88
  ```ts
51
- import { getDirectLink, downloadVideoFromRawLink } from "fast-dirpy"
89
+ import { downloadVideoFromRawLink, getDirectLink } from 'fast-dirpy'
52
90
 
53
91
  // get direct link
54
92
  const link = await getDirectLink(
55
- "<url>",
56
- {
57
- host: "127.0.0.1",
58
- port: 7890
59
- }
93
+ '<url>',
94
+ {
95
+ host: '127.0.0.1',
96
+ port: 7890
97
+ }
60
98
  )
61
99
 
62
100
  // download video
63
- downloadVideoFromRawLink({
64
- url,
65
- path: "./download.mp4",
66
- proxy: {
67
- host: "127.0.0.1",
68
- port: 7890
69
- }
101
+ await downloadVideoFromRawLink({
102
+ url,
103
+ path: './download.mp4',
104
+ proxy: {
105
+ host: '127.0.0.1',
106
+ port: 7890
107
+ }
70
108
  })
71
109
  ```
72
110
 
package/bin/fast-dirpy.js CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict'
3
3
 
4
- import '../dist/cli.js'
4
+ import '../dist/cli.js'
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.2",
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
- "license": "MIT",
25
- "homepage": "https://github.com/Vincent-the-gamer/fast-dirpy#readme",
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
- "sideEffects": false,
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
- "taze": "^19.0.2",
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
  }
@@ -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};
package/dist/cli.d.ts DELETED
@@ -1,2 +0,0 @@
1
-
2
- export { }
package/dist/cli.js DELETED
@@ -1 +0,0 @@
1
- import{a as i,b as r}from"./chunk-KX4T6SEL.js";import{cac as a}from"cac";var p={name:"fast-dirpy",version:"0.1.0",type:"module",description:"A simple library/CLI to download video using dirpy.com",author:"Vincent-the-gamer",main:"dist/index.js",module:"dist/index.js",types:"dist/index.d.ts",files:["dist"],bin:{"fast-dirpy":"bin/fast-dirpy.js"},typesVersions:{"*":{".":["./dist/index.d.ts","./dist/cli.d.ts"]}},scripts:{tsx:"tsx",build:"tsup",test:"vitest",dep:"taze major",login:"pnpm login --registry https://registry.npmjs.com"},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"},publishConfig:{registry:"https://registry.npmjs.com",access:"public"},sideEffects:!1,devDependencies:{"@types/node":"^22.13.14",taze:"^19.0.2",tsup:"^8.4.0",tsx:"^4.19.3",typescript:"^5.8.2",vitest:"^3.0.9"},dependencies:{axios:"^1.8.4",cac:"^6.7.14",jsdom:"^26.0.0","restore-cursor":"^5.1.0"}};import c from"restore-cursor";var o=a("fast-dirpy");o.command("get <url>","get video direct link.").option("--proxyHost, -H <proxyHost>","Proxy host.").option("--proxyPort, -P <proxyPort>","Proxy port.").action(async(s,t)=>{let e=await i(s,{host:t.proxyHost||null,port:t.proxyPort||null});console.log(e)});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(s,t)=>{let e=t.proxyHost||null,n=t.proxyPort||null;r({url:s,path:t.path||"./download.mp4",proxy:{host:e,port:n}})});o.help();o.version(p.version);o.parse();c();
package/dist/index.d.ts DELETED
@@ -1,10 +0,0 @@
1
- declare function getDirectLink(url: string, proxy?: Record<string, any>): Promise<string>;
2
- interface DownloadParams {
3
- url: string;
4
- path: string;
5
- puppeteer?: boolean;
6
- proxy?: Record<string, any>;
7
- }
8
- declare function downloadVideoFromRawLink(params: DownloadParams): Promise<void>;
9
-
10
- export { downloadVideoFromRawLink, getDirectLink };
package/dist/index.js DELETED
@@ -1 +0,0 @@
1
- import{a as o,b as r}from"./chunk-KX4T6SEL.js";export{r as downloadVideoFromRawLink,o as getDirectLink};