fast-dirpy 0.1.6 → 0.1.8

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,20 @@ 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
+ > [!IMPORTANT]
71
+ > 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.
72
+
54
73
  #### Get Direct Link
55
74
 
56
75
  ```shell
@@ -60,11 +79,11 @@ export default defineConfig({
60
79
  # -P, --proxyPort: proxy port
61
80
  # -c, --config: Specified external config file.
62
81
  # e.g.: fast-dirpy get https://xxx -c ~/Downloads/fast-dirpy.config.json
82
+ # --chromePath: Path to your Google Chrome browser.
63
83
  fast-dirpy get https\://www.youtube.com/watch\?v\=6c28qWDMPBA -H 127.0.0.1 -P 7890
64
84
 
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
85
+ # Bilibili source doesn't need any proxy, so it's disabled by default.
86
+ fast-dirpy get https://www.bilibili.com/video/BV1TSPeeGE35
68
87
  ```
69
88
 
70
89
  if you have set your proxy config in `fast-dirpy.config.ts`, you can omit proxy parameters:
@@ -74,6 +93,10 @@ fast-dirpy get https\://www.youtube.com/watch\?v\=6c28qWDMPBA
74
93
  ```
75
94
 
76
95
  #### Download Video
96
+
97
+ > [!IMPORTANT]
98
+ > 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.
99
+
77
100
  ```shell
78
101
  # get video direct link
79
102
  # Path: --path, -p: Downloaded video save path.
@@ -83,11 +106,11 @@ fast-dirpy get https\://www.youtube.com/watch\?v\=6c28qWDMPBA
83
106
  # -P, --proxyPort: proxy port.
84
107
  # -c, --config: Specified external config file.
85
108
  # e.g.: fast-dirpy get https://xxx -c ~/Downloads/fast-dirpy.config.json
109
+ # --chromePath: Path to your Google Chrome browser.
86
110
  fast-dirpy download https\://www.youtube.com/watch\?v\=6c28qWDMPBA -p ./test.mp4 -H 127.0.0.1 -P 7890
87
111
 
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
112
+ # Bilibili source doesn't need any proxy, so it's disabled by default.
113
+ fast-dirpy download https://www.bilibili.com/video/BV1TSPeeGE35 -p ./test.mp4
91
114
  ```
92
115
 
93
116
  if you have set your proxy config in `fast-dirpy.config.ts`, you can omit proxy parameters:
@@ -103,11 +126,15 @@ fast-dirpy --help
103
126
  ```
104
127
 
105
128
  ### Use as a library
