fast-dirpy
v1.0.2
Published
A simple library/CLI to download video from several websites.
Readme
A simple library/CLI to download youtube(etc.) videos.
Supported Websites
[!WARNING] MissAV has a cloudflare challenge page which can't be bypassed using puppeteer/playwright, so you need to download the html page manually (no js and css needed, only html), then pass the local file path to extract m3u8 source.
fast-dirpy download --json '[{"url": "missav:/home/xxx/Downloads/xxx.html", "path": "./msav-test.mp4"}]'And this method is unstable, sometimes you'll get http 429.
[!WARNING] XHamster requests are mostly failed, so above v1.0.2, it also provides manual link extract method. download the html page(no js and css needed, only html), then pass the local file path to extract m3u8 source.
fast-dirpy download --json '[{"url": "xhamster:/home/xxx/Downloads/xxx.html", "path": "./xhamster-test.mp4"}]'
xhamster (m3u8, if error, manually download html page and )
And .m3u8 videos.
Agent Skill
fast-dirpy now has a skill: Find fast-dirpy skill
Installation
As a library
npm i fast-dirpy
# deno
deno add jsr:@vince-g/fast-dirpyAs a command line tool
npm i fast-dirpy -gUsage
Config file
[!IMPORTANT]
fast-dirpy.configcan befast-dirpy.config.['ts', 'mts', 'cts', 'js', 'mjs', 'cjs', 'json']
You can create a fast-dirpy.config file in your library root or same location in command line.
import { defineConfig } from 'fast-dirpy'
export default defineConfig({
proxy: {
protocol: 'http',
host: '127.0.0.1',
port: 7890,
},
timeout: 20000, // request timeout: 20s
puppeteer: {
// Path to Chrome. Please notice that you must give the inner unix executable file path in macOS.
// /Applications/Google Chrome.app will not work.
executablePath: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
headless: true
}
}Use in command line
[!IMPORTANT] Some website listed in Supported Websites requires Google Chrome installed for Puppeteer use. You have to use a config file or give parameter of puppeteer executable path.
Get Direct Link
# get video direct link
# Proxy:
# -H, --proxyHost: proxy host
# -P, --proxyPort: proxy port
# -c, --config: Specified external config file.
# e.g.: fast-dirpy get https://xxx -c ~/Downloads/fast-dirpy.config.json
# --chromePath: Path to your Google Chrome browser.
fast-dirpy get https://www.youtube.com/watch?v=6c28qWDMPBA -H 127.0.0.1 -P 7890
# Bilibili source doesn't need any proxy, so it's disabled by default.
fast-dirpy get https://www.bilibili.com/video/BV1TSPeeGE35if you have set your proxy config in fast-dirpy.config.ts, you can omit proxy parameters:
fast-dirpy get https\://www.youtube.com/watch\?v\=6c28qWDMPBADownload Video
[!IMPORTANT]
- Some website listed in Supported Websites requires Google Chrome installed for Puppeteer use. You have to use a config file or give parameter of puppeteer executable path.
- You can download multiple videos in parallel at version
v1.0.0and above.
# Proxy:
# -H, --proxyHost: proxy host.
# -P, --proxyPort: proxy port.
# -c, --config: Specified external config file.
# e.g.: fast-dirpy get https://xxx -c ~/Downloads/fast-dirpy.config.json
# --chromePath: Path to your Google Chrome browser.
fast-dirpy download --json '[{"url": "https://www.bilibili.com/video/BV1uEAWzuEHC","path": "./cmd-test.mp4"}]' -H 127.0.0.1 -P 7890
fast-dirpy download --jsonFile ./test/params.json -H 127.0.0.1 -P 7890if you have set your proxy config in fast-dirpy.config.ts, you can omit proxy parameters:
fast-dirpy download --jsonFile ./test/params.json
fast-dirpy download --json '[{"url": "https://www.bilibili.com/video/BV1uEAWzuEHC","path": "./cmd-test.mp4"}]'For further CLI help:
fast-dirpy --helpUse as a library
[!IMPORTANT] You can download multiple videos in parallel at version
v1.0.0and above.
import { fastLink, fastDownload, remoteM3U8ToMP4, downloadVideo } from 'fast-dirpy'
// get direct link, returns string or object(some cases)
const link = await fastLink(
{
url: '<url>',
cwd: '/path/to/external-config' // Optional: You can specify an external config file.
},
// options (Optional, can be omitted if you have a config file, this will overwrites your config file options.)
{
proxy: { ... }
}
)
// download video
await fastDownload([{
url: '<url>',
path: './download.mp4',
cwd: '/path/to/external-config', // Optional: You can specify an external config file.
}],
// options (Optional, can be omitted if you have a config file, this will overwrites your config file options.)
{
proxy: { ... }
})Test
To run single test case in Vitest, using:
pnpm run test src/test/xxx.test.ts:<line_number>License
MIT License © 2025-PRESENT Vincent-the-gamer
