fast-dirpy
v0.3.9
Published
A simple library/CLI to download video from several websites.
Downloads
172
Readme
A simple library/CLI to download youtube(etc.) videos.
Supported Websites
And .m3u8 videos.
[!IMPORTANT] From v0.3.0, .m3u8 downloader is no longer using ffmpeg. And it doesn't provide proxy settings, so, you need to use
export https_proxy=http://ip:portto set proxy manually in terminal.
You can use this userscript to extract .m3u8 sources from websites.
Installation
As a library
npm i fast-dirpy
# deno
deno add jsr:@vince-g/fast-dirpyAs a command line tool
npm i fast-dirpy -gAdditional: download ffmpeg
https://www.ffmpeg.org/download.html
Usage
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.
.m3u8source is handled byffmpeg.
# 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
# m3u8 sources
fast-dirpy download https\://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8 -p ./test.mp4
# mp4 sources
fast-dirpy download http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4 -p ./big_buck_bunny.mp4if 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.mp4For further CLI help:
fast-dirpy --helpUse as a library
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: { ... }
})
// Download `.m3u8` video
await remoteM3U8ToMP4({
url: 'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8',
path: './test.mp4',
})
// Download `.mp4` video
await downloadVideo({
url: 'http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4',
path: "./big_buck_bunny.mp4"
})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