129
+
130
+ > [!IMPORTANT]
131
+ > If a website is listed in [Supported Websites](#supported-websites), then `getXXXLink` is to get direct link and `downloadXXX` is to download video.
132
+
106
133
  ```ts
107
- import { downloadVideoFromRawLink, getBilibiliLink, getDirectLink } from 'fast-dirpy'
134
+ import { downloadDirpy, getBilibiliLink, getDirpyLink } from 'fast-dirpy'
108
135
 
109
136
  // get direct link
110
- const link = await getDirectLink(
137
+ const link = await getDirpyLink(
111
138
  {
112
139
  url: '<url>',
113
140
  cwd: '/path/to/external-config' // Optional: You can specify an external config file.
@@ -124,7 +151,7 @@ const link = await getBilibiliLink(
124
151
  )
125
152
 
126
153
  // download video
127
- await downloadVideoFromRawLink({
154
+ await downloadDirpy({
128
155
  url: '<url>',
129
156
  path: './download.mp4',
130
157
  cwd: '/path/to/external-config', // Optional: You can specify an external config file.
@@ -135,7 +162,7 @@ await downloadVideoFromRawLink({
135
162
  })
136
163
 
137
164
  // download bilibili video
138
- await downloadBilibiliVideo({
165
+ await downloadBilibili({
139
166
  url: '<url>',
140
167
  path: './myvideo.mp4'
141
168
  })
@@ -155,3 +182,4 @@ await downloadBilibiliVideo({
155
182
  [license-href]: https://github.com/Vincent-the-gamer/fast-dirpy/blob/main/LICENSE
156
183
  [jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-080f12?style=flat&colorA=080f12&colorB=1fa669
157
184
  [jsdocs-href]: https://www.jsdocs.io/package/fast-dirpy
185
+ [jsr-badge]: https://jsr.io/badges/@vince-g/fast-dirpy
@@ -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();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();import Z from"puppeteer-core";async function I(r){return await Z.launch(r)}i();i();function _(r){let e=Math.floor(Math.random()*r.length);return r[e]}var Q=["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 _(Q)}i();import ir from"node:fs";import ar from"axios";i();function rr(r){let e=r.match(/BV[a-zA-Z0-9]+/);return e?`https://bilibili-real-url.deno.dev/${e[0]}.mp4`:""}async function Rr(r){let{path:e,url:t}=r,n=rr(t);n!==""?await O({url:n,path:e||"./download.mp4"}):console.error("Extract direct link failed!")}i();import er from"axios";import tr from"jsdom";var{JSDOM:or}=tr;async function nr(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 er.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 or(f),c="",s=g.document.getElementById("media-source");return s&&(c=s.src),c}async function Br(r,e=l){let{path:t,url:n,cwd:o}=r,a=await nr({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=ir.createWriteStream(t);return(await ar({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)})}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 I({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,rr as e,Rr as f,nr as g,Br as h,O as i,fr as j};
package/dist/cli.js CHANGED
@@ -1 +1 @@
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();
1
+ import{a as e,b as y,c as g,d as x,e as b,f as P,g as w,h as k}from"./chunk-RM2BKSBF.js";import{c as m}from"./chunk-HD53P4DN.js";m();import{bold as v,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.8",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 u(i){let r=/BV[a-zA-Z0-9]+/;return i.includes("bilibili")||r.test(i)?0:i.includes("animeidhentai")?2:1}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=u(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}`)} : ${v("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 g({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=u(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}`)} : ${v("Video Downloader")}.`),o===0?(e.info("Matched link source: Bilibili."),await P({url:i,path:n})):o===1?(e.info("Matched link source: Dirpy."),k({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})):e.error("Your link is not supported!")});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 DownloadParams as D, type DirectLinkParams as a, type DirpyOptions 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-DKxT5hQw.js';
1
+ export { d as defineConfig } from './config-0EeRO6Y-.js';
package/dist/index.d.ts CHANGED
@@ -1,11 +1,15 @@
1
- import { D as DownloadParams, a as DirectLinkParams, b as DirpyOptions } from './config-DKxT5hQw.js';
2
- export { d as defineConfig } from './config-DKxT5hQw.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 getBilibiliDirectLink(link: string): string;
5
- declare function downloadBilibiliVideo(params: DownloadParams): 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>;
9
+
10
+ declare function getDirpyLink(params: DirectLinkParams, options?: Partial<DirpyOptions>): Promise<string>;
11
+ declare function downloadDirpy(params: DownloadParams, options?: Partial<DirpyOptions>): Promise<void>;
6
12
 
7
- declare function getDirectLink(params: DirectLinkParams, options?: Partial<DirpyOptions>): Promise<string>;
8
13
  declare function downloadVideo(params: DownloadParams, options?: Partial<DirpyOptions>): Promise<void>;
9
- declare function downloadVideoFromRawLink(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{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};
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-RM2BKSBF.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.6",
4
+ "version": "0.1.8",
5
5
  "description": "A simple library/CLI to download video using dirpy.com",
6
6
  "author": "Vincent-the-gamer",
7
7
  "license": "MIT",
@@ -41,19 +41,20 @@
41
41
  "cac": "^6.7.14",
42
42
  "consola": "^3.4.2",
43
43
  "jsdom": "^26.1.0",
44
+ "puppeteer-core": "^24.7.1",
44
45
  "restore-cursor": "^5.1.0",
45
- "unconfig": "^7.3.1"
46
+ "unconfig": "^7.3.2"
46
47
  },
47
48
  "devDependencies": {
48
49
  "@antfu/eslint-config": "^4.12.0",
49
50
  "@types/node": "^22.14.1",
50
51
  "deepmerge": "^4.3.1",
51
- "eslint": "^9.25.0",
52
+ "eslint": "^9.25.1",
52
53
  "taze": "^19.0.4",
53
54
  "tsup": "^8.4.0",
54
55
  "tsx": "^4.19.3",
55
56
  "typescript": "^5.8.3",
56
- "vitest": "^3.1.1"
57
+ "vitest": "^3.1.2"
57
58
  },
58
59
  "scripts": {
59
60
  "tsx": "tsx",
@@ -1,2 +0,0 @@
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};