w-dwload-dlp
Version:
A download tool for video.
524 lines (163 loc) • 8.66 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>Global - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
<script src="scripts/nav.js" defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav >
<h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#WDwloadDlp">WDwloadDlp</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">Global</h1>
<section>
<header>
<h2>
</h2>
</header>
<article>
<div class="container-overview">
<dl class="details">
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="WDwloadDlp"><span class="type-signature type-signature-async">(async) </span>WDwloadDlp<span class="signature">(url, fp, opt<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4>
<dl class="details">
<dt class="tag-description">Description:</dt>
<dd class="tag-description"><ul class="dummy"><li><p>下載video檔案,預設轉mp4,核心調用yt-dlp,只能用於Windows作業系統</p>
<p>yt-dlp: https://github.com/yt-dlp/yt-dlp</p></li></ul></dd>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="WDwloadDlp.mjs.html">WDwloadDlp.mjs</a>, <a href="WDwloadDlp.mjs.html#line90">line 90</a>
</li></ul></dd>
</dl>
<h5 class="h5-examples">Example</h5>
<pre class="prettyprint"><code>import fs from 'fs'
import WDwloadDlp from './src/WDwloadDlp.mjs'
async function test() {
//url
let url = `https://www.youtube.com/watch?v=jfXg5ZslKg4` //youtube mp4
// let url = `https://www.youtube.com/watch?v=fTk0mc946dk` //youtube webm
// let url = `https://www.youtube.com/watch?v=lKoCiBVKQaQ` //youtube webm
// let url = `https://www.bilibili.com/video/BV1JZ421x7q8/?spm_id_from=333.1073.channel.secondary_floor_video.click` //bilibili
// let url = `https://ooo.mp4` //直接提供mp4檔
//fp
let fp = './abc.mp4'
//funProg
let funProg = (prog, nn, na) => {
console.log('prog', `${prog.toFixed(2)}%`, nn, na)
}
//WDwloadDlp
await WDwloadDlp(url, fp, {
clean: true, //單一程序執行時, 事先清除之前暫存檔, 減少浪費硬碟空間
funProg,
})
//len
let len = fs.statSync(fp).size
console.log('len', len)
console.log('done:', fp)
}
test()
.catch((err) => {
console.log('catch', err)
})
// prog 0.49% 1 99
// prog 5.05% 4 99
// ...
// prog 99.00% 98 99
// prog 100.00% 99 99
// len 22394508
// done: ./abc.mp4</code></pre>
<h5 class="h5-parameters">Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>url</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>輸入網址字串,支援網站種類詳見yt-dlp</p></td>
</tr>
<tr>
<td class="name"><code>fp</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>輸入儲存video(*.mp4)檔案路徑字串</p></td>
</tr>
<tr>
<td class="name"><code>opt</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
<code>{}</code>
</td>
<td class="description last"><p>輸入設定物件,預設{}</p>
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>clean</code></td>
<td class="type">
<span class="param-type">Boolean</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
<code>false</code>
</td>
<td class="description last"><p>輸入預先清除暫存檔布林值,預設false</p></td>
</tr>
<tr>
<td class="name"><code>funProg</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
<code>null</code>
</td>
<td class="description last"><p>輸入回傳進度函數,傳入參數為prog代表進度百分比、nn代表當前已下載ts檔案數量、na代表全部須下載ts檔案數量,預設null</p></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<h5 class="h5-returns">Returns:</h5>
<div class="param-desc">
<p>回傳Promise,resolve回傳成功訊息,reject回傳錯誤訊息</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Thu May 21 2026 23:13:01 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/polyfill.js"></script>
<script src="scripts/linenumber.js"></script>
</body>
</html>