A simple library/CLI to download youtube(etc.) videos.
And .m3u8
videos(using ffmpeg
).
npm i fast-dirpy
# deno
deno add jsr:@vince-g/fast-dirpy
npm i fast-dirpy -g
[!IMPORTANT]
fast-dirpy.config
can 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
},
// binary file path of ffmpeg
// in Windows, use: "xx/ffmpeg.exe"
// if no ffmpeg path given, it will rely on your env variable.
ffmpeg: "./ffmpeg"
}
[!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.
.m3u8
source is handled byffmpeg
, please download it if you want to download.m3u8
videos.
# 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/BV1TSPeeGE35
if 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\=6c28qWDMPBA
[!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.
.m3u8
source is handled byffmpeg
, please download it if you want to download.m3u8
videos.
# get video direct link
# Path: --path, -p: Downloaded video save path.
#
# 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 https\://www.youtube.com/watch\?v\=6c28qWDMPBA -p ./test.mp4 -H 127.0.0.1 -P 7890
# Bilibili source doesn't need any proxy, so it's disabled by default.
fast-dirpy download https://www.bilibili.com/video/BV1TSPeeGE35 -p ./test.mp4
fast-dirpy download https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8 -p ./test.mp4
if you have set your proxy config in fast-dirpy.config.ts
, you can omit proxy parameters:
fast-dirpy download https\://www.youtube.com/watch\?v\=6c28qWDMPBA -p ./test.mp4
For further CLI help:
fast-dirpy --help
[!IMPORTANT] If a website is listed in Supported Websites, then
getXXXLink
is to get direct link anddownloadXXX
is to download video.
import { downloadDirpy, remoteM3U8ToMP4, getBilibiliLink, getDirpyLink } from 'fast-dirpy'
// get direct link
const link = await getDirpyLink(
{
url: '<url>',
cwd: '/path/to/external-config' // Optional: You can specify an external config file.
},
{
host: '127.0.0.1',
port: 7890
}
)
// get bilibili direct link
const link = await getBilibiliLink(
'<url>',
)
// download video
await downloadDirpy({
url: '<url>',
path: './download.mp4',
cwd: '/path/to/external-config', // Optional: You can specify an external config file.
proxy: {
host: '127.0.0.1',
port: 7890
}
})
// download bilibili video
await downloadBilibili({
url: '<url>',
path: './myvideo.mp4'
})
// download `.m3u8` video
await remoteM3U8ToMP4({
input: 'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8',
output: './test.mp4',
})
To run single test case in Vitest, using:
pnpm run test src/test/xxx.test.ts:<line_number>
MIT License © 2025-PRESENT Vincent-the-gamer