fast-dirpy 0.3.7 → 0.3.9
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 +2 -1
- package/bin/fast-dirpy.js +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/{config-DH7qoWD4.d.mts → config-COA6iekn.d.mts} +3 -1
- package/dist/config.d.mts +1 -1
- package/dist/config.mjs +1 -1
- package/dist/index.d.mts +9 -5
- package/dist/index.mjs +1 -1
- package/dist/judgeUrl-C8A0NXW8.mjs +3 -0
- package/package.json +9 -9
- package/dist/config-D2bPo76p.mjs +0 -1
- package/dist/judgeUrl-CVv06PmX.mjs +0 -3
package/README.md
CHANGED
|
@@ -24,6 +24,7 @@ A simple library/CLI to download youtube(etc.) videos.
|
|
|
24
24
|
* [XVideos](https://www.xvideos.com/)
|
|
25
25
|
* [Missav](https://missav.ws/) (m3u8)
|
|
26
26
|
* [Hanime1.me](https://hanime1.me/)
|
|
27
|
+
* [wow.xxx](https://www.wow.xxx/)
|
|
27
28
|
</details>
|
|
28
29
|
|
|
29
30
|
And `.m3u8` videos.
|
|
@@ -169,7 +170,7 @@ await fastDownload({
|
|
|
169
170
|
url: '<url>',
|
|
170
171
|
path: './download.mp4',
|
|
171
172
|
cwd: '/path/to/external-config', // Optional: You can specify an external config file.
|
|
172
|
-
},
|
|
173
|
+
},
|
|
173
174
|
// options (Optional, can be omitted if you have a config file, this will overwrites your config file options.)
|
|
174
175
|
{
|
|
175
176
|
proxy: { ... }
|
package/bin/fast-dirpy.js
CHANGED
package/dist/cli.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{C as e,_ as t,a as n,b as r,c as i,f as a,g as o,h as s,i as c,l,m as u,n as d,p as f,r as p,s as m,t as h,u as g,v as _,w as v,y}from"./judgeUrl-C8A0NXW8.mjs";import{bold as b,dim as x}from"ansis";import{cac as S}from"cac";import C from"restore-cursor";const w=S(`fast-dirpy`),{version:T}=e;w.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,n)=>{let i=h(e),{proxyHost:a,proxyPort:o,config:u,silent:p,chromePath:m}=n,g=a?{proxy:{host:a,port:o}}:void 0,_=m?{puppeteer:{executablePath:m}}:void 0;if(r(!!p),y.info(`fast-dirpy ${x(`v${T}`)} : ${b(`Direct Link Getter`)}.`),i===d.AnimeIdHentai){y.info(`Matched link source: Animeidhentai.`);let n=await t({url:e,cwd:u},{...g,..._});console.log(n)}else if(i===d.KoreanPM){y.info(`Matched link source: KoreanPM.`);let t=await l({url:e,cwd:u},g);console.log(t)}else if(i===d.Wowxxx){y.info(`Matched link source: Wowxxx.`);let t=await c({url:e,cwd:u},g);console.log(t)}else if(i===d.Bilibili){if(y.info(`Matched link source: Bilibili.`),!e.includes(`bilibili.com`)){y.error(`Please provide a valid Bilibili URL.`);return}let t=await s(e);console.log(t)}else if(i===d.Dirpy){y.info(`Matched link source: Dirpy.`);let t=await f({url:e,cwd:u},g);console.log(t)}else y.error(`Your link is not supported!`)}),w.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(e,t)=>{let s=h(e),{proxyHost:c,proxyPort:l,path:f,config:v,silent:S,chromePath:C}=t,w=c?{proxy:{host:c,port:l}}:void 0,E=C?{puppeteer:{executablePath:C}}:void 0;r(!!S),y.info(`fast-dirpy ${x(`v${T}`)} : ${b(`Video Downloader`)}.`),s===d.Bilibili?(y.info(`Matched link source: Bilibili.`),await u({url:e,path:f})):s===d.Dirpy?(y.info(`Matched link source: Dirpy.`),a({url:e,path:f||`./dirpy.mp4`,cwd:v},w)):s===d.AnimeIdHentai?(y.info(`Matched link source: AnimeIdHentai.`),await o({url:e,path:f||`./animeidhentai.mp4`,cwd:v},{...w,...E})):s===d.KoreanPM?(y.info(`Matched link source: KoreanPM.`),await i({url:e,path:f||`./korean-pm.mp4`,cwd:v},w)):s===d.Wowxxx?(y.info(`Matched link source: Wowxxx.`),await p({url:e,path:f||`./wowxxx.mp4`,cwd:v},w)):s===d.MissAV?(y.info(`Matched link source: MissAV.`),await n({url:e,path:f,cwd:v})):s===d.Hanime?(y.info(`Matched link source: Hanime.`),await g({url:e,path:f,cwd:v})):s===d.M3U8?(y.info(`Matched link source: m3u8.`),await m({url:e,path:f||`./m3u8-download.mp4`,cwd:v})):s===d.MP4?(y.info(`Matched link source: mp4.`),await _({url:e,path:f,cwd:v})):y.error(`Your link is not supported!`)}),w.help(),w.version(v),w.parse(),C();export{};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
//#region src/types/index.d.ts
|
|
2
2
|
interface Options {
|
|
3
|
+
headers?: Record<string, any>;
|
|
3
4
|
proxy?: {
|
|
4
5
|
protocol?: string;
|
|
5
6
|
host: string;
|
|
@@ -31,7 +32,8 @@ declare enum UrlType {
|
|
|
31
32
|
KoreanPM = 4,
|
|
32
33
|
MissAV = 5,
|
|
33
34
|
Hanime = 6,
|
|
34
|
-
|
|
35
|
+
Wowxxx = 7,
|
|
36
|
+
MP4 = 8,
|
|
35
37
|
}
|
|
36
38
|
//#endregion
|
|
37
39
|
//#region src/config.d.ts
|
package/dist/config.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as defineConfig } from "./config-
|
|
1
|
+
import { t as defineConfig } from "./config-COA6iekn.mjs";
|
|
2
2
|
export { defineConfig };
|
package/dist/config.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function e(e){return e}export{e as defineConfig};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as Options, i as M3U8Params, n as DirectLinkParams, o as UrlType, r as DownloadParams, t as defineConfig } from "./config-
|
|
1
|
+
import { a as Options, i as M3U8Params, n as DirectLinkParams, o as UrlType, r as DownloadParams, t as defineConfig } from "./config-COA6iekn.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/constants.d.ts
|
|
4
4
|
declare const DEFAULT_OPTIONS: Options;
|
|
@@ -16,6 +16,10 @@ declare function downloadBilibili(params: DownloadParams): Promise<void>;
|
|
|
16
16
|
declare function getDirpyLink(params: DirectLinkParams, options?: Partial<Options>): Promise<string>;
|
|
17
17
|
declare function downloadDirpy(params: DownloadParams, options?: Partial<Options>): Promise<void>;
|
|
18
18
|
//#endregion
|
|
19
|
+
//#region src/core/hanime.d.ts
|
|
20
|
+
declare function getHanimeLink(params: DirectLinkParams, options?: Partial<Options>): Promise<Record<string, any>[]>;
|
|
21
|
+
declare function downloadHanime(params: DownloadParams, options?: Partial<Options>): Promise<void>;
|
|
22
|
+
//#endregion
|
|
19
23
|
//#region src/core/koreanpm.d.ts
|
|
20
24
|
declare function getKoreanPmLink(params: DirectLinkParams, options?: Partial<Options>): Promise<string>;
|
|
21
25
|
declare function downloadKoreanPm(params: DownloadParams, options?: Partial<Options>): Promise<void>;
|
|
@@ -30,9 +34,9 @@ declare function remoteM3U8ToMP4(params: Partial<M3U8Params>): void;
|
|
|
30
34
|
declare function getMissavLink(params: DirectLinkParams): Promise<string>;
|
|
31
35
|
declare function downloadMissav(params: Partial<DownloadParams>): Promise<void>;
|
|
32
36
|
//#endregion
|
|
33
|
-
//#region src/core/
|
|
34
|
-
declare function
|
|
35
|
-
declare function
|
|
37
|
+
//#region src/core/wowxxx.d.ts
|
|
38
|
+
declare function getWowxxxLink(params: DirectLinkParams, options?: Partial<Options>): Promise<Record<string, any>[]>;
|
|
39
|
+
declare function downloadWowxxx(params: DownloadParams, options?: Partial<Options>): Promise<void>;
|
|
36
40
|
//#endregion
|
|
37
41
|
//#region src/utils/downloader.d.ts
|
|
38
42
|
declare function downloadVideo(params: DownloadParams, options?: Partial<Options>): Promise<void>;
|
|
@@ -41,4 +45,4 @@ declare function downloadVideo(params: DownloadParams, options?: Partial<Options
|
|
|
41
45
|
declare function fastLink(params: DirectLinkParams, options?: Partial<Options>): Promise<string | Record<string, any>[]>;
|
|
42
46
|
declare function fastDownload(params: DownloadParams, options?: Partial<Options>): Promise<void>;
|
|
43
47
|
//#endregion
|
|
44
|
-
export { DEFAULT_OPTIONS, DirectLinkParams, DownloadParams, M3U8Params, Options, UrlType, __dirname, defineConfig, downloadAnimeIdHentai, downloadBilibili, downloadDirpy, downloadHanime, downloadKoreanPm, downloadMissav, downloadVideo, fastDownload, fastLink, getAnimeIdHentaiLink, getBilibiliLink, getDirpyLink, getHanimeLink, getKoreanPmLink, getMissavLink, remoteM3U8ToMP4 };
|
|
48
|
+
export { DEFAULT_OPTIONS, DirectLinkParams, DownloadParams, M3U8Params, Options, UrlType, __dirname, defineConfig, downloadAnimeIdHentai, downloadBilibili, downloadDirpy, downloadHanime, downloadKoreanPm, downloadMissav, downloadVideo, downloadWowxxx, fastDownload, fastLink, getAnimeIdHentaiLink, getBilibiliLink, getDirpyLink, getHanimeLink, getKoreanPmLink, getMissavLink, getWowxxxLink, remoteM3U8ToMP4 };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{C as e,S as t,_ as n,a as r,c as i,d as a,f as o,g as s,h as c,i as l,l as u,m as d,n as f,o as p,p as m,r as h,s as g,t as _,u as v,v as y,x as b,y as x}from"./judgeUrl-C8A0NXW8.mjs";import{defineConfig as S}from"./config.mjs";import{bold as C,dim as w}from"ansis";const{version:T}=e;async function E(e,t=b){let{url:r,cwd:i}=e,{proxy:o,puppeteer:s}=t,d=o||{},h=s||{},g=_(r);return x.info(`fast-dirpy ${w(`v${T}`)} : ${C(`Direct Link Getter`)}.`),g===f.Bilibili?(x.info(`Matched link source: Bilibili.`),r.includes(`bilibili.com`)?await c(r):(x.error(`Please provide a valid Bilibili URL.`),``)):g===f.AnimeIdHentai?(x.info(`Matched link source: Animeidhentai.`),await n({url:r,cwd:i},{...d,...h})):g===f.KoreanPM?(x.info(`Matched link source: KoreanPM.`),await u({url:r,cwd:i},d)):g===f.MissAV?(x.info(`Matched link source: MissAV.`),await p({url:r,cwd:i})):g===f.Hanime?(x.info(`Matched link source: Hanime.`),await a({url:r,cwd:i},d)):g===f.Wowxxx?(x.info(`Matched link source: Wowxxx.`),await l({url:r,cwd:i},d)):g===f.Dirpy?(x.info(`Matched link source: Dirpy.`),await m({url:r,cwd:i},d)):(x.error(`Your link is not supported!`),``)}async function D(e,t=b){let{url:n,path:a,cwd:c}=e,{proxy:l,puppeteer:u}=t,p=l||{},m=u||{},S=_(n);x.info(`fast-dirpy ${w(`v${T}`)} : ${C(`Video Downloader`)}.`),S===f.Bilibili?(x.info(`Matched link source: Bilibili.`),await d({url:n,path:a})):S===f.AnimeIdHentai?(x.info(`Matched link source: AnimeIdHentai.`),await s({url:n,path:a||`./animeidhentai.mp4`,cwd:c},{...p,...m})):S===f.KoreanPM?(x.info(`Matched link source: KoreanPM.`),await i({url:n,path:a||`./korean-pm.mp4`,cwd:c},p)):S===f.MissAV?(x.info(`Matched link source: MissAV.`),await r({url:n,path:a,cwd:c})):S===f.Hanime?(x.info(`Matched link source: Hanime.`),await v({url:n,path:a,cwd:c})):S===f.Wowxxx?(x.info(`Matched link source: Wowxxx.`),await h({url:n,path:a,cwd:c})):S===f.Dirpy?(x.info(`Matched link source: Dirpy.`),o({url:n,path:a||`./dirpy.mp4`,cwd:c},p)):S===f.MP4?(x.info(`Matched link source: mp4.`),await y({url:n,path:a||`./mp4-download.mp4`,cwd:c})):S===f.M3U8?(x.info(`Matched link source: m3u8.`),await g({url:n,path:a||`./m3u8-download.mp4`,cwd:c})):x.error(`Your link is not supported!`)}export{b as DEFAULT_OPTIONS,f as UrlType,t as __dirname,S as defineConfig,s as downloadAnimeIdHentai,d as downloadBilibili,o as downloadDirpy,v as downloadHanime,i as downloadKoreanPm,r as downloadMissav,y as downloadVideo,h as downloadWowxxx,D as fastDownload,E as fastLink,n as getAnimeIdHentaiLink,c as getBilibiliLink,m as getDirpyLink,a as getHanimeLink,u as getKoreanPmLink,p as getMissavLink,l as getWowxxxLink,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,{createWriteStream as c}from"node:fs";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,ee=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),_=(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},v=(e,t,n)=>(n=e==null?{}:d(h(e)),_(t||!e||!e.__esModule?f(n,`default`,{value:e,enumerable:!0}):n,e)),y=`0.3.9`,b={name:`fast-dirpy`,type:`module`,version:y,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.mjs`,module:`dist/index.mjs`,types:`dist/index.d.mts`,typesVersions:{"*":{".":[`./dist/index.d.mts`,`./dist/cli.d.mts`]}},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.2`,cac:`^6.7.14`,cheerio:`^1.1.2`,consola:`^3.4.2`,m3u8stream:`^0.8.6`,"puppeteer-core":`^24.34.0`,"restore-cursor":`^5.1.0`,unconfig:`^7.4.2`},devDependencies:{"@antfu/eslint-config":`^6.7.3`,"@types/node":`^25.0.3`,deepmerge:`^4.3.1`,eslint:`^9.39.2`,taze:`^19.9.2`,tsdown:`^0.18.3`,tsx:`^4.21.0`,typescript:`^5.9.3`,vitest:`^4.0.16`}};const x={timeout:2e4},S=r(import.meta.url),C=n.dirname(S);var w=ee(((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=v(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)}function k(e){return e[Math.floor(Math.random()*e.length)]}const A=[`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 j(){return k(A)}async function M(t,n=x){let{path:r,url:i}=t,{proxy:a,timeout:o}=await O(n),c=a?.host===``?void 0:a;if(i===``)return Promise.reject(`Extract direct link failed!`);let l=s.createWriteStream(r||`./download.mp4`);return(await e({url:i,headers:{"User-Agent":j(),...n.headers},method:`GET`,responseType:`stream`,proxy:c,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 N(e){return await l.launch(e)}async function te(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":j()},proxy:c,timeout:s}),u=t(l),d=``,f=u(`div.embed.rad2 > iframe`).attr();return f&&(d=f.src),d}async function P(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 te({url:n},{proxy:o}),{executablePath:c,headless:l}=a,u=await N({executablePath:c,headless:l,args:[`--proxy-server=http://${o?.host}:${i?.port}`]}),d=j(),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 F(e,t=x){let{path:n,url:r,cwd:i}=e;await M({url:await P({url:r},t),path:n,cwd:i},t)}function I(e){let t=e.match(/BV[a-zA-Z0-9]+/);return t?`https://bilibili-real-url.deno.dev/${t[0]}.mp4`:``}async function L(e){let{path:t,url:n}=e,r=I(n);r===``?console.error(`Extract direct link failed!`):await M({url:r,path:t||`./download.mp4`})}async function R(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":j(),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 z(e,t=x){let{path:n,url:r,cwd:i}=e;await M({url:await R({url:r},t),path:n,cwd:i},t)}function B(e,t){return Number(e.size)-Number(t.size)}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":j(),Referer:`https://hanime1.me/`},proxy:c,timeout:s}),u=t(l)(`source[type="video/mp4"]`);return Object.values(u).map(e=>e.attribs).filter(e=>e!=null).sort(B)}async function H(e,t=x){let{path:n,url:r,cwd:i}=e,a=await V({url:r},t);a.length>0&&T.success(`Successfully get video sources, size ${a[a.length-1].size} to be downloaded.`),await M({url:a[a.length-1].src,path:n,cwd:i},t)}async function U(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":j()},proxy:c,timeout:s}),u=t(l),d=``,f=u(`meta[itemprop="contentURL"]`).attr();return f&&(d=f.content),d}async function W(e,t=x){let{path:n,url:r,cwd:i}=e;await M({url:await U({url:r},t),path:n,cwd:i},t)}function G(e){let{url:t,path:r}=e,i=r??n.resolve(C,`../m3u8-download.mp4`),a=u(t);a.pipe(c(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 K(e){return new Promise(t=>setTimeout(t,e*1e3))}async function q(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 N({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=j();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),K(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 J(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 Y(e){return e.split(`/`).pop()||(T.error(`Failed to extract movie ID from URL.`),null)}async function X(t){let{url:n,cwd:r}=t,i=await J(await q({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 Z(e){let{url:t,cwd:n,path:r}=e,i=Y(t);await G({url:await X({url:t,cwd:n}),cwd:n,path:r||`${i}.mp4`})}function ne(e,t){let n=e.label.slice(0,e.label.length-1),r=t.label.slice(0,t.label.length-1);return Number(n)-Number(r)}async function Q(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":j(),Referer:`https://www.wow.xxx/`},proxy:c,timeout:s}),u=t(l)(`source[type="video/mp4"]`);return Object.values(u).map(e=>e.attribs).filter(e=>e!=null).sort(ne)}async function re(e,t=x){let{path:n,url:r,cwd:i}=e,a=await Q({url:r},t);a.length>0&&T.success(`Successfully get video sources, size ${a[a.length-1].label} to be downloaded.`),await M({url:a[a.length-1].src,path:n,cwd:i},t)}let $=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.Hanime=6]=`Hanime`,e[e.Wowxxx=7]=`Wowxxx`,e[e.MP4=8]=`MP4`,e}({});function ie(e){return e.includes(`bilibili`)||/BV[a-zA-Z0-9]+/.test(e)?$.Bilibili:e.includes(`animeidhentai`)?$.AnimeIdHentai:e.includes(`koreanpornmovie`)?$.KoreanPM:e.includes(`missav`)?$.MissAV:e.includes(`hanime1.me`)?$.Hanime:e.includes(`wow.xxx`)?$.Wowxxx:e.endsWith(`.m3u8`)||e.includes(`.m3u8`)&&!e.endsWith(`.mp4`)?$.M3U8:e.endsWith(`.mp4`)||e.includes(`.mp4`)&&!e.endsWith(`.m3u8`)?$.MP4:$.Dirpy}export{b as C,C as S,P as _,Z as a,E as b,W as c,V as d,z as f,F as g,I as h,Q as i,U as l,L as m,$ as n,X as o,R as p,re as r,G as s,ie as t,H as u,M as v,y as w,x,T 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.
|
|
4
|
+
"version": "0.3.9",
|
|
5
5
|
"description": "A simple library/CLI to download video from several websites.",
|
|
6
6
|
"author": "Vincent-the-gamer",
|
|
7
7
|
"license": "MIT",
|
|
@@ -42,20 +42,20 @@
|
|
|
42
42
|
"cheerio": "^1.1.2",
|
|
43
43
|
"consola": "^3.4.2",
|
|
44
44
|
"m3u8stream": "^0.8.6",
|
|
45
|
-
"puppeteer-core": "^24.
|
|
45
|
+
"puppeteer-core": "^24.34.0",
|
|
46
46
|
"restore-cursor": "^5.1.0",
|
|
47
|
-
"unconfig": "^7.4.
|
|
47
|
+
"unconfig": "^7.4.2"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@antfu/eslint-config": "^6.
|
|
51
|
-
"@types/node": "^
|
|
50
|
+
"@antfu/eslint-config": "^6.7.3",
|
|
51
|
+
"@types/node": "^25.0.3",
|
|
52
52
|
"deepmerge": "^4.3.1",
|
|
53
|
-
"eslint": "^9.39.
|
|
53
|
+
"eslint": "^9.39.2",
|
|
54
54
|
"taze": "^19.9.2",
|
|
55
|
-
"tsdown": "^0.
|
|
56
|
-
"tsx": "^4.
|
|
55
|
+
"tsdown": "^0.18.3",
|
|
56
|
+
"tsx": "^4.21.0",
|
|
57
57
|
"typescript": "^5.9.3",
|
|
58
|
-
"vitest": "^4.0.
|
|
58
|
+
"vitest": "^4.0.16"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"tsx": "tsx",
|
package/dist/config-D2bPo76p.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function e(e){return e}export{e as t};
|
|
@@ -1,3 +0,0 @@
|
|
|
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.7`,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.mjs`,module:`dist/index.mjs`,types:`dist/index.d.mts`,typesVersions:{"*":{".":[`./dist/index.d.mts`,`./dist/cli.d.mts`]}},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.2`,cac:`^6.7.14`,cheerio:`^1.1.2`,consola:`^3.4.2`,m3u8stream:`^0.8.6`,"puppeteer-core":`^24.31.0`,"restore-cursor":`^5.1.0`,unconfig:`^7.4.1`},devDependencies:{"@antfu/eslint-config":`^6.2.0`,"@types/node":`^24.10.1`,deepmerge:`^4.3.1`,eslint:`^9.39.1`,taze:`^19.9.2`,tsdown:`^0.16.8`,tsx:`^4.20.6`,typescript:`^5.9.3`,vitest:`^4.0.14`}};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||`./download.mp4`);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.Hanime=6]=`Hanime`,e[e.MP4=7]=`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(`hanime1.me`)?Z.Hanime:e.endsWith(`.m3u8`)||e.includes(`.m3u8`)&&!e.endsWith(`.mp4`)?Z.M3U8:e.endsWith(`.mp4`)||e.includes(`.mp4`)&&!e.endsWith(`.m3u8`)?Z.MP4:Z.Dirpy}export{b as S,E as _,W as a,w as b,V as c,R as d,L as f,k as g,N 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,D as v,x,S as y};
|