fast-dirpy 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -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.
@@ -151,46 +150,35 @@ fast-dirpy --help
151
150
  > If a website is listed in [Supported Websites](#supported-websites), then `getXXXLink` is to get direct link and `downloadXXX` is to download video.
152
151
 
153
152
  ```ts
154
- import { downloadDirpy, getBilibiliLink, getDirpyLink, remoteM3U8ToMP4 } from 'fast-dirpy'
153
+ import { fastLink, fastDownload } from 'fast-dirpy'
155
154
 
156
155
  // get direct link
157
- const link = await getDirpyLink(
156
+ const link = await fastLink(
158
157
  {
159
158
  url: '<url>',
160
159
  cwd: '/path/to/external-config' // Optional: You can specify an external config file.
161
160
  },
161
+ // options (Optional, can be omitted if you have a config file, this can overwrite your config file options.)
162
162
  {
163
- host: '127.0.0.1',
164
- port: 7890
163
+ proxy: { ... }
165
164
  }
166
165
  )
167
166
 
168
- // get bilibili direct link
169
- const link = await getBilibiliLink(
170
- '<url>',
171
- )
172
-
173
167
  // download video
174
- await downloadDirpy({
168
+ await fastDownload({
175
169
  url: '<url>',
176
170
  path: './download.mp4',
177
171
  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
- }
182
- })
183
-
184
- // download bilibili video
185
- await downloadBilibili({
186
- url: '<url>',
187
- path: './myvideo.mp4'
172
+ },
173
+ // options (Optional, can be omitted if you have a config file, this can overwrite your config file options.)
174
+ {
175
+ proxy: { ... }
188
176
  })
189
177
 
190
178
  // download `.m3u8` video
191
179
  await remoteM3U8ToMP4({
192
- input: 'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8',
193
- output: './test.mp4',
180
+ url: 'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8',
181
+ path: './test.mp4',
194
182
  })
195
183
  ```
196
184
 
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{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,judgeUrl as u,logger as d,package_default as f,remoteM3U8ToMP4 as p,setSilent as m}from"./judgeUrl--jwX-SYw.js";import{bold as h,dim as g}from"ansis";import{cac as _}from"cac";import v from"restore-cursor";const y=_(`fast-dirpy`),{version:b}=f;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=u(t),{proxyHost:i,proxyPort:a,config:f,silent:p,chromePath:_}=n,v=i?{proxy:{host:i,port:a}}:void 0,y=_?{puppeteer:{executablePath:_}}:void 0;if(m(!!p),d.info(`fast-dirpy ${g(`v${b}`)} : ${h(`Direct Link Getter`)}.`),r===e.Bilibili){if(d.info(`Matched link source: Bilibili.`),!t.includes(`bilibili.com`)){d.error(`Please provide a valid Bilibili URL.`);return}let e=await s(t);console.log(e)}else if(r===e.Dirpy){d.info(`Matched link source: Dirpy.`);let e=await c({url:t,cwd:f},v);console.log(e)}else if(r===e.AnimeIdHentai){d.info(`Matched link source: Animeidhentai.`);let e=await o({url:t,cwd:f},{...v,...y});console.log(e)}else if(r===e.KoreanPM){d.info(`Matched link source: KoreanPM.`);let e=await l({url:t,cwd:f},v);console.log(e)}else d.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=u(o),{proxyHost:l,proxyPort:f,path:_,config:v,silent:y,chromePath:x}=s,S=l?{proxy:{host:l,port:f}}:void 0,C=x?{puppeteer:{executablePath:x}}:void 0;m(!!y),d.info(`fast-dirpy ${g(`v${b}`)} : ${h(`Video Downloader`)}.`),c===e.Bilibili?(d.info(`Matched link source: Bilibili.`),await n({url:o,path:_})):c===e.Dirpy?(d.info(`Matched link source: Dirpy.`),r({url:o,path:_||`./dirpy.mp4`,cwd:v},S)):c===e.AnimeIdHentai?(d.info(`Matched link source: AnimeIdHentai.`),await t({url:o,path:_||`./animeidhentai.mp4`,cwd:v},{...S,...C})):c===e.KoreanPM?(d.info(`Matched link source: KoreanPM.`),await i({url:o,path:_||`./korean-pm.mp4`,cwd:v},S)):c===e.MissAV?(d.info(`Matched link source: MissAV.`),await a({url:o,path:_,cwd:v})):c===e.M3U8?(d.info(`Matched link source: m3u8.`),await p({url:o,path:_||`./m3u8-download.mp4`,cwd:v})):d.error(`Your link is not supported!`)}),y.help(),y.version(f.version),y.parse(),v();export{};
package/dist/index.d.ts CHANGED
@@ -1,5 +1,9 @@
1
1
  import { DirectLinkParams, DownloadParams, M3U8Params, Options, UrlType, defineConfig } from "./config-nmMeP6kT.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,12 @@ 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
