fast-dirpy 0.1.8 → 0.1.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 +34 -10
- package/dist/cli.d.ts +1 -2
- package/dist/cli.js +1 -1
- package/dist/config-BQe32DQp.d.ts +34 -0
- package/dist/config-ld9QlYHr.js +1 -0
- package/dist/config.d.ts +2 -1
- package/dist/config.js +1 -1
- package/dist/index.d.ts +27 -8
- package/dist/index.js +1 -1
- package/dist/types-DKWCe0OV.js +1 -0
- package/package.json +13 -13
- package/dist/chunk-HD53P4DN.js +0 -1
- package/dist/chunk-OYM7YQEE.js +0 -1
- package/dist/chunk-RM2BKSBF.js +0 -1
- package/dist/config-0EeRO6Y-.d.ts +0 -31
package/README.md
CHANGED
|
@@ -16,11 +16,7 @@ A simple library/CLI to download youtube(etc.) videos.
|
|
|
16
16
|
- [YouTube](https://www.youtube.com/)
|
|
17
17
|
- [Bilibili](https://www.bilibili.com/)
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
<summary>「Mystic」Websites</summary>
|
|
21
|
-
|
|
22
|
-
- Animeidhentai (Google Chrome required)
|
|
23
|
-
</details>
|
|
19
|
+
And `.m3u8` videos(using `ffmpeg`).
|
|
24
20
|
|
|
25
21
|
## Installation
|
|
26
22
|
|
|
@@ -60,15 +56,20 @@ export default defineConfig({
|
|
|
60
56
|
// Path to Chrome. Please notice that you must give the inner unix executable file path in macOS.
|
|
61
57
|
// /Applications/Google Chrome.app will not work.
|
|
62
58
|
executablePath: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
|
63
|
-
headless:
|
|
64
|
-
}
|
|
59
|
+
headless: true
|
|
60
|
+
},
|
|
61
|
+
// binary file path of ffmpeg
|
|
62
|
+
// in Windows, use: "xx/ffmpeg.exe"
|
|
63
|
+
// if no ffmpeg path given, it will rely on your env variable.
|
|
64
|
+
ffmpeg: "./ffmpeg"
|
|
65
65
|
}
|
|
66
66
|
```
|
|
67
67
|
|
|
68
68
|
### Use in command line
|
|
69
69
|
|
|
70
70
|
> [!IMPORTANT]
|
|
71
|
-
> Some website listed in [Supported Websites](#supported-websites) requires Google Chrome installed for Puppeteer use. You have to use a config file or give parameter of puppeteer executable path.
|
|
71
|
+
> 1. Some website listed in [Supported Websites](#supported-websites) requires Google Chrome installed for Puppeteer use. You have to use a config file or give parameter of puppeteer executable path.
|
|
72
|
+
> 2. `.m3u8` source is handled by `ffmpeg`, please download it if you want to download `.m3u8` videos.
|
|
72
73
|
|
|
73
74
|
#### Get Direct Link
|
|
74
75
|
|
|
@@ -95,7 +96,8 @@ fast-dirpy get https\://www.youtube.com/watch\?v\=6c28qWDMPBA
|
|
|
95
96
|
#### Download Video
|
|
96
97
|
|
|
97
98
|
> [!IMPORTANT]
|
|
98
|
-
> Some website listed in [Supported Websites](#supported-websites) requires Google Chrome installed for Puppeteer use. You have to use a config file or give parameter of puppeteer executable path.
|
|
99
|
+
> 1. Some website listed in [Supported Websites](#supported-websites) requires Google Chrome installed for Puppeteer use. You have to use a config file or give parameter of puppeteer executable path.
|
|
100
|
+
> 2. `.m3u8` source is handled by `ffmpeg`, please download it if you want to download `.m3u8` videos.
|
|
99
101
|
|
|
100
102
|
```shell
|
|
101
103
|
# get video direct link
|
|
@@ -113,6 +115,11 @@ fast-dirpy download https\://www.youtube.com/watch\?v\=6c28qWDMPBA -p ./test.mp4
|
|
|
113
115
|
fast-dirpy download https://www.bilibili.com/video/BV1TSPeeGE35 -p ./test.mp4
|
|
114
116
|
```
|
|
115
117
|
|
|
118
|
+
# m3u8 sources
|
|
119
|
+
```
|
|
120
|
+
fast-dirpy download https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8 -p ./test.mp4
|
|
121
|
+
```
|
|
122
|
+
|
|
116
123
|
if you have set your proxy config in `fast-dirpy.config.ts`, you can omit proxy parameters:
|
|
117
124
|
|
|
118
125
|
```shell
|
|
@@ -125,13 +132,15 @@ For further CLI help:
|
|
|
125
132
|
fast-dirpy --help
|
|
126
133
|
```
|
|
127
134
|
|
|
135
|
+
### Download and parse `.m3u8` files
|
|
136
|
+
|
|
128
137
|
### Use as a library
|
|
129
138
|
|
|
130
139
|
> [!IMPORTANT]
|
|
131
140
|
> If a website is listed in [Supported Websites](#supported-websites), then `getXXXLink` is to get direct link and `downloadXXX` is to download video.
|
|
132
141
|
|
|
133
142
|
```ts
|
|
134
|
-
import { downloadDirpy, getBilibiliLink, getDirpyLink } from 'fast-dirpy'
|
|
143
|
+
import { downloadDirpy, remoteM3U8ToMP4, getBilibiliLink, getDirpyLink } from 'fast-dirpy'
|
|
135
144
|
|
|
136
145
|
// get direct link
|
|
137
146
|
const link = await getDirpyLink(
|
|
@@ -166,6 +175,21 @@ await downloadBilibili({
|
|
|
166
175
|
url: '<url>',
|
|
167
176
|
path: './myvideo.mp4'
|
|
168
177
|
})
|
|
178
|
+
|
|
179
|
+
// download `.m3u8` video
|
|
180
|
+
await remoteM3U8ToMP4({
|
|
181
|
+
input: 'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8',
|
|
182
|
+
output: './test.mp4',
|
|
183
|
+
})
|
|
184
|
+
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Test
|
|
188
|
+
|
|
189
|
+
To run single test case in Vitest, using:
|
|
190
|
+
|
|
191
|
+
```shell
|
|
192
|
+
pnpm run test src/test/xxx.test.ts:<line_number>
|
|
169
193
|
```
|
|
170
194
|
|
|
171
195
|
## License
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { }
|
|
1
|
+
export { };
|
package/dist/cli.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{UrlType as e,downloadAnimeIdHentai as t,downloadBilibili as n,downloadDirpy as r,getAnimeIdHentaiLink as i,getBilibiliLink as a,getDirpyLink as o,logger as s,remoteM3U8ToMP4 as c,setSilent as l}from"./types-DKWCe0OV.js";import{bold as u,dim as d}from"ansis";import{cac as f}from"cac";import p from"restore-cursor";var m=`fast-dirpy`,h=`module`,g=`0.1.9`,_=`A simple library/CLI to download video using dirpy.com`,v=`Vincent-the-gamer`,y=`MIT`,b=`https://github.com/Vincent-the-gamer/fast-dirpy#readme`,x={type:`git`,url:`git+https://github.com/Vincent-the-gamer/fast-dirpy.git`},S={url:`https://github.com/Vincent-the-gamer/fast-dirpy/issues`},C=!1,w=`dist/index.js`,T=`dist/index.js`,E=`dist/index.d.ts`,D={"*":{".":[`./dist/index.d.ts`,`./dist/cli.d.ts`]}},O={"fast-dirpy":`bin/fast-dirpy.js`},k=[`dist`],A={tsx:`tsx`,build:`tsdown`,test:`vitest`,dep:`taze major`,"lint:fix":`eslint . --fix`,login:`pnpm login --registry https://registry.npmjs.com`},j={registry:`https://registry.npmjs.com`,access:`public`},M={ansis:`^4.0.0`,axios:`^1.9.0`,cac:`^6.7.14`,cheerio:`^1.0.0`,consola:`^3.4.2`,"puppeteer-core":`^24.9.0`,"restore-cursor":`^5.1.0`,unconfig:`^7.3.2`},N={"@antfu/eslint-config":`^4.13.2`,"@types/node":`^22.15.21`,deepmerge:`^4.3.1`,eslint:`^9.27.0`,taze:`^19.1.0`,tsdown:`^0.12.3`,tsx:`^4.19.4`,typescript:`^5.8.3`,vitest:`^3.1.4`},P={name:m,type:h,version:g,description:_,author:v,license:y,homepage:b,repository:x,bugs:S,sideEffects:C,main:w,module:T,types:E,typesVersions:D,bin:O,files:k,scripts:A,publishConfig:j,dependencies:M,devDependencies:N};function F(t){let n=/BV[a-zA-Z0-9]+/;return t.includes(`bilibili`)||n.test(t)?e.Bilibili:t.includes(`animeidhentai`)?e.AnimeIdHentai:t.endsWith(`.m3u8`)?e.M3U8:e.Dirpy}const I=f(`fast-dirpy`),{version:L}=P;I.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=F(t),{proxyHost:c,proxyPort:f,config:p,silent:m,chromePath:h}=n,g=c?{proxy:{host:c,port:f}}:void 0,_=h?{puppeteer:{executablePath:h}}:void 0;if(l(!!m),s.info(`fast-dirpy ${d(`v${L}`)} : ${u(`Direct Link Getter`)}.`),r===e.Bilibili){if(s.info(`Matched link source: Bilibili.`),!t.includes(`bilibili.com`)){s.error(`Please provide a valid Bilibili URL.`);return}let e=await a(t);console.log(e)}else if(r===e.Dirpy){s.info(`Matched link source: Dirpy.`);let e=await o({url:t,cwd:p},g);console.log(e)}else if(r===e.AnimeIdHentai){s.info(`Matched link source: Animeidhentai.`);let e=await i({url:t,cwd:p},{...g,..._});console.log(e)}else s.error(`Your link is not supported!`)}),I.command(`download <url>`,`download a video.`).option(`--path, -p <path>`,`Download destination path + filename. e.g. /xxx/example.mp4.`).option(`--proxyHost, -H <proxyHost>`,`Proxy host.`).option(`--proxyPort, -P <proxyPort>`,`Proxy port.`).option(`--config, -c <path>`,`Specify an external config file.`).option(`--silent`,`Suppress non-error logs`).option(`--chromePath`,`Path to your Google Chrome browser`).action(async(i,a)=>{let o=F(i),{proxyHost:f,proxyPort:p,path:m,config:h,silent:g,chromePath:_}=a,v=f?{proxy:{host:f,port:p}}:void 0,y=_?{puppeteer:{executablePath:_}}:void 0;l(!!g),s.info(`fast-dirpy ${d(`v${L}`)} : ${u(`Video Downloader`)}.`),o===e.Bilibili?(s.info(`Matched link source: Bilibili.`),await n({url:i,path:m})):o===e.Dirpy?(s.info(`Matched link source: Dirpy.`),r({url:i,path:m||`./dirpy.mp4`,cwd:h},v)):o===e.AnimeIdHentai?(s.info(`Matched link source: AnimeIdHentai.`),await t({url:i,path:m||`./animeidhentai.mp4`,cwd:h},{...v,...y})):o===e.M3U8?(s.info(`Matched link source: m3u8.`),await c({input:i,output:m||`./m3u8-download.mp4`,cwd:h})):s.error(`Your link is not supported!`)}),I.help(),I.version(P.version),I.parse(),p();
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//#region src/types/index.d.ts
|
|
2
|
+
interface Options {
|
|
3
|
+
proxy?: {
|
|
4
|
+
protocol?: string;
|
|
5
|
+
host: string;
|
|
6
|
+
port: number;
|
|
7
|
+
};
|
|
8
|
+
timeout?: number;
|
|
9
|
+
puppeteer?: {
|
|
10
|
+
executablePath: string;
|
|
11
|
+
headless?: boolean;
|
|
12
|
+
};
|
|
13
|
+
ffmpeg?: string;
|
|
14
|
+
}
|
|
15
|
+
interface DirectLinkParams {
|
|
16
|
+
url: string;
|
|
17
|
+
cwd?: string;
|
|
18
|
+
}
|
|
19
|
+
interface DownloadParams {
|
|
20
|
+
url: string;
|
|
21
|
+
path: string;
|
|
22
|
+
cwd?: string;
|
|
23
|
+
}
|
|
24
|
+
declare enum UrlType {
|
|
25
|
+
Bilibili = 0,
|
|
26
|
+
AnimeIdHentai = 1,
|
|
27
|
+
Dirpy = 2,
|
|
28
|
+
M3U8 = 3,
|
|
29
|
+
} //#endregion
|
|
30
|
+
//#region src/config.d.ts
|
|
31
|
+
declare function defineConfig(options: Options): Options;
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
export { DirectLinkParams, DownloadParams, Options, UrlType as UrlType$1, defineConfig as defineConfig$1 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){return e}export{e as defineConfig};
|
package/dist/config.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { defineConfig$1 as defineConfig } from "./config-BQe32DQp.js";
|
|
2
|
+
export { defineConfig };
|
package/dist/config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{defineConfig as e}from"./config-ld9QlYHr.js";export{e as defineConfig};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { U as UrlType, d as defineConfig } from './config-0EeRO6Y-.js';
|
|
1
|
+
import { DirectLinkParams, DownloadParams, Options, UrlType$1 as UrlType, defineConfig$1 as defineConfig } from "./config-BQe32DQp.js";
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
declare function
|
|
3
|
+
//#region src/core/animeidhentai.d.ts
|
|
4
|
+
declare function getAnimeIdHentaiLink(params: DirectLinkParams, options?: Partial<Options>): Promise<string>;
|
|
5
|
+
declare function downloadAnimeIdHentai(params: DownloadParams, options?: Partial<Options>): Promise<void>;
|
|
6
6
|
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/core/bilibili.d.ts
|
|
7
9
|
declare function getBilibiliLink(link: string): string;
|
|
8
10
|
declare function downloadBilibili(params: DownloadParams): Promise<void>;
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/core/dirpy.d.ts
|
|
14
|
+
declare function getDirpyLink(params: DirectLinkParams, options?: Partial<Options>): Promise<string>;
|
|
15
|
+
declare function downloadDirpy(params: DownloadParams, options?: Partial<Options>): Promise<void>;
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/core/m3u8.d.ts
|
|
19
|
+
interface M3U8ParserParams {
|
|
20
|
+
input: string;
|
|
21
|
+
output: string;
|
|
22
|
+
cwd?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Get remote m3u8 stream, then use ffmpeg to parse it to mp4.
|
|
26
|
+
*/
|
|
27
|
+
declare function remoteM3U8ToMP4(params: M3U8ParserParams, options?: Partial<Options>): Promise<void>;
|
|
14
28
|
|
|
15
|
-
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/core/index.d.ts
|
|
31
|
+
declare function downloadVideo(params: DownloadParams, options?: Partial<Options>): Promise<void>;
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
export { DirectLinkParams, DownloadParams, Options, UrlType, defineConfig, downloadAnimeIdHentai, downloadBilibili, downloadDirpy, downloadVideo, getAnimeIdHentaiLink, getBilibiliLink, getDirpyLink, remoteM3U8ToMP4 };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{UrlType as e,downloadAnimeIdHentai as t,downloadBilibili as n,downloadDirpy as r,downloadVideo as i,getAnimeIdHentaiLink as a,getBilibiliLink as o,getDirpyLink as s,remoteM3U8ToMP4 as c}from"./types-DKWCe0OV.js";import{defineConfig as l}from"./config-ld9QlYHr.js";export{e as UrlType,l as defineConfig,t as downloadAnimeIdHentai,n as downloadBilibili,r as downloadDirpy,i as downloadVideo,a as getAnimeIdHentaiLink,o as getBilibiliLink,s as getDirpyLink,c as remoteM3U8ToMP4};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"node:fs";import t from"axios";import{createConfigLoader as n}from"unconfig";import r from"node:process";import{consola as i}from"consola";import{load as a}from"cheerio";import o from"puppeteer-core";import{spawn as s}from"node:child_process";var c=Object.create,l=Object.defineProperty,u=Object.getOwnPropertyDescriptor,d=Object.getOwnPropertyNames,f=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty,m=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),h=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=d(t),a=0,o=i.length,s;a<o;a++)s=i[a],!p.call(e,s)&&s!==n&&l(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=u(t,s))||r.enumerable});return e},g=(e,t,n)=>(n=e==null?{}:c(f(e)),h(t||!e||!e.__esModule?l(n,`default`,{value:e,enumerable:!0}):n,e));const _={timeout:2e4};var v=m((exports,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]`||s(e)}var a=typeof Symbol==`function`&&Symbol.for,o=a?Symbol.for(`react.element`):60103;function s(e){return e.$$typeof===o}function c(e){return Array.isArray(e)?[]:{}}function l(e,t){return t.clone!==!1&&t.isMergeableObject(e)?_(c(e),e,t):e}function u(e,t,n){return e.concat(t).map(function(e){return l(e,n)})}function d(e,t){if(!t.customMerge)return _;var n=t.customMerge(e);return typeof n==`function`?n:_}function f(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[]}function p(e){return Object.keys(e).concat(f(e))}function m(e,t){try{return t in e}catch{return!1}}function h(e,t){return m(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))}function g(e,t,n){var r={};return n.isMergeableObject(e)&&p(e).forEach(function(t){r[t]=l(e[t],n)}),p(t).forEach(function(i){h(e,i)||(m(e,i)&&n.isMergeableObject(t[i])?r[i]=d(i,n)(e[i],t[i],n):r[i]=l(t[i],n))}),r}function _(e,t,r){r||={},r.arrayMerge=r.arrayMerge||u,r.isMergeableObject=r.isMergeableObject||n,r.cloneUnlessOtherwiseSpecified=l;var i=Array.isArray(t),a=Array.isArray(e),o=i===a;return o?i?r.arrayMerge(e,t,r):g(e,t,r):l(t,r)}_.all=function(e,t){if(!Array.isArray(e))throw Error(`first argument should be an array`);return e.reduce(function(e,n){return _(e,n,t)},{})};var v=_;t.exports=v});const y=i.withTag(`fast-dirpy`);function b(e){`CONSOLA_LEVEL`in r.env||(y.level=e?0:3)}var x=g(v(),1);async function S(e,t){let r=_,i=n({sources:[{files:[`fast-dirpy.config`],extensions:[`ts`,`mts`,`cts`,`js`,`mjs`,`cjs`,`json`]}],cwd:t||process.cwd(),merge:!1}),{config:a,sources:o}=await i.load();return o.length?(y.info(`Config file found: ${o[0]}`),(0,x.default)((0,x.default)(r,a),e)):(0,x.default)(r,e)}function C(e){let t=Math.floor(Math.random()*e.length);return e[t]}const w=[`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 T(){return C(w)}async function E(e){let t=await o.launch(e);return t}async function D(e,n=_){let{url:r,cwd:i}=e,{proxy:o,timeout:s}=await S(n,i),c=o?.host===``?void 0:o,{data:l}=await t.get(r,{headers:{"User-Agent":T()},proxy:c,timeout:s}),u=a(l),d=``,f=u(`div.embed.rad2 > iframe`).attr();return f&&(d=f.src),d}async function O(e,t=_){let{url:n,cwd:r}=e,{proxy:i,puppeteer:a}=await S(t,r),o=i?.host===``?void 0:i,s=await D({url:n},{proxy:o}),{executablePath:c,headless:l}=a,u=await E({executablePath:c,headless:l,args:[`--proxy-server=http://${o?.host}:${i?.port}`]}),d=T(),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 k(e,t=_){let{path:n,url:r,cwd:i}=e,a=await O({url:r},t);await F({url:a,path:n,cwd:i},t)}function A(e){let t=e.match(/BV[a-zA-Z0-9]+/);if(t){let e=`https://bilibili-real-url.deno.dev/${t[0]}.mp4`;return e}return``}async function j(e){let{path:t,url:n}=e,r=A(n);r===``?console.error(`Extract direct link failed!`):await F({url:r,path:t||`./download.mp4`})}async function M(e,n=_){let{url:r,cwd:i}=e,{proxy:o,timeout:s}=await S(n,i),c=o?.host===``?void 0:o,{data:l}=await t.get(`https://dirpy.com/studio`,{params:{url:r},headers:{"User-Agent":T(),Referer:`https://dirpy.com/studio?url=${r}`},proxy:c,timeout:s}),u=a(l),d=``,f=u(`#media-source`).attr();return f&&(d=f.src),d}async function N(e,t=_){let{path:n,url:r,cwd:i}=e,a=await M({url:r},t);await F({url:a,path:n,cwd:i},t)}async function P(e,t=_){let{cwd:n,input:r,output:i}=e,{ffmpeg:a,proxy:o}=await S(t,n),c=o?.host===``?void 0:o,l=s(a||`ffmpeg`,[`-http_proxy`,`${c?.protocol}://${c?.host}:${c?.port}`,`-i`,r,`-bsf:a`,`aac_adtstoasc`,`-vcodec`,`copy`,`-acodec`,`copy`,`-crf`,`50`,i],{stdio:`inherit`,shell:process.platform===`win32`});l.stdout?.on(`data`,e=>{y.info(e)}),l.stderr?.on(`data`,e=>{y.error(`FFmpeg stderr: ${e.toString()}`),process.exit(1)}),l.stdin?.on(`error`,e=>{y.error(e),process.exit(1)}),process.exit(0)}async function F(n,r=_){let{path:i,url:a}=n,{proxy:o,timeout:s}=await S(r),c=o?.host===``?void 0:o;if(a===``)return Promise.reject(`Extract direct link failed!`);let l=e.createWriteStream(i),u=await t({url:a,headers:{"User-Agent":T()},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)}%`;y.info(i)}});return u.data.pipe(l),new Promise((e,t)=>{l.on(`finish`,e),l.on(`error`,t)})}let I=function(e){return e[e.Bilibili=0]=`Bilibili`,e[e.AnimeIdHentai=1]=`AnimeIdHentai`,e[e.Dirpy=2]=`Dirpy`,e[e.M3U8=3]=`M3U8`,e}({});export{I as UrlType,k as downloadAnimeIdHentai,j as downloadBilibili,N as downloadDirpy,F as downloadVideo,O as getAnimeIdHentaiLink,A as getBilibiliLink,M as getDirpyLink,y as logger,P as remoteM3U8ToMP4,b as setSilent};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fast-dirpy",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.9",
|
|
5
5
|
"description": "A simple library/CLI to download video using dirpy.com",
|
|
6
6
|
"author": "Vincent-the-gamer",
|
|
7
7
|
"license": "MIT",
|
|
@@ -36,29 +36,29 @@
|
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"ansis": "^
|
|
40
|
-
"axios": "^1.
|
|
39
|
+
"ansis": "^4.0.0",
|
|
40
|
+
"axios": "^1.9.0",
|
|
41
41
|
"cac": "^6.7.14",
|
|
42
|
+
"cheerio": "^1.0.0",
|
|
42
43
|
"consola": "^3.4.2",
|
|
43
|
-
"
|
|
44
|
-
"puppeteer-core": "^24.7.1",
|
|
44
|
+
"puppeteer-core": "^24.9.0",
|
|
45
45
|
"restore-cursor": "^5.1.0",
|
|
46
46
|
"unconfig": "^7.3.2"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@antfu/eslint-config": "^4.
|
|
50
|
-
"@types/node": "^22.
|
|
49
|
+
"@antfu/eslint-config": "^4.13.2",
|
|
50
|
+
"@types/node": "^22.15.21",
|
|
51
51
|
"deepmerge": "^4.3.1",
|
|
52
|
-
"eslint": "^9.
|
|
53
|
-
"taze": "^19.0
|
|
54
|
-
"
|
|
55
|
-
"tsx": "^4.19.
|
|
52
|
+
"eslint": "^9.27.0",
|
|
53
|
+
"taze": "^19.1.0",
|
|
54
|
+
"tsdown": "^0.12.3",
|
|
55
|
+
"tsx": "^4.19.4",
|
|
56
56
|
"typescript": "^5.8.3",
|
|
57
|
-
"vitest": "^3.1.
|
|
57
|
+
"vitest": "^3.1.4"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"tsx": "tsx",
|
|
61
|
-
"build": "
|
|
61
|
+
"build": "tsdown",
|
|
62
62
|
"test": "vitest",
|
|
63
63
|
"dep": "taze major",
|
|
64
64
|
"lint:fix": "eslint . --fix",
|
package/dist/chunk-HD53P4DN.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var n=Object.create;var i=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var c=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty;var l=(t,e)=>()=>(t&&(e=t(t=0)),e);var d=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var s=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let m of p(e))!f.call(t,m)&&m!==o&&i(t,m,{get:()=>e[m],enumerable:!(r=a(e,m))||r.enumerable});return t};var g=(t,e,o)=>(o=t!=null?n(c(t)):{},s(e||!t||!t.__esModule?i(o,"default",{value:t,enumerable:!0}):o,t));var _=l(()=>{"use strict"});export{d as a,g as b,_ as c};
|
package/dist/chunk-OYM7YQEE.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as i}from"./chunk-HD53P4DN.js";i();function o(p){return p}export{o as a};
|
package/dist/chunk-RM2BKSBF.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as T,b as C,c as i}from"./chunk-HD53P4DN.js";var E=T((Pr,L)=>{"use strict";i();var F=function(e){return N(e)&&!U(e)};function N(r){return!!r&&typeof r=="object"}function U(r){var e=Object.prototype.toString.call(r);return e==="[object RegExp]"||e==="[object Date]"||z(r)}var V=typeof Symbol=="function"&&Symbol.for,W=V?Symbol.for("react.element"):60103;function z(r){return r.$$typeof===W}function K(r){return Array.isArray(r)?[]:{}}function x(r,e){return e.clone!==!1&&e.isMergeableObject(r)?b(K(r),r,e):r}function B(r,e,t){return r.concat(e).map(function(n){return x(n,t)})}function G(r,e){if(!e.customMerge)return b;var t=e.customMerge(r);return typeof t=="function"?t:b}function H(r){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(r).filter(function(e){return Object.propertyIsEnumerable.call(r,e)}):[]}function v(r){return Object.keys(r).concat(H(r))}function S(r,e){try{return e in r}catch{return!1}}function Y(r,e){return S(r,e)&&!(Object.hasOwnProperty.call(r,e)&&Object.propertyIsEnumerable.call(r,e))}function X(r,e,t){var n={};return t.isMergeableObject(r)&&v(r).forEach(function(o){n[o]=x(r[o],t)}),v(e).forEach(function(o){Y(r,o)||(S(r,o)&&t.isMergeableObject(e[o])?n[o]=G(o,t)(r[o],e[o],t):n[o]=x(e[o],t))}),n}function b(r,e,t){t=t||{},t.arrayMerge=t.arrayMerge||B,t.isMergeableObject=t.isMergeableObject||F,t.cloneUnlessOtherwiseSpecified=x;var n=Array.isArray(e),o=Array.isArray(r),a=n===o;return a?n?t.arrayMerge(r,e,t):X(r,e,t):x(e,t)}b.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(n,o){return b(n,o,t)},{})};var J=b;L.exports=J});i();import R from"node:process";import{consola as $}from"consola";var P=$.withTag("fast-dirpy");function yr(r){"CONSOLA_LEVEL"in R.env||(P.level=r?0:3)}i();import sr from"axios";import cr from"jsdom";i();var l={timeout:2e4};i();var D=C(E(),1);import{createConfigLoader as q}from"unconfig";async function y(r,e){let t=l,n=q({sources:[{files:["fast-dirpy.config"],extensions:["ts","mts","cts","js","mjs","cjs","json"]}],cwd:e||process.cwd(),merge:!1}),{config:o,sources:a}=await n.load();return a.length?(P.info(`Config file found: ${a[0]}`),(0,D.default)((0,D.default)(t,o),r)):(0,D.default)(t,r)}i();import Z from"puppeteer-core";async function I(r){return await Z.launch(r)}i();i();function _(r){let e=Math.floor(Math.random()*r.length);return r[e]}var Q=["Mozilla/5.0 (X11; U; Linux x86_64; zh-CN; rv:1.9.2.10) Gecko/20100922 Ubuntu/10.10 (maverick) Firefox/3.6.10","Mozilla/5.0 (Windows NT 6.1; rv,2.0.1) Gecko/20100101 Firefox/4.0.1","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36","Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36","Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Ubuntu/11.10 Chromium/27.0.1453.93 Chrome/27.0.1453.93 Safari/537.36"];function w(){return _(Q)}i();import ir from"node:fs";import ar from"axios";i();function rr(r){let e=r.match(/BV[a-zA-Z0-9]+/);return e?`https://bilibili-real-url.deno.dev/${e[0]}.mp4`:""}async function Rr(r){let{path:e,url:t}=r,n=rr(t);n!==""?await O({url:n,path:e||"./download.mp4"}):console.error("Extract direct link failed!")}i();import er from"axios";import tr from"jsdom";var{JSDOM:or}=tr;async function nr(r,e=l){let{url:t,cwd:n}=r,{proxy:o,timeout:a}=await y(e,n),u=o?.host!==""?o:void 0,{data:f}=await er.get("https://dirpy.com/studio",{params:{url:t},headers:{"User-Agent":w(),Referer:`https://dirpy.com/studio?url=${t}`},proxy:u,timeout:a}),{window:g}=new or(f),c="",s=g.document.getElementById("media-source");return s&&(c=s.src),c}async function Br(r,e=l){let{path:t,url:n,cwd:o}=r,a=await nr({url:n},e);await O({url:a,path:t,cwd:o},e)}async function O(r,e=l){let{path:t,url:n}=r,{proxy:o,timeout:a}=await y(e),u=o?.host!==""?o:void 0;if(n==="")return Promise.reject("Extract direct link failed!");let f=ir.createWriteStream(t);return(await ar({url:n,headers:{"User-Agent":w()},method:"GET",responseType:"stream",proxy:u,timeout:a,onDownloadProgress:c=>{let{loaded:s,total:h,progress:d}=c,A=`loaded:${s} total: ${h} progress: ${(d*100).toFixed(2)}%`;P.info(A)}})).data.pipe(f),new Promise((c,s)=>{f.on("finish",c),f.on("error",s)})}var{JSDOM:pr}=cr;async function mr(r,e=l){let{url:t,cwd:n}=r,{proxy:o,timeout:a}=await y(e,n),u=o?.host!==""?o:void 0,{data:f}=await sr.get(t,{headers:{"User-Agent":w()},proxy:u,timeout:a}),{window:g}=new pr(f),c="",s=g.document.querySelector("div.embed.rad2 > iframe");return s&&(c=s.src),c}async function lr(r,e=l){let{url:t,cwd:n}=r,{proxy:o,puppeteer:a}=await y(e,n),u=o?.host!==""?o:void 0,f=await mr({url:t},{proxy:u}),{executablePath:g,headless:c}=a,s=await I({executablePath:g,headless:c,args:[`--proxy-server=http://${u?.host}:${o?.port}`]}),h=w(),d=await s.newPage();await d.setUserAgent(h),await d.goto(f),await d.waitForSelector("div.play.p-pulse"),await d.click("div.play.p-pulse"),await d.waitForSelector("div.frame > iframe");let A=await d.$eval("div.frame > iframe",M=>M.src),j=await s.newPage();await j.goto(`${A}`),await j.waitForSelector("video.jw-video.jw-reset");let k=await j.$eval("video.jw-video.jw-reset",M=>M.src);return await s.close(),k}async function fe(r,e=l){let{path:t,url:n,cwd:o}=r,a=await lr({url:n},e);await O({url:a,path:t,cwd:o},e)}i();var fr=(o=>(o[o.Bilibili=0]="Bilibili",o[o.Dirpy=1]="Dirpy",o[o.AnimeIdHentai=2]="AnimeIdHentai",o[o.Others=3]="Others",o))(fr||{});export{P as a,yr as b,lr as c,fe as d,rr as e,Rr as f,nr as g,Br as h,O as i,fr as j};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
interface DirpyOptions {
|
|
2
|
-
proxy?: {
|
|
3
|
-
protocol?: string;
|
|
4
|
-
host: string;
|
|
5
|
-
port: number;
|
|
6
|
-
};
|
|
7
|
-
timeout?: number;
|
|
8
|
-
puppeteer?: {
|
|
9
|
-
executablePath: string;
|
|
10
|
-
headless?: boolean;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
interface DirectLinkParams {
|
|
14
|
-
url: string;
|
|
15
|
-
cwd?: string;
|
|
16
|
-
}
|
|
17
|
-
interface DownloadParams {
|
|
18
|
-
url: string;
|
|
19
|
-
path: string;
|
|
20
|
-
cwd?: string;
|
|
21
|
-
}
|
|
22
|
-
declare enum UrlType {
|
|
23
|
-
Bilibili = 0,
|
|
24
|
-
Dirpy = 1,
|
|
25
|
-
AnimeIdHentai = 2,
|
|
26
|
-
Others = 3
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
declare function defineConfig(options: DirpyOptions): DirpyOptions;
|
|
30
|
-
|
|
31
|
-
export { type DirectLinkParams as D, UrlType as U, type DirpyOptions as a, type DownloadParams as b, defineConfig as d };
|