fast-dirpy 0.1.5 → 0.1.7

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
@@ -4,6 +4,7 @@
4
4
  </div>
5
5
 
6
6
  [![npm version][npm-version-src]][npm-version-href]
7
+ [![JSR][jsr-badge]](https://jsr.io/@vince-g/fast-dirpy)
7
8
  [![npm downloads][npm-downloads-src]][npm-downloads-href]
8
9
  [![JSDocs][jsdocs-src]][jsdocs-href]
9
10
  [![License][license-src]][license-href]
@@ -15,11 +16,20 @@ A simple library/CLI to download youtube(etc.) videos.
15
16
  - [YouTube](https://www.youtube.com/)
16
17
  - [Bilibili](https://www.bilibili.com/)
17
18
 
19
+ <details>
20
+ <summary>「Mystic」Websites</summary>
21
+
22
+ - Animeidhentai (Google Chrome required)
23
+ </details>
24
+
18
25
  ## Installation
19
26
 
20
27
  ### As a library
21
28
  ```shell
22
29
  npm i fast-dirpy
30
+
31
+ # deno
32
+ deno add jsr:@vince-g/fast-dirpy
23
33
  ```
24
34
 
25
35
  ### As a **command line tool**
@@ -46,11 +56,19 @@ export default defineConfig({
46
56
  port: 7890,
47
57
  },
48
58
  timeout: 20000, // request timeout: 20s
49
- })
59
+ puppeteer: {
60
+ // Path to Chrome. Please notice that you must give the inner unix executable file path in macOS.
61
+ // /Applications/Google Chrome.app will not work.
62
+ executablePath: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
63
+ headless: false
64
+ }
65
+ }
50
66
  ```
51
67
 
52
68
  ### Use in command line
53
69
 
70
+ > Some website listed in [Supported Websites](#supported-websites) requires Google Chrome installed for Puppeteer use. You have to use a config file or give parameter of puppeteer executable path.
71
+
54
72
  #### Get Direct Link
55
73
 
56
74
  ```shell
@@ -58,22 +76,26 @@ export default defineConfig({
58
76
  # Proxy:
59
77
  # -H, --proxyHost: proxy host
60
78
  # -P, --proxyPort: proxy port
61
- # -c, --config: Specified external config file.
79
+ # -c, --config: Specified external config file.
62
80
  # e.g.: fast-dirpy get https://xxx -c ~/Downloads/fast-dirpy.config.json
63
- fast-dirpy get https\://www.youtube.com/watch\?v\=SAXpBgkXt60 -H 127.0.0.1 -P 7890
81
+ # --chromePath: Path to your Google Chrome browser.
82
+ fast-dirpy get https\://www.youtube.com/watch\?v\=6c28qWDMPBA -H 127.0.0.1 -P 7890
64
83
 
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
84
+ # Bilibili source doesn't need any proxy, so it's disabled by default.
85
+ fast-dirpy get https://www.bilibili.com/video/BV1TSPeeGE35
68
86
  ```
69
87
 
70
88
  if you have set your proxy config in `fast-dirpy.config.ts`, you can omit proxy parameters:
71
89
 
72
90
  ```shell
73
- fast-dirpy get https\://www.youtube.com/watch\?v\=SAXpBgkXt60
91
+ fast-dirpy get https\://www.youtube.com/watch\?v\=6c28qWDMPBA
74
92
  ```
75
93
 
76
94
  #### Download Video
95
+
96
+ > [!IMPORTANT]
97
+ > Some website listed in [Supported Websites](#supported-websites) requires Google Chrome installed for Puppeteer use. You have to use a config file or give parameter of puppeteer executable path.
98
+
77
99
  ```shell
78
100
  # get video direct link
79
101
  # Path: --path, -p: Downloaded video save path.
@@ -81,19 +103,19 @@ fast-dirpy get https\://www.youtube.com/watch\?v\=SAXpBgkXt60
81
103
  # Proxy:
82
104
  # -H, --proxyHost: proxy host.
83
105
  # -P, --proxyPort: proxy port.
84
- # -c, --config: Specified external config file.
106
+ # -c, --config: Specified external config file.
85
107
  # e.g.: fast-dirpy get https://xxx -c ~/Downloads/fast-dirpy.config.json
86
- fast-dirpy download https\://www.youtube.com/watch\?v\=SAXpBgkXt60 -p ./test.mp4 -H 127.0.0.1 -P 7890
108
+ # --chromePath: Path to your Google Chrome browser.
109
+ fast-dirpy download https\://www.youtube.com/watch\?v\=6c28qWDMPBA -p ./test.mp4 -H 127.0.0.1 -P 7890
87
110
 
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
111
+ # Bilibili source doesn't need any proxy, so it's disabled by default.
112
+ fast-dirpy download https://www.bilibili.com/video/BV1TSPeeGE35 -p ./test.mp4
91
113
  ```
92
114
 
93
115
  if you have set your proxy config in `fast-dirpy.config.ts`, you can omit proxy parameters:
94
116
 
95
117
  ```shell
96
- fast-dirpy download https\://www.youtube.com/watch\?v\=SAXpBgkXt60 -p ./test.mp4
118
+ fast-dirpy download https\://www.youtube.com/watch\?v\=6c28qWDMPBA -p ./test.mp4
97
119
  ```
98
120
 
99
121
  For further CLI help:
@@ -103,11 +125,15 @@ fast-dirpy --help
103
125
  ```
104
126
 
105
127
  ### Use as a library
128
+
129
+ > [!IMPORTANT]
130
+ > If a website is listed in [Supported Websites](#supported-websites), then `getXXXLink` is to get direct link and `downloadXXX` is to download video.
131
+
106
132
  ```ts
107
- import { downloadVideoFromRawLink, getDirectLink, getBilibiliLink } from 'fast-dirpy'
133
+ import { downloadDirpy, getBilibiliLink, getDirpyLink } from 'fast-dirpy'
108
134
 
109
135
  // get direct link
110
- const link = await getDirectLink(
136
+ const link = await getDirpyLink(
111
137
  {
112
138
  url: '<url>',
113
139
  cwd: '/path/to/external-config' // Optional: You can specify an external config file.
@@ -124,7 +150,7 @@ const link = await getBilibiliLink(
124
150
  )
125
151
 
126
152
  // download video
127
- await downloadVideoFromRawLink({
153
+ await downloadDirpy({
128
154
  url: '<url>',
129
155
  path: './download.mp4',
130
156
  cwd: '/path/to/external-config', // Optional: You can specify an external config file.
@@ -135,7 +161,7 @@ await downloadVideoFromRawLink({
135
161
  })
136
162
 
137
163
  // download bilibili video
138
- await downloadBilibiliVideo({
164
+ await downloadBilibili({
139
165
  url: '<url>',
140
166
  path: './myvideo.mp4'
141
167
  })
@@ -155,3 +181,4 @@ await downloadBilibiliVideo({
155
181
  [license-href]: https://github.com/Vincent-the-gamer/fast-dirpy/blob/main/LICENSE
156
182
  [jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-080f12?style=flat&colorA=080f12&colorB=1fa669
157
183
  [jsdocs-href]: https://www.jsdocs.io/package/fast-dirpy
184
+ [jsr-badge]: https://jsr.io/badges/@vince-g/fast-dirpy
@@ -0,0 +1 @@
1
+ import{c as i}from"./chunk-HD53P4DN.js";i();function o(p){return p}export{o as a};
@@ -0,0 +1 @@
1
+ import{a as T,b as C,c as i}from"./chunk-HD53P4DN.js";var E=T((Pr,L)=>{"use strict";i();var F=function(e){return N(e)&&!U(e)};function N(r){return!!r&&typeof r=="object"}function U(r){var e=Object.prototype.toString.call(r);return e==="[object RegExp]"||e==="[object Date]"||z(r)}var V=typeof Symbol=="function"&&Symbol.for,W=V?Symbol.for("react.element"):60103;function z(r){return r.$$typeof===W}function K(r){return Array.isArray(r)?[]:{}}function x(r,e){return e.clone!==!1&&e.isMergeableObject(r)?b(K(r),r,e):r}function B(r,e,t){return r.concat(e).map(function(n){return x(n,t)})}function G(r,e){if(!e.customMerge)return b;var t=e.customMerge(r);return typeof t=="function"?t:b}function H(r){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(r).filter(function(e){return Object.propertyIsEnumerable.call(r,e)}):[]}function v(r){return Object.keys(r).concat(H(r))}function S(r,e){try{return e in r}catch{return!1}}function Y(r,e){return S(r,e)&&!(Object.hasOwnProperty.call(r,e)&&Object.propertyIsEnumerable.call(r,e))}function X(r,e,t){var n={};return t.isMergeableObject(r)&&v(r).forEach(function(o){n[o]=x(r[o],t)}),v(e).forEach(function(o){Y(r,o)||(S(r,o)&&t.isMergeableObject(e[o])?n[o]=G(o,t)(r[o],e[o],t):n[o]=x(e[o],t))}),n}function b(r,e,t){t=t||{},t.arrayMerge=t.arrayMerge||B,t.isMergeableObject=t.isMergeableObject||F,t.cloneUnlessOtherwiseSpecified=x;var n=Array.isArray(e),o=Array.isArray(r),a=n===o;return a?n?t.arrayMerge(r,e,t):X(r,e,t):x(e,t)}b.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(n,o){return b(n,o,t)},{})};var J=b;L.exports=J});i();import R from"node:process";import{consola as $}from"consola";var P=$.withTag("fast-dirpy");function yr(r){"CONSOLA_LEVEL"in R.env||(P.level=r?0:3)}i();import sr from"axios";import cr from"jsdom";i();import nr from"node:fs";import ir from"axios";i();var l={timeout:2e4};i();var D=C(E(),1);import{createConfigLoader as q}from"unconfig";async function y(r,e){let t=l,n=q({sources:[{files:["fast-dirpy.config"],extensions:["ts","mts","cts","js","mjs","cjs","json"]}],cwd:e||process.cwd(),merge:!1}),{config:o,sources:a}=await n.load();return a.length?(P.info(`Config file found: ${a[0]}`),(0,D.default)((0,D.default)(t,o),r)):(0,D.default)(t,r)}i();i();function I(r){let e=Math.floor(Math.random()*r.length);return r[e]}var Z=["Mozilla/5.0 (X11; U; Linux x86_64; zh-CN; rv:1.9.2.10) Gecko/20100922 Ubuntu/10.10 (maverick) Firefox/3.6.10","Mozilla/5.0 (Windows NT 6.1; rv,2.0.1) Gecko/20100101 Firefox/4.0.1","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","Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36","Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Ubuntu/11.10 Chromium/27.0.1453.93 Chrome/27.0.1453.93 Safari/537.36"];function w(){return I(Z)}i();function Q(r){let e=r.match(/BV[a-zA-Z0-9]+/);return e?`https://bilibili-real-url.deno.dev/${e[0]}.mp4`:""}async function kr(r){let{path:e,url:t}=r,n=Q(t);n!==""?await O({url:n,path:e||"./download.mp4"}):console.error("Extract direct link failed!")}i();import rr from"axios";import er from"jsdom";var{JSDOM:tr}=er;async function or(r,e=l){let{url:t,cwd:n}=r,{proxy:o,timeout:a}=await y(e,n),u=o?.host!==""?o:void 0,{data:f}=await rr.get("https://dirpy.com/studio",{params:{url:t},headers:{"User-Agent":w(),Referer:`https://dirpy.com/studio?url=${t}`},proxy:u,timeout:a}),{window:g}=new tr(f),c="",s=g.document.getElementById("media-source");return s&&(c=s.src),c}async function Wr(r,e=l){let{path:t,url:n,cwd:o}=r,a=await or({url:n},e);await O({url:a,path:t,cwd:o},e)}async function O(r,e=l){let{path:t,url:n}=r,{proxy:o,timeout:a}=await y(e),u=o?.host!==""?o:void 0;if(n==="")return Promise.reject("Extract direct link failed!");let f=nr.createWriteStream(t);return(await ir({url:n,headers:{"User-Agent":w()},method:"GET",responseType:"stream",proxy:u,timeout:a,onDownloadProgress:c=>{let{loaded:s,total:h,progress:d}=c,A=`loaded:${s} total: ${h} progress: ${(d*100).toFixed(2)}%`;P.info(A)}})).data.pipe(f),new Promise((c,s)=>{f.on("finish",c),f.on("error",s)})}i();import ar from"puppeteer-core";async function _(r){return await ar.launch(r)}var{JSDOM:pr}=cr;async function mr(r,e=l){let{url:t,cwd:n}=r,{proxy:o,timeout:a}=await y(e,n),u=o?.host!==""?o:void 0,{data:f}=await sr.get(t,{headers:{"User-Agent":w()},proxy:u,timeout:a}),{window:g}=new pr(f),c="",s=g.document.querySelector("div.embed.rad2 > iframe");return s&&(c=s.src),c}async function lr(r,e=l){let{url:t,cwd:n}=r,{proxy:o,puppeteer:a}=await y(e,n),u=o?.host!==""?o:void 0,f=await mr({url:t},{proxy:u}),{executablePath:g,headless:c}=a,s=await _({executablePath:g,headless:c,args:[`--proxy-server=http://${u?.host}:${o?.port}`]}),h=w(),d=await s.newPage();await d.setUserAgent(h),await d.goto(f),await d.waitForSelector("div.play.p-pulse"),await d.click("div.play.p-pulse"),await d.waitForSelector("div.frame > iframe");let A=await d.$eval("div.frame > iframe",M=>M.src),j=await s.newPage();await j.goto(`${A}`),await j.waitForSelector("video.jw-video.jw-reset");let k=await j.$eval("video.jw-video.jw-reset",M=>M.src);return await s.close(),k}async function fe(r,e=l){let{path:t,url:n,cwd:o}=r,a=await lr({url:n},e);await O({url:a,path:t,cwd:o},e)}i();var fr=(o=>(o[o.Bilibili=0]="Bilibili",o[o.Dirpy=1]="Dirpy",o[o.AnimeIdHentai=2]="AnimeIdHentai",o[o.Others=3]="Others",o))(fr||{});export{P as a,yr as b,lr as c,fe as d,Q as e,kr as f,or as g,Wr as h,O as i,fr as j};
package/dist/cli.js CHANGED
@@ -1 +1 @@
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();
1
+ import{a as e,b as y,c as u,d as x,e as b,f as P,g as w,h as v}from"./chunk-WHX3I2BB.js";import{c as m}from"./chunk-HD53P4DN.js";m();import{bold as k,dim as H}from"ansis";import{cac as C}from"cac";import I from"restore-cursor";var h={name:"fast-dirpy",type:"module",version:"0.1.7",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","puppeteer-core":"^24.7.1","restore-cursor":"^5.1.0",unconfig:"^7.3.2"},devDependencies:{"@antfu/eslint-config":"^4.12.0","@types/node":"^22.14.1",deepmerge:"^4.3.1",eslint:"^9.25.1",taze:"^19.0.4",tsup:"^8.4.0",tsx:"^4.19.3",typescript:"^5.8.3",vitest:"^3.1.2"}};m();function g(i){let r=/BV[a-zA-Z0-9]+/;return i.includes("bilibili")||r.test(i)?0:i.includes("dirpy")?1:i.includes("animeidhentai")?2:3}var a=C("fast-dirpy"),{version:A}=h;a.command("get <url>","get video direct link.").option("--proxyHost, -H <proxyHost>","Proxy host.").option("--proxyPort, -P <proxyPort>","Proxy port.").option("--config, -c <path>","Specify an external config file.").option("--silent","Suppress non-error logs").option("--chromePath","Path to your Google Chrome browser").action(async(i,r)=>{let o=g(i),{proxyHost:s,proxyPort:f,config:n,silent:d,chromePath:l}=r,p=s?{proxy:{host:s,port:f}}:void 0,c=l?{puppeteer:{executablePath:l}}:void 0;if(y(!!d),e.info(`fast-dirpy ${H(`v${A}`)} : ${k("Direct Link Getter")}.`),o===0){if(e.info("Matched link source: Bilibili."),!i.includes("bilibili.com")){e.error("Please provide a valid Bilibili URL.");return}let t=await b(i);console.log(t)}else if(o===1){e.info("Matched link source: Dirpy.");let t=await w({url:i,cwd:n},p);console.log(t)}else if(o===2){e.info("Matched link source: Animeidhentai.");let t=await u({url:i,cwd:n},{...p,...c});console.log(t)}else e.error("Your link is not supported!")});a.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("--config, -c <path>","Specify an external config file.").option("--silent","Suppress non-error logs").option("--chromePath","Path to your Google Chrome browser").action(async(i,r)=>{let o=g(i),{proxyHost:s,proxyPort:f,path:n,config:d,silent:l,chromePath:p}=r,c=s?{proxy:{host:s,port:f}}:void 0,t=p?{puppeteer:{executablePath:p}}:void 0;y(!!l),e.info(`fast-dirpy ${H(`v${A}`)} : ${k("Video Downloader")}.`),o===0?(e.info("Matched link source: Bilibili."),await P({url:i,path:n})):o===1?(e.info("Matched link source: Dirpy."),v({url:i,path:n||"./dirpy.mp4",cwd:d},c)):o===2&&(e.info("Matched link source: AnimeIdHentai."),await x({url:i,path:n||"./animeidhentai.mp4",cwd:d},{...c,...t}))});a.help();a.version(h.version);a.parse();I();
@@ -5,6 +5,10 @@ interface DirpyOptions {
5
5
  port: number;
6
6
  };
7
7
  timeout?: number;
8
+ puppeteer?: {
9
+ executablePath: string;
10
+ headless?: boolean;
11
+ };
8
12
  }
9
13
  interface DirectLinkParams {
10
14
  url: string;
@@ -15,7 +19,13 @@ interface DownloadParams {
15
19
  path: string;
16
20
  cwd?: string;
17
21
  }
22
+ declare enum UrlType {
23
+ Bilibili = 0,
24
+ Dirpy = 1,
25
+ AnimeIdHentai = 2,
26
+ Others = 3
27
+ }
18
28
 
19
29
  declare function defineConfig(options: DirpyOptions): DirpyOptions;
20
30
 
21
- export { type DirectLinkParams as D, type DirpyOptions as a, type DownloadParams as b, defineConfig as d };
31
+ export { type DirectLinkParams as D, UrlType as U, 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-BzOW2OFi.js';
1
+ export { d as defineConfig } from './config-0EeRO6Y-.js';
package/dist/config.js CHANGED
@@ -1 +1 @@
1
- import{a}from"./chunk-OTOEWWYP.js";import"./chunk-LP3GSA6N.js";export{a as defineConfig};
1
+ import{a}from"./chunk-OYM7YQEE.js";import"./chunk-HD53P4DN.js";export{a as defineConfig};
package/dist/index.d.ts CHANGED
@@ -1,11 +1,15 @@
1
- import { D as DirectLinkParams, a as DirpyOptions, b as DownloadParams } from './config-BzOW2OFi.js';
2
- export { d as defineConfig } from './config-BzOW2OFi.js';
1
+ import { D as DirectLinkParams, a as DirpyOptions, b as DownloadParams } from './config-0EeRO6Y-.js';
2
+ export { U as UrlType, d as defineConfig } from './config-0EeRO6Y-.js';
3
3
 
4
- declare function getDirectLink(params: DirectLinkParams, options?: Partial<DirpyOptions>): Promise<string>;
5
- declare function downloadVideo(params: DownloadParams, options?: Partial<DirpyOptions>): Promise<void>;
6
- declare function downloadVideoFromRawLink(params: DownloadParams, options?: Partial<DirpyOptions>): Promise<void>;
4
+ declare function getAnimeIdHentaiLink(params: DirectLinkParams, options?: Partial<DirpyOptions>): Promise<string>;
5
+ declare function downloadAnimeIdHentai(params: DownloadParams, options?: Partial<DirpyOptions>): Promise<void>;
6
+
7
+ declare function getBilibiliLink(link: string): string;
8
+ declare function downloadBilibili(params: DownloadParams): Promise<void>;
7
9
 
8
- declare function getBilibiliDirectLink(link: string): string;
9
- declare function downloadBilibiliVideo(params: DownloadParams): Promise<void>;
10
+ declare function getDirpyLink(params: DirectLinkParams, options?: Partial<DirpyOptions>): Promise<string>;
11
+ declare function downloadDirpy(params: DownloadParams, options?: Partial<DirpyOptions>): Promise<void>;
12
+
13
+ declare function downloadVideo(params: DownloadParams, options?: Partial<DirpyOptions>): Promise<void>;
10
14
 
11
- export { DirectLinkParams, DirpyOptions, DownloadParams, downloadBilibiliVideo, downloadVideo, downloadVideoFromRawLink, getBilibiliDirectLink, getDirectLink };
15
+ export { DirectLinkParams, DirpyOptions, DownloadParams, downloadAnimeIdHentai, downloadBilibili, downloadDirpy, downloadVideo, getAnimeIdHentaiLink, getBilibiliLink, getDirpyLink };
package/dist/index.js CHANGED
@@ -1 +1 @@
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};
1
+ import{c as r,d as e,e as f,f as m,g as p,h as t,i as x,j as a}from"./chunk-WHX3I2BB.js";import{a as b}from"./chunk-OYM7YQEE.js";import{c as o}from"./chunk-HD53P4DN.js";o();export{a as UrlType,b as defineConfig,e as downloadAnimeIdHentai,m as downloadBilibili,t as downloadDirpy,x as downloadVideo,r as getAnimeIdHentaiLink,f as getBilibiliLink,p as getDirpyLink};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "fast-dirpy",
3
3
  "type": "module",
4
- "version": "0.1.5",
4
+ "version": "0.1.7",
5
5
  "description": "A simple library/CLI to download video using dirpy.com",
6
6
  "author": "Vincent-the-gamer",
7
7
  "license": "MIT",
@@ -36,22 +36,25 @@
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
- "jsdom": "^26.0.0",
42
+ "consola": "^3.4.2",
43
+ "jsdom": "^26.1.0",
44
+ "puppeteer-core": "^24.7.1",
42
45
  "restore-cursor": "^5.1.0",
43
- "unconfig": "^7.3.1"
46
+ "unconfig": "^7.3.2"
44
47
  },
45
48
  "devDependencies": {
46
- "@antfu/eslint-config": "^4.11.0",
47
- "@types/node": "^22.13.17",
49
+ "@antfu/eslint-config": "^4.12.0",
50
+ "@types/node": "^22.14.1",
48
51
  "deepmerge": "^4.3.1",
49
- "eslint": "^9.23.0",
52
+ "eslint": "^9.25.1",
50
53
  "taze": "^19.0.4",
51
54
  "tsup": "^8.4.0",
52
55
  "tsx": "^4.19.3",
53
- "typescript": "^5.8.2",
54
- "vitest": "^3.1.1"
56
+ "typescript": "^5.8.3",
57
+ "vitest": "^3.1.2"
55
58
  },
56
59
  "scripts": {
57
60
  "tsx": "tsx",
@@ -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};
@@ -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