30
- declare function downloadVideo(params: DownloadParams, options?: Partial<Options>): Promise<void>;
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/index.d.ts
34
+ declare function fastLink(params: DirectLinkParams, options?: Partial<Options>): Promise<string>;
35
+ declare function fastDownload(params: DownloadParams, options?: Partial<Options>): Promise<void>;
31
36
  //#endregion
32
- export { DirectLinkParams, DownloadParams, M3U8Params, Options, UrlType, defineConfig, downloadAnimeIdHentai, downloadBilibili, downloadDirpy, downloadKoreanPm, downloadMissav, downloadVideo, getAnimeIdHentaiLink, getBilibiliLink, getDirpyLink, getKoreanPmLink, getMissavLink, remoteM3U8ToMP4 };
37
+ export { DEFAULT_OPTIONS, DirectLinkParams, DownloadParams, M3U8Params, Options, UrlType, __dirname, defineConfig, downloadAnimeIdHentai, downloadBilibili, downloadDirpy, downloadKoreanPm, downloadMissav, 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{DEFAULT_OPTIONS as e,UrlType as t,__dirname as n,downloadAnimeIdHentai as r,downloadBilibili as i,downloadDirpy as a,downloadKoreanPm as o,downloadMissav as s,getAnimeIdHentaiLink as c,getBilibiliLink as l,getDirpyLink as u,getKoreanPmLink as d,getMissavLink as f,judgeUrl as p,logger as m,package_default as h,remoteM3U8ToMP4 as g}from"./judgeUrl--jwX-SYw.js";import{defineConfig as _}from"./config-ld9QlYHr.js";import{bold as v,dim as y}from"ansis";const{version:b}=h;async function x(n,r=e){let{url:i,cwd:a}=n,{proxy:o,puppeteer:s}=r,h=o||{},g=s||{},_=p(i);return m.info(`fast-dirpy ${y(`v${b}`)} : ${v(`Direct Link Getter`)}.`),_===t.Bilibili?(m.info(`Matched link source: Bilibili.`),i.includes(`bilibili.com`)?await l(i):(m.error(`Please provide a valid Bilibili URL.`),``)):_===t.AnimeIdHentai?(m.info(`Matched link source: Animeidhentai.`),await c({url:i,cwd:a},{...h,...g})):_===t.KoreanPM?(m.info(`Matched link source: KoreanPM.`),await d({url:i,cwd:a},h)):_===t.MissAV?(m.info(`Matched link source: MissAV.`),await f({url:i,cwd:a})):_===t.Dirpy?(m.info(`Matched link source: Dirpy.`),await u({url:i,cwd:a},h)):(m.error(`Your link is not supported!`),``)}async function S(n,c=e){let{url:l,path:u,cwd:d}=n,{proxy:f,puppeteer:h}=c,_=f||{},x=h||{},S=p(l);m.info(`fast-dirpy ${y(`v${b}`)} : ${v(`Video Downloader`)}.`),S===t.Bilibili?(m.info(`Matched link source: Bilibili.`),await i({url:l,path:u})):S===t.Dirpy?(m.info(`Matched link source: Dirpy.`),a({url:l,path:u||`./dirpy.mp4`,cwd:d},_)):S===t.AnimeIdHentai?(m.info(`Matched link source: AnimeIdHentai.`),await r({url:l,path:u||`./animeidhentai.mp4`,cwd:d},{..._,...x})):S===t.KoreanPM?(m.info(`Matched link source: KoreanPM.`),await o({url:l,path:u||`./korean-pm.mp4`,cwd:d},_)):S===t.MissAV?(m.info(`Matched link source: MissAV.`),await s({url:l,path:u,cwd:d})):S===t.M3U8?(m.info(`Matched link source: m3u8.`),await g({url:l,path:u||`./m3u8-download.mp4`,cwd:d})):m.error(`Your link is not supported!`)}export{e as DEFAULT_OPTIONS,t as UrlType,n as __dirname,_ as defineConfig,r as downloadAnimeIdHentai,i as downloadBilibili,a as downloadDirpy,o as downloadKoreanPm,s as downloadMissav,S as fastDownload,x as fastLink,c as getAnimeIdHentaiLink,l as getBilibiliLink,u as getDirpyLink,d as getKoreanPmLink,f as getMissavLink,g 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={name:`fast-dirpy`,type:`module`,version:`0.3.2`,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.25.0`,"restore-cursor":`^5.1.0`,unconfig:`^7.3.3`},devDependencies:{"@antfu/eslint-config":`^6.0.0`,"@types/node":`^24.8.1`,deepmerge:`^4.3.1`,eslint:`^9.38.0`,taze:`^19.8.0`,tsdown:`^0.15.8`,tsx:`^4.20.6`,typescript:`^5.9.3`,vitest:`^3.2.4`}};const x={timeout:2e4},S=r(import.meta.url),C=n.dirname(S);var w=_(((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 T=o.withTag(`fast-dirpy`);function E(e){`CONSOLA_LEVEL`in a.env||(T.level=e?0:3)}var D=y(w(),1);async function O(e,t){let n=x,{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?(T.info(`Config file found: ${a[0]}`),(0,D.default)((0,D.default)(n,r),e)):(0,D.default)(n,e)}async function k(e){return await s.launch(e)}function A(e){return e[Math.floor(Math.random()*e.length)]}const j=[`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 M(){return A(j)}async function N(t,n=x){let{path:r,url:i}=t,{proxy:a,timeout:o}=await O(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":M()},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)}%`;T.info(i)}})).data.pipe(l),new Promise((e,t)=>{l.on(`finish`,e),l.on(`error`,t)})}async function P(n,r=x){let{url:i,cwd:a}=n,{proxy:o,timeout:s}=await O(r,a),c=o?.host===``?void 0:o,{data:l}=await e.get(i,{headers:{"User-Agent":M()},proxy:c,timeout:s}),u=t(l),d=``,f=u(`div.embed.rad2 > iframe`).attr();return f&&(d=f.src),d}async function F(e,t=x){let{url:n,cwd:r}=e,{proxy:i,puppeteer:a}=await O(t,r),o=i?.host===``?void 0:i,s=await P({url:n},{proxy:o}),{executablePath:c,headless:l}=a,u=await k({executablePath:c,headless:l,args:[`--proxy-server=http://${o?.host}:${i?.port}`]}),d=M(),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 I(e,t=x){let{path:n,url:r,cwd:i}=e;await N({url:await F({url:r},t),path:n,cwd:i},t)}function L(e){let t=e.match(/BV[a-zA-Z0-9]+/);return t?`https://bilibili-real-url.deno.dev/${t[0]}.mp4`:``}async function R(e){let{path:t,url:n}=e,r=L(n);r===``?console.error(`Extract direct link failed!`):await N({url:r,path:t||`./download.mp4`})}async function z(n,r=x){let{url:i,cwd:a}=n,{proxy:o,timeout:s}=await O(r,a),c=o?.host===``?void 0:o,{data:l}=await e.get(`https://dirpy.com/studio`,{params:{url:i},headers:{"User-Agent":M(),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 B(e,t=x){let{path:n,url:r,cwd:i}=e;await N({url:await z({url:r},t),path:n,cwd:i},t)}async function V(n,r=x){let{url:i,cwd:a}=n,{proxy:o,timeout:s}=await O(r,a),c=o?.host===``?void 0:o,{data:l}=await e.get(i,{headers:{"User-Agent":M()},proxy:c,timeout:s}),u=t(l),d=``,f=u(`meta[itemprop="contentURL"]`).attr();return f&&(d=f.content),d}async function H(e,t=x){let{path:n,url:r,cwd:i}=e;await N({url:await V({url:r},t),path:n,cwd:i},t)}function U(e){let{url:t,path:r}=e,i=r??n.resolve(C,`../m3u8-download.mp4`),a=u(t);a.pipe(l(i)),a.on(`progress`,(e,t,n)=>{T.info(`Segment: ${JSON.stringify(e)},
2
+ Total Segments: ${t},
3
+ downloaded: ${(n/1024/1024).toFixed(2)}MB Downloaded`),e.num>=t&&a.end()})}function W(e){return new Promise(t=>setTimeout(t,e*1e3))}async function G(e,t=x){let{url:n,cwd:r}=e,{proxy:i,puppeteer:a}=await O(t,r),o=i?.host===``?void 0:i,{executablePath:s,headless:c}=a,l=await k({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=M();await u.setUserAgent(d);try{let e=await u.goto(n,{waitUntil:`domcontentloaded`});e&&T.info(`http status: ${e.status()}`);let t=await u.title(),r=await u.content();if(T.info(`Page title: ${t}`),t.includes(`Just a moment`)||r.includes(`Checking your browser`)){T.info(`Cloudflare challenge detected, waiting for it to complete...`);try{T.info(`Waiting for page title to change...`),await u.waitForFunction(`document.title != 'Just a moment...'`,{timeout:3e4}),T.info(`Page title has changed`)}catch(e){T.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)){T.info(`Found possible verification button: ${e}`),await u.click(e),W(5);break}}catch(e){T.error(`Failed to click verification button: ${e}`)}}}let i=await u.title();T.info(`current page title: ${i}`),T.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)`);T.info(`Getting page content...`);let a=await u.content();return T.info(`Page content retrieved successfully.`),a}catch(e){T.error(`Error during scraping: ${e}`)}finally{T.info(`Closing browser`),await l.close()}}async function K(e){let t=e.match(/m3u8\|([a-f0-9|]+)\|com\|surrit\|https\|video/);return t?t[1].split(`|`).reverse().join(`-`):(T.error(`Failed to extract UUID from HTML.`),null)}function q(e){return e.split(`/`).pop()||(T.error(`Failed to extract movie ID from URL.`),null)}async function J(t){let{url:n,cwd:r}=t,i=await K(await G({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 Y(e){let{url:t,cwd:n,path:r}=e,i=q(t);await U({url:await J({url:t,cwd:n}),cwd:n,path:r||`${i}.mp4`})}let X=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}({});function Z(e){return e.includes(`bilibili`)||/BV[a-zA-Z0-9]+/.test(e)?X.Bilibili:e.includes(`animeidhentai`)?X.AnimeIdHentai:e.includes(`koreanpornmovie`)?X.KoreanPM:e.includes(`missav`)?X.MissAV:e.endsWith(`.m3u8`)?X.M3U8:X.Dirpy}export{x as DEFAULT_OPTIONS,X as UrlType,C as __dirname,I as downloadAnimeIdHentai,R as downloadBilibili,B as downloadDirpy,H as downloadKoreanPm,Y as downloadMissav,F as getAnimeIdHentaiLink,L as getBilibiliLink,z as getDirpyLink,V as getKoreanPmLink,J as getMissavLink,Z as judgeUrl,T as logger,b as package_default,U as remoteM3U8ToMP4,E as setSilent};
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.2",
5
5
  "description": "A simple library/CLI to download video from several websites.",
6
6
  "author": "Vincent-the-gamer",
7
7
  "license": "MIT",
@@ -42,17 +42,17 @@
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.25.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.0.0",
51
+ "@types/node": "^24.8.1",
52
52
  "deepmerge": "^4.3.1",
53
- "eslint": "^9.37.0",
54
- "taze": "^19.7.0",
55
- "tsdown": "^0.15.6",
53
+ "eslint": "^9.38.0",
54
+ "taze": "^19.8.0",
55
+ "tsdown": "^0.15.8",
56
56
  "tsx": "^4.20.6",
57
57
  "typescript": "^5.9.3",
58
58
  "vitest": "^3.2.4"
@@ -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};