fast-dirpy 0.3.1 → 0.3.3

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
@@ -18,18 +18,17 @@ A simple library/CLI to download youtube(etc.) videos.
18
18
 
19
19
  <details>
20
20
  <summary>NSFW</summary>
21
-
21
+
22
22
  * [Animehentai](https://animeidhentai.com/)
23
23
  * [Koreanpornmovies](https://koreanpornmovie.com/)
24
24
  * [XVideos](https://www.xvideos.com/)
25
25
  * [Missav](https://missav.ws/) (m3u8)
26
26
  </details>
27
27
 
28
-
29
28
  And `.m3u8` videos.
30
29
 
31
30
  > [!IMPORTANT]
32
- > From v0.2.1, .m3u8 downloader is no longer using ffmpeg.
31
+ > From v0.3.0, .m3u8 downloader is no longer using ffmpeg.
33
32
  > And it doesn't provide proxy settings, so, you need to use `export https_proxy=http://ip:port` to set proxy manually in terminal.
34
33
 
35
34
  You can use this [userscript](https://greasyfork.org/zh-CN/scripts/449581-m3u8%E8%A7%86%E9%A2%91%E4%BE%A6%E6%B5%8B%E4%B8%8B%E8%BD%BD%E5%99%A8-%E8%87%AA%E5%8A%A8%E5%97%85%E6%8E%A2) to extract `.m3u8` sources from websites.
@@ -131,6 +130,9 @@ fast-dirpy download https\://www.bilibili.com/video/BV1TSPeeGE35 -p ./test.mp4
131
130
 
132
131
  # m3u8 sources
133
132
  fast-dirpy download https\://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8 -p ./test.mp4
133
+
134
+ # mp4 sources
135
+ fast-dirpy download http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4 -p ./big_buck_bunny.mp4
134
136
  ```
135
137
 
136
138
  if you have set your proxy config in `fast-dirpy.config.ts`, you can omit proxy parameters:
@@ -146,51 +148,42 @@ fast-dirpy --help
146
148
  ```
147
149
 
148
150
  ### Use as a library
149
-
150
- > [!IMPORTANT]
151
- > If a website is listed in [Supported Websites](#supported-websites), then `getXXXLink` is to get direct link and `downloadXXX` is to download video.
152
-
153
151
  ```ts
154
- import { downloadDirpy, getBilibiliLink, getDirpyLink, remoteM3U8ToMP4 } from 'fast-dirpy'
152
+ import { fastLink, fastDownload } from 'fast-dirpy'
155
153
 
156
154
  // get direct link
157
- const link = await getDirpyLink(
155
+ const link = await fastLink(
158
156
  {
159
157
  url: '<url>',
160
158
  cwd: '/path/to/external-config' // Optional: You can specify an external config file.
161
159
  },
160
+ // options (Optional, can be omitted if you have a config file, this will overwrites your config file options.)
162
161
  {
163
- host: '127.0.0.1',
164
- port: 7890
162
+ proxy: { ... }
165
163
  }
166
164
  )
167
165
 
168
- // get bilibili direct link
169
- const link = await getBilibiliLink(
170
- '<url>',
171
- )
172
-
173
166
  // download video
174
- await downloadDirpy({
167
+ await fastDownload({
175
168
  url: '<url>',
176
169
  path: './download.mp4',
177
170
  cwd: '/path/to/external-config', // Optional: You can specify an external config file.
178
- proxy: {
179
- host: '127.0.0.1',
180
- port: 7890
181
- }
171
+ },
172
+ // options (Optional, can be omitted if you have a config file, this will overwrites your config file options.)
173
+ {
174
+ proxy: { ... }
182
175
  })
183
176
 
184
- // download bilibili video
185
- await downloadBilibili({
186
- url: '<url>',
187
- path: './myvideo.mp4'
177
+ // Download `.m3u8` video
178
+ await remoteM3U8ToMP4({
179
+ url: 'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8',
180
+ path: './test.mp4',
188
181
  })
189
182
 
190
- // download `.m3u8` video
191
- await remoteM3U8ToMP4({
192
- input: 'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8',
193
- output: './test.mp4',
183
+ // Download `.mp4` video
184
+ await downloadVideo({
185
+ url: 'http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4',
186
+ path: "./big_buck_bunny.mp4"
194
187
  })
195
188
  ```
196
189
 
package/dist/cli.js CHANGED
@@ -1 +1 @@
1
- import{UrlType as e,downloadAnimeIdHentai as t,downloadBilibili as n,downloadDirpy as r,downloadKoreanPm as i,downloadMissav as a,getAnimeIdHentaiLink as o,getBilibiliLink as s,getDirpyLink as c,getKoreanPmLink as l,logger as u,remoteM3U8ToMP4 as d,setSilent as f}from"./types-LuYF6CB8.js";import{bold as p,dim as m}from"ansis";import{cac as h}from"cac";import g from"restore-cursor";var _={name:`fast-dirpy`,type:`module`,version:`0.3.1`,description:`A simple library/CLI to download video from several websites.`,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:`tsdown`,test:`vitest`,dep:`taze major -I`,"lint:fix":`eslint . --fix`,login:`pnpm login --registry https://registry.npmjs.com`},publishConfig:{registry:`https://registry.npmjs.com`,access:`public`},dependencies:{ansis:`^4.2.0`,axios:`^1.12.2`,cac:`^6.7.14`,cheerio:`^1.1.2`,consola:`^3.4.2`,m3u8stream:`^0.8.6`,"puppeteer-core":`^24.23.0`,"restore-cursor":`^5.1.0`,unconfig:`^7.3.3`},devDependencies:{"@antfu/eslint-config":`^5.4.1`,"@types/node":`^24.7.0`,deepmerge:`^4.3.1`,eslint:`^9.37.0`,taze:`^19.7.0`,tsdown:`^0.15.6`,tsx:`^4.20.6`,typescript:`^5.9.3`,vitest:`^3.2.4`}};function v(t){return t.includes(`bilibili`)||/BV[a-zA-Z0-9]+/.test(t)?e.Bilibili:t.includes(`animeidhentai`)?e.AnimeIdHentai:t.includes(`koreanpornmovie`)?e.KoreanPM:t.includes(`missav`)?e.MissAV:t.endsWith(`.m3u8`)?e.M3U8:e.Dirpy}const y=h(`fast-dirpy`),{version:b}=_;y.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(t,n)=>{let r=v(t),{proxyHost:i,proxyPort:a,config:d,silent:h,chromePath:g}=n,_=i?{proxy:{host:i,port:a}}:void 0,y=g?{puppeteer:{executablePath:g}}:void 0;if(f(!!h),u.info(`fast-dirpy ${m(`v${b}`)} : ${p(`Direct Link Getter`)}.`),r===e.Bilibili){if(u.info(`Matched link source: Bilibili.`),!t.includes(`bilibili.com`)){u.error(`Please provide a valid Bilibili URL.`);return}let e=await s(t);console.log(e)}else if(r===e.Dirpy){u.info(`Matched link source: Dirpy.`);let e=await c({url:t,cwd:d},_);console.log(e)}else if(r===e.AnimeIdHentai){u.info(`Matched link source: Animeidhentai.`);let e=await o({url:t,cwd:d},{..._,...y});console.log(e)}else if(r===e.KoreanPM){u.info(`Matched link source: KoreanPM.`);let e=await l({url:t,cwd:d},_);console.log(e)}else u.error(`Your link is not supported!`)}),y.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(o,s)=>{let c=v(o),{proxyHost:l,proxyPort:h,path:g,config:_,silent:y,chromePath:x}=s,S=l?{proxy:{host:l,port:h}}:void 0,C=x?{puppeteer:{executablePath:x}}:void 0;f(!!y),u.info(`fast-dirpy ${m(`v${b}`)} : ${p(`Video Downloader`)}.`),c===e.Bilibili?(u.info(`Matched link source: Bilibili.`),await n({url:o,path:g})):c===e.Dirpy?(u.info(`Matched link source: Dirpy.`),r({url:o,path:g||`./dirpy.mp4`,cwd:_},S)):c===e.AnimeIdHentai?(u.info(`Matched link source: AnimeIdHentai.`),await t({url:o,path:g||`./animeidhentai.mp4`,cwd:_},{...S,...C})):c===e.KoreanPM?(u.info(`Matched link source: KoreanPM.`),await i({url:o,path:g||`./korean-pm.mp4`,cwd:_},S)):c===e.MissAV?(u.info(`Matched link source: MissAV.`),await a({url:o,path:g,cwd:_})):c===e.M3U8?(u.info(`Matched link source: m3u8.`),await d({url:o,path:g||`./m3u8-download.mp4`,cwd:_})):u.error(`Your link is not supported!`)}),y.help(),y.version(_.version),y.parse(),g();export{};
1
+ import{a as e,b as t,c as n,d as r,f as i,g as a,h as o,l as s,m as c,n as l,o as u,p as d,r as f,s as p,t as m,u as h,y as g}from"./judgeUrl-CQGcgriO.js";import{bold as _,dim as v}from"ansis";import{cac as y}from"cac";import b from"restore-cursor";const x=y(`fast-dirpy`),{version:S}=g;x.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(e,t)=>{let n=m(e),{proxyHost:i,proxyPort:c,config:u,silent:f,chromePath:h}=t,g=i?{proxy:{host:i,port:c}}:void 0,y=h?{puppeteer:{executablePath:h}}:void 0;if(a(!!f),o.info(`fast-dirpy ${v(`v${S}`)} : ${_(`Direct Link Getter`)}.`),n===l.Bilibili){if(o.info(`Matched link source: Bilibili.`),!e.includes(`bilibili.com`)){o.error(`Please provide a valid Bilibili URL.`);return}let t=await r(e);console.log(t)}else if(n===l.Dirpy){o.info(`Matched link source: Dirpy.`);let t=await s({url:e,cwd:u},g);console.log(t)}else if(n===l.AnimeIdHentai){o.info(`Matched link source: Animeidhentai.`);let t=await d({url:e,cwd:u},{...g,...y});console.log(t)}else if(n===l.KoreanPM){o.info(`Matched link source: KoreanPM.`);let t=await p({url:e,cwd:u},g);console.log(t)}else o.error(`Your link is not supported!`)}),x.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(t,r)=>{let s=m(t),{proxyHost:d,proxyPort:p,path:g,config:y,silent:b,chromePath:x}=r,C=d?{proxy:{host:d,port:p}}:void 0,w=x?{puppeteer:{executablePath:x}}:void 0;a(!!b),o.info(`fast-dirpy ${v(`v${S}`)} : ${_(`Video Downloader`)}.`),s===l.Bilibili?(o.info(`Matched link source: Bilibili.`),await h({url:t,path:g})):s===l.Dirpy?(o.info(`Matched link source: Dirpy.`),n({url:t,path:g||`./dirpy.mp4`,cwd:y},C)):s===l.AnimeIdHentai?(o.info(`Matched link source: AnimeIdHentai.`),await i({url:t,path:g||`./animeidhentai.mp4`,cwd:y},{...C,...w})):s===l.KoreanPM?(o.info(`Matched link source: KoreanPM.`),await u({url:t,path:g||`./korean-pm.mp4`,cwd:y},C)):s===l.MissAV?(o.info(`Matched link source: MissAV.`),await f({url:t,path:g,cwd:y})):s===l.M3U8?(o.info(`Matched link source: m3u8.`),await e({url:t,path:g||`./m3u8-download.mp4`,cwd:y})):s===l.MP4?(o.info(`Matched link source: mp4.`),await c({url:t,path:g,cwd:y})):o.error(`Your link is not supported!`)}),x.help(),x.version(t),x.parse(),b();export{};
@@ -0,0 +1 @@
1
+ function e(e){return e}export{e as t};
@@ -30,9 +30,10 @@ declare enum UrlType {
30
30
  M3U8 = 3,
31
31
  KoreanPM = 4,
32
32
  MissAV = 5,
33
+ MP4 = 6,
33
34
  }
34
35
  //#endregion
35
36
  //#region src/config.d.ts
36
37
  declare function defineConfig(options: Options): Options;
37
38
  //#endregion
38
- export { DirectLinkParams, DownloadParams, M3U8Params, Options, UrlType, defineConfig };
39
+ export { Options as a, M3U8Params as i, DirectLinkParams as n, UrlType as o, DownloadParams as r, defineConfig as t };
package/dist/config.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { defineConfig } from "./config-nmMeP6kT.js";
1
+ import { t as defineConfig } from "./config-DvqfH1ip.js";
2
2
  export { defineConfig };
package/dist/config.js CHANGED
@@ -1 +1 @@
1
- import{defineConfig as e}from"./config-ld9QlYHr.js";export{e as defineConfig};
1
+ import{t as e}from"./config-C--eeFbZ.js";export{e as defineConfig};
package/dist/index.d.ts CHANGED
@@ -1,5 +1,9 @@
1
- import { DirectLinkParams, DownloadParams, M3U8Params, Options, UrlType, defineConfig } from "./config-nmMeP6kT.js";
1
+ import { a as Options, i as M3U8Params, n as DirectLinkParams, o as UrlType, r as DownloadParams, t as defineConfig } from "./config-DvqfH1ip.js";
2
2
 
3
+ //#region src/constants.d.ts
4
+ declare const DEFAULT_OPTIONS: Options;
5
+ declare const __dirname: string;
6
+ //#endregion
3
7
  //#region src/core/animeidhentai.d.ts
4
8
  declare function getAnimeIdHentaiLink(params: DirectLinkParams, options?: Partial<Options>): Promise<string>;
5
9
  declare function downloadAnimeIdHentai(params: DownloadParams, options?: Partial<Options>): Promise<void>;
@@ -12,10 +16,6 @@ declare function downloadBilibili(params: DownloadParams): Promise<void>;
12
16
  declare function getDirpyLink(params: DirectLinkParams, options?: Partial<Options>): Promise<string>;
13
17
  declare function downloadDirpy(params: DownloadParams, options?: Partial<Options>): Promise<void>;
14
18
  //#endregion
15
- //#region src/core/missav.d.ts
16
- declare function getMissavLink(params: DirectLinkParams): Promise<string>;
17
- declare function downloadMissav(params: Partial<DownloadParams>): Promise<void>;
18
- //#endregion
19
19
  //#region src/core/koreanpm.d.ts
20
20
  declare function getKoreanPmLink(params: DirectLinkParams, options?: Partial<Options>): Promise<string>;
21
21
  declare function downloadKoreanPm(params: DownloadParams, options?: Partial<Options>): Promise<void>;
@@ -26,7 +26,15 @@ declare function downloadKoreanPm(params: DownloadParams, options?: Partial<Opti
26
26
  */
27
27
  declare function remoteM3U8ToMP4(params: Partial<M3U8Params>): void;
28
28
  //#endregion
29
- //#region src/core/index.d.ts
29
+ //#region src/core/missav.d.ts
30
+ declare function getMissavLink(params: DirectLinkParams): Promise<string>;
31
+ declare function downloadMissav(params: Partial<DownloadParams>): Promise<void>;
32
+ //#endregion
33
+ //#region src/utils/downloader.d.ts
30
34
  declare function downloadVideo(params: DownloadParams, options?: Partial<Options>): Promise<void>;
31
35
  //#endregion
32
- export { DirectLinkParams, DownloadParams, M3U8Params, Options, UrlType, defineConfig, downloadAnimeIdHentai, downloadBilibili, downloadDirpy, downloadKoreanPm, downloadMissav, downloadVideo, getAnimeIdHentaiLink, getBilibiliLink, getDirpyLink, getKoreanPmLink, getMissavLink, remoteM3U8ToMP4 };
36
+ //#region src/index.d.ts
37
+ declare function fastLink(params: DirectLinkParams, options?: Partial<Options>): Promise<string>;
38
+ declare function fastDownload(params: DownloadParams, options?: Partial<Options>): Promise<void>;
39
+ //#endregion
40
+ export { DEFAULT_OPTIONS, DirectLinkParams, DownloadParams, M3U8Params, Options, UrlType, __dirname, defineConfig, downloadAnimeIdHentai, downloadBilibili, downloadDirpy, downloadKoreanPm, downloadMissav, downloadVideo, fastDownload, fastLink, getAnimeIdHentaiLink, getBilibiliLink, getDirpyLink, getKoreanPmLink, getMissavLink, remoteM3U8ToMP4 };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{UrlType as e,downloadAnimeIdHentai as t,downloadBilibili as n,downloadDirpy as r,downloadKoreanPm as i,downloadMissav as a,downloadVideo as o,getAnimeIdHentaiLink as s,getBilibiliLink as c,getDirpyLink as l,getKoreanPmLink as u,getMissavLink as d,remoteM3U8ToMP4 as f}from"./types-LuYF6CB8.js";import{defineConfig as p}from"./config-ld9QlYHr.js";export{e as UrlType,p as defineConfig,t as downloadAnimeIdHentai,n as downloadBilibili,r as downloadDirpy,i as downloadKoreanPm,a as downloadMissav,o as downloadVideo,s as getAnimeIdHentaiLink,c as getBilibiliLink,l as getDirpyLink,u as getKoreanPmLink,d as getMissavLink,f as remoteM3U8ToMP4};
1
+ import{_ as e,a as t,c as n,d as r,f as i,h as a,i as o,l as s,m as c,n as l,o as u,p as d,r as f,s as p,t as m,u as h,v as g,y as _}from"./judgeUrl-CQGcgriO.js";import{t as v}from"./config-C--eeFbZ.js";import{bold as y,dim as b}from"ansis";const{version:x}=_;async function S(t,n=e){let{url:i,cwd:c}=t,{proxy:u,puppeteer:f}=n,h=u||{},g=f||{},_=m(i);return a.info(`fast-dirpy ${b(`v${x}`)} : ${y(`Direct Link Getter`)}.`),_===l.Bilibili?(a.info(`Matched link source: Bilibili.`),i.includes(`bilibili.com`)?await r(i):(a.error(`Please provide a valid Bilibili URL.`),``)):_===l.AnimeIdHentai?(a.info(`Matched link source: Animeidhentai.`),await d({url:i,cwd:c},{...h,...g})):_===l.KoreanPM?(a.info(`Matched link source: KoreanPM.`),await p({url:i,cwd:c},h)):_===l.MissAV?(a.info(`Matched link source: MissAV.`),await o({url:i,cwd:c})):_===l.Dirpy?(a.info(`Matched link source: Dirpy.`),await s({url:i,cwd:c},h)):(a.error(`Your link is not supported!`),``)}async function C(r,o=e){let{url:s,path:c,cwd:d}=r,{proxy:p,puppeteer:g}=o,_=p||{},v=g||{},S=m(s);a.info(`fast-dirpy ${b(`v${x}`)} : ${y(`Video Downloader`)}.`),S===l.Bilibili?(a.info(`Matched link source: Bilibili.`),await h({url:s,path:c})):S===l.Dirpy?(a.info(`Matched link source: Dirpy.`),n({url:s,path:c||`./dirpy.mp4`,cwd:d},_)):S===l.AnimeIdHentai?(a.info(`Matched link source: AnimeIdHentai.`),await i({url:s,path:c||`./animeidhentai.mp4`,cwd:d},{..._,...v})):S===l.KoreanPM?(a.info(`Matched link source: KoreanPM.`),await u({url:s,path:c||`./korean-pm.mp4`,cwd:d},_)):S===l.MissAV?(a.info(`Matched link source: MissAV.`),await f({url:s,path:c,cwd:d})):S===l.M3U8?(a.info(`Matched link source: m3u8.`),await t({url:s,path:c||`./m3u8-download.mp4`,cwd:d})):a.error(`Your link is not supported!`)}export{e as DEFAULT_OPTIONS,l as UrlType,g as __dirname,v as defineConfig,i as downloadAnimeIdHentai,h as downloadBilibili,n as downloadDirpy,u as downloadKoreanPm,f as downloadMissav,c as downloadVideo,C as fastDownload,S as fastLink,d as getAnimeIdHentaiLink,r as getBilibiliLink,s as getDirpyLink,p as getKoreanPmLink,o as getMissavLink,t as remoteM3U8ToMP4};
@@ -0,0 +1,3 @@
1
+ import e from"axios";import{load as t}from"cheerio";import n from"node:path";import{fileURLToPath as r}from"node:url";import{createConfigLoader as i}from"unconfig";import a from"node:process";import{consola as o}from"consola";import s from"puppeteer-core";import c,{createWriteStream as l}from"node:fs";import u from"m3u8stream";var d=Object.create,f=Object.defineProperty,p=Object.getOwnPropertyDescriptor,m=Object.getOwnPropertyNames,h=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty,_=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),v=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=m(t),a=0,o=i.length,s;a<o;a++)s=i[a],!g.call(e,s)&&s!==n&&f(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=p(t,s))||r.enumerable});return e},y=(e,t,n)=>(n=e==null?{}:d(h(e)),v(t||!e||!e.__esModule?f(n,`default`,{value:e,enumerable:!0}):n,e)),b=`0.3.3`,x={name:`fast-dirpy`,type:`module`,version:b,description:`A simple library/CLI to download video from several websites.`,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:`tsdown`,test:`vitest`,dep:`taze major -I`,"lint:fix":`eslint . --fix`,login:`pnpm login --registry https://registry.npmjs.com`},publishConfig:{registry:`https://registry.npmjs.com`,access:`public`},dependencies:{ansis:`^4.2.0`,axios:`^1.13.1`,cac:`^6.7.14`,cheerio:`^1.1.2`,consola:`^3.4.2`,m3u8stream:`^0.8.6`,"puppeteer-core":`^24.27.0`,"restore-cursor":`^5.1.0`,unconfig:`^7.3.3`},devDependencies:{"@antfu/eslint-config":`^6.2.0`,"@types/node":`^24.9.2`,deepmerge:`^4.3.1`,eslint:`^9.39.0`,taze:`^19.9.0`,tsdown:`^0.15.12`,tsx:`^4.20.6`,typescript:`^5.9.3`,vitest:`^4.0.6`}};const S={timeout:2e4},C=r(import.meta.url),w=n.dirname(C);var T=_(((e,t)=>{var n=function(e){return r(e)&&!i(e)};function r(e){return!!e&&typeof e==`object`}function i(e){var t=Object.prototype.toString.call(e);return t===`[object RegExp]`||t===`[object Date]`||o(e)}var a=typeof Symbol==`function`&&Symbol.for?Symbol.for(`react.element`):60103;function o(e){return e.$$typeof===a}function s(e){return Array.isArray(e)?[]:{}}function c(e,t){return t.clone!==!1&&t.isMergeableObject(e)?g(s(e),e,t):e}function l(e,t,n){return e.concat(t).map(function(e){return c(e,n)})}function u(e,t){if(!t.customMerge)return g;var n=t.customMerge(e);return typeof n==`function`?n:g}function d(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[]}function f(e){return Object.keys(e).concat(d(e))}function p(e,t){try{return t in e}catch{return!1}}function m(e,t){return p(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))}function h(e,t,n){var r={};return n.isMergeableObject(e)&&f(e).forEach(function(t){r[t]=c(e[t],n)}),f(t).forEach(function(i){m(e,i)||(p(e,i)&&n.isMergeableObject(t[i])?r[i]=u(i,n)(e[i],t[i],n):r[i]=c(t[i],n))}),r}function g(e,t,r){r||={},r.arrayMerge=r.arrayMerge||l,r.isMergeableObject=r.isMergeableObject||n,r.cloneUnlessOtherwiseSpecified=c;var i=Array.isArray(t);return i===Array.isArray(e)?i?r.arrayMerge(e,t,r):h(e,t,r):c(t,r)}g.all=function(e,t){if(!Array.isArray(e))throw Error(`first argument should be an array`);return e.reduce(function(e,n){return g(e,n,t)},{})},t.exports=g}));const E=o.withTag(`fast-dirpy`);function D(e){`CONSOLA_LEVEL`in a.env||(E.level=e?0:3)}var O=y(T(),1);async function k(e,t){let n=S,{config:r,sources:a}=await i({sources:[{files:[`fast-dirpy.config`],extensions:[`ts`,`mts`,`cts`,`js`,`mjs`,`cjs`,`json`]}],cwd:t||process.cwd(),merge:!1}).load();return a.length?(E.info(`Config file found: ${a[0]}`),(0,O.default)((0,O.default)(n,r),e)):(0,O.default)(n,e)}async function A(e){return await s.launch(e)}function j(e){return e[Math.floor(Math.random()*e.length)]}const M=[`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 N(){return j(M)}async function P(t,n=S){let{path:r,url:i}=t,{proxy:a,timeout:o}=await k(n),s=a?.host===``?void 0:a;if(i===``)return Promise.reject(`Extract direct link failed!`);let l=c.createWriteStream(r);return(await e({url:i,headers:{"User-Agent":N()},method:`GET`,responseType:`stream`,proxy:s,timeout:o,onDownloadProgress:e=>{let{loaded:t,total:n,progress:r}=e,i=`loaded:${t} total: ${n} progress: ${(r*100).toFixed(2)}%`;E.info(i)}})).data.pipe(l),new Promise((e,t)=>{l.on(`finish`,e),l.on(`error`,t)})}async function F(n,r=S){let{url:i,cwd:a}=n,{proxy:o,timeout:s}=await k(r,a),c=o?.host===``?void 0:o,{data:l}=await e.get(i,{headers:{"User-Agent":N()},proxy:c,timeout:s}),u=t(l),d=``,f=u(`div.embed.rad2 > iframe`).attr();return f&&(d=f.src),d}async function I(e,t=S){let{url:n,cwd:r}=e,{proxy:i,puppeteer:a}=await k(t,r),o=i?.host===``?void 0:i,s=await F({url:n},{proxy:o}),{executablePath:c,headless:l}=a,u=await A({executablePath:c,headless:l,args:[`--proxy-server=http://${o?.host}:${i?.port}`]}),d=N(),f=await u.newPage();await f.setUserAgent(d),await f.goto(s),await f.waitForSelector(`div.play.p-pulse`),await f.click(`div.play.p-pulse`),await f.waitForSelector(`div.frame > iframe`);let p=await f.$eval(`div.frame > iframe`,e=>e.src),m=await u.newPage();await m.goto(`${p}`),await m.waitForSelector(`video.jw-video.jw-reset`);let h=await m.$eval(`video.jw-video.jw-reset`,e=>e.src);return await u.close(),h}async function L(e,t=S){let{path:n,url:r,cwd:i}=e;await P({url:await I({url:r},t),path:n,cwd:i},t)}function R(e){let t=e.match(/BV[a-zA-Z0-9]+/);return t?`https://bilibili-real-url.deno.dev/${t[0]}.mp4`:``}async function z(e){let{path:t,url:n}=e,r=R(n);r===``?console.error(`Extract direct link failed!`):await P({url:r,path:t||`./download.mp4`})}async function B(n,r=S){let{url:i,cwd:a}=n,{proxy:o,timeout:s}=await k(r,a),c=o?.host===``?void 0:o,{data:l}=await e.get(`https://dirpy.com/studio`,{params:{url:i},headers:{"User-Agent":N(),Referer:`https://dirpy.com/studio?url=${i}`},proxy:c,timeout:s}),u=t(l),d=``,f=u(`#media-source`).attr();return f&&(d=f.src),d}async function V(e,t=S){let{path:n,url:r,cwd:i}=e;await P({url:await B({url:r},t),path:n,cwd:i},t)}async function H(n,r=S){let{url:i,cwd:a}=n,{proxy:o,timeout:s}=await k(r,a),c=o?.host===``?void 0:o,{data:l}=await e.get(i,{headers:{"User-Agent":N()},proxy:c,timeout:s}),u=t(l),d=``,f=u(`meta[itemprop="contentURL"]`).attr();return f&&(d=f.content),d}async function U(e,t=S){let{path:n,url:r,cwd:i}=e;await P({url:await H({url:r},t),path:n,cwd:i},t)}function W(e){let{url:t,path:r}=e,i=r??n.resolve(w,`../m3u8-download.mp4`),a=u(t);a.pipe(l(i)),a.on(`progress`,(e,t,n)=>{E.info(`Segment: ${JSON.stringify(e)},
2
+ Total Segments: ${t},
3
+ downloaded: ${(n/1024/1024).toFixed(2)}MB Downloaded`),e.num>=t&&a.end()})}function G(e){return new Promise(t=>setTimeout(t,e*1e3))}async function K(e,t=S){let{url:n,cwd:r}=e,{proxy:i,puppeteer:a}=await k(t,r),o=i?.host===``?void 0:i,{executablePath:s,headless:c}=a,l=await A({executablePath:s,headless:c,args:[`--proxy-server=http://${o?.host}:${i?.port}`,`--disable-features=IsolateOrigins,site-per-process`,`--disable-site-isolation-trials`,`--disable-web-security`,`--disable-setuid-sandbox`,`--no-sandbox`,`--disable-gpu`,`--disable-dev-shm-usage`,`--disable-accelerated-2d-canvas`,`--no-first-run`,`--no-zygote`,`--single-process`,`--window-size=1920,1080`],slowMo:50,timezoneId:`America/New_York`,locale:`en-US`}),u=await l.newPage(),d=N();await u.setUserAgent(d);try{let e=await u.goto(n,{waitUntil:`domcontentloaded`});e&&E.info(`http status: ${e.status()}`);let t=await u.title(),r=await u.content();if(E.info(`Page title: ${t}`),t.includes(`Just a moment`)||r.includes(`Checking your browser`)){E.info(`Cloudflare challenge detected, waiting for it to complete...`);try{E.info(`Waiting for page title to change...`),await u.waitForFunction(`document.title != 'Just a moment...'`,{timeout:3e4}),E.info(`Page title has changed`)}catch(e){E.error(`Timeout waiting for title change: ${e}`);try{for(let e of[`input[type='checkbox']`,`.ray-button`,`#challenge-stage button`,`button:has-text('Verify')`,`button:has-text('Continue')`])if(await u.$(e)){E.info(`Found possible verification button: ${e}`),await u.click(e),G(5);break}}catch(e){E.error(`Failed to click verification button: ${e}`)}}}let i=await u.title();E.info(`current page title: ${i}`),E.info(`Simulating page scroll...`);for(let e=0;e<3;e++)await u.evaluate(`window.scrollBy(0, window.innerHeight / 2)`),await u.evaluate(`window.scrollBy(0, window.innerHeight / 4)`);E.info(`Getting page content...`);let a=await u.content();return E.info(`Page content retrieved successfully.`),a}catch(e){E.error(`Error during scraping: ${e}`)}finally{E.info(`Closing browser`),await l.close()}}async function q(e){let t=e.match(/m3u8\|([a-f0-9|]+)\|com\|surrit\|https\|video/);return t?t[1].split(`|`).reverse().join(`-`):(E.error(`Failed to extract UUID from HTML.`),null)}function J(e){return e.split(`/`).pop()||(E.error(`Failed to extract movie ID from URL.`),null)}async function Y(t){let{url:n,cwd:r}=t,i=await q(await K({url:n,cwd:r})),a=`https://surrit.com/${i}/playlist.m3u8`,{data:o}=await e.get(a),s=o.match(/(?:\d+p|\d+x\d+)\/video\.m3u8/g);return`https://surrit.com/${i}/${s[s.length-1]}`}async function X(e){let{url:t,cwd:n,path:r}=e,i=J(t);await W({url:await Y({url:t,cwd:n}),cwd:n,path:r||`${i}.mp4`})}let Z=function(e){return e[e.Bilibili=0]=`Bilibili`,e[e.AnimeIdHentai=1]=`AnimeIdHentai`,e[e.Dirpy=2]=`Dirpy`,e[e.M3U8=3]=`M3U8`,e[e.KoreanPM=4]=`KoreanPM`,e[e.MissAV=5]=`MissAV`,e[e.MP4=6]=`MP4`,e}({});function Q(e){return e.includes(`bilibili`)||/BV[a-zA-Z0-9]+/.test(e)?Z.Bilibili:e.includes(`animeidhentai`)?Z.AnimeIdHentai:e.includes(`koreanpornmovie`)?Z.KoreanPM:e.includes(`missav`)?Z.MissAV:e.includes(`.m3u8`)?Z.M3U8:e.endsWith(`.mp4`)?Z.MP4:Z.Dirpy}export{S as _,W as a,b,V as c,R as d,L as f,D as g,E as h,Y as i,B as l,P as m,Z as n,U as o,I as p,X as r,H as s,Q as t,z as u,w as v,x as y};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "fast-dirpy",
3
3
  "type": "module",
4
- "version": "0.3.1",
4
+ "version": "0.3.3",
5
5
  "description": "A simple library/CLI to download video from several websites.",
6
6
  "author": "Vincent-the-gamer",
7
7
  "license": "MIT",
@@ -37,25 +37,25 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "ansis": "^4.2.0",
40
- "axios": "^1.12.2",
40
+ "axios": "^1.13.1",
41
41
  "cac": "^6.7.14",
42
42
  "cheerio": "^1.1.2",
43
43
  "consola": "^3.4.2",
44
44
  "m3u8stream": "^0.8.6",
45
- "puppeteer-core": "^24.23.0",
45
+ "puppeteer-core": "^24.27.0",
46
46
  "restore-cursor": "^5.1.0",
47
47
  "unconfig": "^7.3.3"
48
48
  },
49
49
  "devDependencies": {
50
- "@antfu/eslint-config": "^5.4.1",
51
- "@types/node": "^24.7.0",
50
+ "@antfu/eslint-config": "^6.2.0",
51
+ "@types/node": "^24.9.2",
52
52
  "deepmerge": "^4.3.1",
53
- "eslint": "^9.37.0",
54
- "taze": "^19.7.0",
55
- "tsdown": "^0.15.6",
53
+ "eslint": "^9.39.0",
54
+ "taze": "^19.9.0",
55
+ "tsdown": "^0.15.12",
56
56
  "tsx": "^4.20.6",
57
57
  "typescript": "^5.9.3",
58
- "vitest": "^3.2.4"
58
+ "vitest": "^4.0.6"
59
59
  },
60
60
  "scripts": {
61
61
  "tsx": "tsx",
@@ -1 +0,0 @@
1
- function e(e){return e}export{e as defineConfig};
@@ -1,3 +0,0 @@
1
- import e,{createWriteStream as t}from"node:fs";import n from"axios";import r from"node:path";import{fileURLToPath as i}from"url";import{createConfigLoader as a}from"unconfig";import o from"node:process";import{consola as s}from"consola";import{load as c}from"cheerio";import l from"puppeteer-core";import u from"m3u8stream";var d=Object.create,f=Object.defineProperty,p=Object.getOwnPropertyDescriptor,m=Object.getOwnPropertyNames,h=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty,_=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),v=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=m(t),a=0,o=i.length,s;a<o;a++)s=i[a],!g.call(e,s)&&s!==n&&f(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=p(t,s))||r.enumerable});return e},y=(e,t,n)=>(n=e==null?{}:d(h(e)),v(t||!e||!e.__esModule?f(n,`default`,{value:e,enumerable:!0}):n,e));const b={timeout:2e4},x=i(import.meta.url),S=r.dirname(x);var C=_(((e,t)=>{var n=function(e){return r(e)&&!i(e)};function r(e){return!!e&&typeof e==`object`}function i(e){var t=Object.prototype.toString.call(e);return t===`[object RegExp]`||t===`[object Date]`||o(e)}var a=typeof Symbol==`function`&&Symbol.for?Symbol.for(`react.element`):60103;function o(e){return e.$$typeof===a}function s(e){return Array.isArray(e)?[]:{}}function c(e,t){return t.clone!==!1&&t.isMergeableObject(e)?g(s(e),e,t):e}function l(e,t,n){return e.concat(t).map(function(e){return c(e,n)})}function u(e,t){if(!t.customMerge)return g;var n=t.customMerge(e);return typeof n==`function`?n:g}function d(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[]}function f(e){return Object.keys(e).concat(d(e))}function p(e,t){try{return t in e}catch{return!1}}function m(e,t){return p(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))}function h(e,t,n){var r={};return n.isMergeableObject(e)&&f(e).forEach(function(t){r[t]=c(e[t],n)}),f(t).forEach(function(i){m(e,i)||(p(e,i)&&n.isMergeableObject(t[i])?r[i]=u(i,n)(e[i],t[i],n):r[i]=c(t[i],n))}),r}function g(e,t,r){r||={},r.arrayMerge=r.arrayMerge||l,r.isMergeableObject=r.isMergeableObject||n,r.cloneUnlessOtherwiseSpecified=c;var i=Array.isArray(t);return i===Array.isArray(e)?i?r.arrayMerge(e,t,r):h(e,t,r):c(t,r)}g.all=function(e,t){if(!Array.isArray(e))throw Error(`first argument should be an array`);return e.reduce(function(e,n){return g(e,n,t)},{})},t.exports=g}));const w=s.withTag(`fast-dirpy`);function T(e){`CONSOLA_LEVEL`in o.env||(w.level=e?0:3)}var E=y(C(),1);async function D(e,t){let n=b,{config:r,sources:i}=await a({sources:[{files:[`fast-dirpy.config`],extensions:[`ts`,`mts`,`cts`,`js`,`mjs`,`cjs`,`json`]}],cwd:t||process.cwd(),merge:!1}).load();return i.length?(w.info(`Config file found: ${i[0]}`),(0,E.default)((0,E.default)(n,r),e)):(0,E.default)(n,e)}function O(e){return e[Math.floor(Math.random()*e.length)]}const k=[`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 A(){return O(k)}async function j(e){return await l.launch(e)}async function M(e,t=b){let{url:r,cwd:i}=e,{proxy:a,timeout:o}=await D(t,i),s=a?.host===``?void 0:a,{data:l}=await n.get(r,{headers:{"User-Agent":A()},proxy:s,timeout:o}),u=c(l),d=``,f=u(`div.embed.rad2 > iframe`).attr();return f&&(d=f.src),d}async function N(e,t=b){let{url:n,cwd:r}=e,{proxy:i,puppeteer:a}=await D(t,r),o=i?.host===``?void 0:i,s=await M({url:n},{proxy:o}),{executablePath:c,headless:l}=a,u=await j({executablePath:c,headless:l,args:[`--proxy-server=http://${o?.host}:${i?.port}`]}),d=A(),f=await u.newPage();await f.setUserAgent(d),await f.goto(s),await f.waitForSelector(`div.play.p-pulse`),await f.click(`div.play.p-pulse`),await f.waitForSelector(`div.frame > iframe`);let p=await f.$eval(`div.frame > iframe`,e=>e.src),m=await u.newPage();await m.goto(`${p}`),await m.waitForSelector(`video.jw-video.jw-reset`);let h=await m.$eval(`video.jw-video.jw-reset`,e=>e.src);return await u.close(),h}async function P(e,t=b){let{path:n,url:r,cwd:i}=e;await J({url:await N({url:r},t),path:n,cwd:i},t)}function F(e){let t=e.match(/BV[a-zA-Z0-9]+/);return t?`https://bilibili-real-url.deno.dev/${t[0]}.mp4`:``}async function I(e){let{path:t,url:n}=e,r=F(n);r===``?console.error(`Extract direct link failed!`):await J({url:r,path:t||`./download.mp4`})}async function L(e,t=b){let{url:r,cwd:i}=e,{proxy:a,timeout:o}=await D(t,i),s=a?.host===``?void 0:a,{data:l}=await n.get(`https://dirpy.com/studio`,{params:{url:r},headers:{"User-Agent":A(),Referer:`https://dirpy.com/studio?url=${r}`},proxy:s,timeout:o}),u=c(l),d=``,f=u(`#media-source`).attr();return f&&(d=f.src),d}async function R(e,t=b){let{path:n,url:r,cwd:i}=e;await J({url:await L({url:r},t),path:n,cwd:i},t)}function z(e){return new Promise(t=>setTimeout(t,e*1e3))}function B(e){let{url:n,path:i}=e,a=i??r.resolve(S,`../m3u8-download.mp4`),o=u(n);o.pipe(t(a)),o.on(`progress`,(e,t,n)=>{w.info(`Segment: ${JSON.stringify(e)},
2
- Total Segments: ${t},
3
- downloaded: ${(n/1024/1024).toFixed(2)}MB Downloaded`),e.num>=t&&o.end()})}async function V(e,t=b){let{url:n,cwd:r}=e,{proxy:i,puppeteer:a}=await D(t,r),o=i?.host===``?void 0:i,{executablePath:s,headless:c}=a,l=await j({executablePath:s,headless:c,args:[`--proxy-server=http://${o?.host}:${i?.port}`,`--disable-features=IsolateOrigins,site-per-process`,`--disable-site-isolation-trials`,`--disable-web-security`,`--disable-setuid-sandbox`,`--no-sandbox`,`--disable-gpu`,`--disable-dev-shm-usage`,`--disable-accelerated-2d-canvas`,`--no-first-run`,`--no-zygote`,`--single-process`,`--window-size=1920,1080`],slowMo:50,timezoneId:`America/New_York`,locale:`en-US`}),u=await l.newPage(),d=A();await u.setUserAgent(d);try{let e=await u.goto(n,{waitUntil:`domcontentloaded`});e&&w.info(`http status: ${e.status()}`);let t=await u.title(),r=await u.content();if(w.info(`Page title: ${t}`),t.includes(`Just a moment`)||r.includes(`Checking your browser`)){w.info(`Cloudflare challenge detected, waiting for it to complete...`);try{w.info(`Waiting for page title to change...`),await u.waitForFunction(`document.title != 'Just a moment...'`,{timeout:3e4}),w.info(`Page title has changed`)}catch(e){w.error(`Timeout waiting for title change: ${e}`);try{for(let e of[`input[type='checkbox']`,`.ray-button`,`#challenge-stage button`,`button:has-text('Verify')`,`button:has-text('Continue')`])if(await u.$(e)){w.info(`Found possible verification button: ${e}`),await u.click(e),z(5);break}}catch(e){w.error(`Failed to click verification button: ${e}`)}}}let i=await u.title();w.info(`current page title: ${i}`),w.info(`Simulating page scroll...`);for(let e=0;e<3;e++)await u.evaluate(`window.scrollBy(0, window.innerHeight / 2)`),await u.evaluate(`window.scrollBy(0, window.innerHeight / 4)`);w.info(`Getting page content...`);let a=await u.content();return w.info(`Page content retrieved successfully.`),a}catch(e){w.error(`Error during scraping: ${e}`)}finally{w.info(`Closing browser`),await l.close()}}async function H(e){let t=e.match(/m3u8\|([a-f0-9\|]+)\|com\|surrit\|https\|video/);return t?t[1].split(`|`).reverse().join(`-`):(w.error(`Failed to extract UUID from HTML.`),null)}function U(e){return e.split(`/`).pop()||(w.error(`Failed to extract movie ID from URL.`),null)}async function W(e){let{url:t,cwd:r}=e,i=await H(await V({url:t,cwd:r})),a=`https://surrit.com/${i}/playlist.m3u8`,{data:o}=await n.get(a),s=o.match(/(?:\d+p|\d+x\d+)\/video\.m3u8/g);return`https://surrit.com/${i}/${s[s.length-1]}`}async function G(e){let{url:t,cwd:n,path:r}=e,i=U(t);await B({url:await W({url:t,cwd:n}),cwd:n,path:r||`${i}.mp4`})}async function K(e,t=b){let{url:r,cwd:i}=e,{proxy:a,timeout:o}=await D(t,i),s=a?.host===``?void 0:a,{data:l}=await n.get(r,{headers:{"User-Agent":A()},proxy:s,timeout:o}),u=c(l),d=``,f=u(`meta[itemprop="contentURL"]`).attr();return f&&(d=f.content),d}async function q(e,t=b){let{path:n,url:r,cwd:i}=e;await J({url:await K({url:r},t),path:n,cwd:i},t)}async function J(t,r=b){let{path:i,url:a}=t,{proxy:o,timeout:s}=await D(r),c=o?.host===``?void 0:o;if(a===``)return Promise.reject(`Extract direct link failed!`);let l=e.createWriteStream(i);return(await n({url:a,headers:{"User-Agent":A()},method:`GET`,responseType:`stream`,proxy:c,timeout:s,onDownloadProgress:e=>{let{loaded:t,total:n,progress:r}=e,i=`loaded:${t} total: ${n} progress: ${(r*100).toFixed(2)}%`;w.info(i)}})).data.pipe(l),new Promise((e,t)=>{l.on(`finish`,e),l.on(`error`,t)})}let Y=function(e){return e[e.Bilibili=0]=`Bilibili`,e[e.AnimeIdHentai=1]=`AnimeIdHentai`,e[e.Dirpy=2]=`Dirpy`,e[e.M3U8=3]=`M3U8`,e[e.KoreanPM=4]=`KoreanPM`,e[e.MissAV=5]=`MissAV`,e}({});export{Y as UrlType,P as downloadAnimeIdHentai,I as downloadBilibili,R as downloadDirpy,q as downloadKoreanPm,G as downloadMissav,J as downloadVideo,N as getAnimeIdHentaiLink,F as getBilibiliLink,L as getDirpyLink,K as getKoreanPmLink,W as getMissavLink,w as logger,B as remoteM3U8ToMP4,T as setSilent};