<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[MeTube自托管视频下载工具 - 基于yt-dlp的Web UI部署与配置教程]]></title><description><![CDATA[<h2>一、项目简介</h2>
<p dir="auto"><strong>MeTube</strong> 是一款自托管的 Web UI 工具，基于强大的 <code>yt-dlp</code> 引擎，支持从 YouTube 及<a href="https://github.com/yt-dlp/yt-dlp/blob/master/supportedsites.md" rel="nofollow ugc">数十个其他网站</a>下载视频、音频、字幕和缩略图。</p>
<p dir="auto"><strong>核心能力：</strong></p>
<ul>
<li>
<p dir="auto">通过浏览器界面下载视频、音频、字幕和缩略图</p>
</li>
<li>
<p dir="auto">下载播放列表和频道，支持自定义输出和下载选项</p>
</li>
<li>
<p dir="auto">订阅频道和播放列表，定期检查新内容并自动排队下载</p>
</li>
<li>
<p dir="auto"><strong>GitHub 地址</strong>：<a href="https://github.com/alexta69/metube" rel="nofollow ugc">https://github.com/alexta69/metube</a></p>
</li>
<li>
<p dir="auto"><strong>开源协议</strong>：AGPL-3.0</p>
</li>
<li>
<p dir="auto"><strong>Docker 镜像</strong>：<code>ghcr.io/alexta69/metube</code></p>
</li>
</ul>
<hr />
<h2>二、快速部署</h2>
<h3>2.1 使用 Docker 运行</h3>
<pre><code class="language-bash">docker run -d -p 8081:8081 -v /path/to/downloads:/downloads ghcr.io/alexta69/metube
</code></pre>
<h3>2.2 使用 Docker Compose 运行</h3>
<pre><code class="language-yaml">services:
  metube:
    image: ghcr.io/alexta69/metube
    container_name: metube
    restart: unless-stopped
    ports:
      - "8081:8081"
    volumes:
      - /path/to/downloads:/downloads
</code></pre>
<p dir="auto">部署完成后，访问 <code>http://your-server-ip:8081</code> 即可打开 MeTube 的 Web 界面。</p>
<hr />
<h2>三、环境变量配置</h2>
<p dir="auto">所有配置项均可通过 Docker 命令行的 <code>-e</code> 参数或 docker-compose 的 <code>environment:</code> 字段设置。</p>
<h3>3.1 下载行为</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>环境变量</th>
<th>说明</th>
<th>默认值</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>MAX_CONCURRENT_DOWNLOADS</code></td>
<td>最大同时下载数</td>
<td><code>3</code></td>
</tr>
<tr>
<td><code>DELETE_FILE_ON_TRASHCAN</code></td>
<td>在 UI 中删除时同时删除服务器文件</td>
<td><code>false</code></td>
</tr>
<tr>
<td><code>DEFAULT_OPTION_PLAYLIST_ITEM_LIMIT</code></td>
<td>播放列表最大下载项数</td>
<td><code>0</code>（无限制）</td>
</tr>
<tr>
<td><code>SUBSCRIPTION_DEFAULT_CHECK_INTERVAL</code></td>
<td>订阅自动检查间隔（分钟）</td>
<td><code>60</code></td>
</tr>
<tr>
<td><code>SUBSCRIPTION_SCAN_PLAYLIST_END</code></td>
<td>每次订阅检查最大获取条目数</td>
<td><code>50</code></td>
</tr>
<tr>
<td><code>SUBSCRIPTION_MAX_SEEN_IDS</code></td>
<td>每个订阅存储的视频 ID 上限</td>
<td><code>50000</code></td>
</tr>
<tr>
<td><code>CLEAR_COMPLETED_AFTER</code></td>
<td>完成后自动清除的秒数</td>
<td><code>0</code>（禁用）</td>
</tr>
</tbody>
</table>
<h3>3.2 存储与目录</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>环境变量</th>
<th>说明</th>
<th>默认值</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>DOWNLOAD_DIR</code></td>
<td>视频下载目录</td>
<td><code>/downloads</code></td>
</tr>
<tr>
<td><code>AUDIO_DOWNLOAD_DIR</code></td>
<td>音频专用下载目录</td>
<td>同 <code>DOWNLOAD_DIR</code></td>
</tr>
<tr>
<td><code>CUSTOM_DIRS</code></td>
<td>启用自定义下载子目录</td>
<td><code>true</code></td>
</tr>
<tr>
<td><code>CREATE_CUSTOM_DIRS</code></td>
<td>自动创建不存在的目录</td>
<td><code>true</code></td>
</tr>
<tr>
<td><code>STATE_DIR</code></td>
<td>状态文件存储目录</td>
<td><code>/downloads/.metube</code></td>
</tr>
<tr>
<td><code>TEMP_DIR</code></td>
<td>临时下载文件目录</td>
<td><code>/downloads</code></td>
</tr>
</tbody>
</table>
<blockquote>
<p dir="auto"><strong>提示</strong>：将 <code>TEMP_DIR</code> 设置为 SSD 或 RAM 文件系统（如 <code>tmpfs</code>）可提升性能，但使用 RAM 文件系统可能导致下载无法恢复。</p>
</blockquote>
<h3>3.3 文件命名与 yt-dlp</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>环境变量</th>
<th>说明</th>
<th>默认值</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>OUTPUT_TEMPLATE</code></td>
<td>视频文件命名模板</td>
<td><code>%(title)s.%(ext)s</code></td>
</tr>
<tr>
<td><code>OUTPUT_TEMPLATE_PLAYLIST</code></td>
<td>播放列表命名模板</td>
<td><code>%(playlist_title)s/%(title)s.%(ext)s</code></td>
</tr>
<tr>
<td><code>OUTPUT_TEMPLATE_CHANNEL</code></td>
<td>频道命名模板</td>
<td><code>%(channel)s/%(title)s.%(ext)s</code></td>
</tr>
<tr>
<td><code>YTDL_OPTIONS</code></td>
<td>额外的 yt-dlp 选项（JSON 格式）</td>
<td>-</td>
</tr>
<tr>
<td><code>YTDL_OPTIONS_FILE</code></td>
<td>yt-dlp 选项 JSON 文件路径</td>
<td>-</td>
</tr>
<tr>
<td><code>YTDL_OPTIONS_PRESETS</code></td>
<td>命名的 yt-dlp 选项预设</td>
<td>-</td>
</tr>
<tr>
<td><code>YTDL_OPTIONS_PRESETS_FILE</code></td>
<td>预设 JSON 文件路径</td>
<td>-</td>
</tr>
<tr>
<td><code>ALLOW_YTDL_OPTIONS_OVERRIDES</code></td>
<td>允许 UI 中自定义 yt-dlp 选项</td>
<td><code>false</code></td>
</tr>
</tbody>
</table>
<h3>3.4 Web 服务器与 URL</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>环境变量</th>
<th>说明</th>
<th>默认值</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>HOST</code></td>
<td>服务器绑定地址</td>
<td><code>0.0.0.0</code></td>
</tr>
<tr>
<td><code>PORT</code></td>
<td>服务器监听端口</td>
<td><code>8081</code></td>
</tr>
<tr>
<td><code>URL_PREFIX</code></td>
<td>反向代理基础路径</td>
<td><code>/</code></td>
</tr>
<tr>
<td><code>PUBLIC_HOST_URL</code></td>
<td>下载链接的基础 URL</td>
<td>-</td>
</tr>
<tr>
<td><code>HTTPS</code></td>
<td>启用 HTTPS</td>
<td><code>false</code></td>
</tr>
<tr>
<td><code>CORS_ALLOWED_ORIGINS</code></td>
<td>允许跨域请求的来源列表</td>
<td>空（拒绝所有）</td>
</tr>
</tbody>
</table>
<h3>3.5 基础设置</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>环境变量</th>
<th>说明</th>
<th>默认值</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>PUID</code> / <code>PGID</code></td>
<td>运行用户/组 ID</td>
<td><code>1000</code></td>
</tr>
<tr>
<td><code>DEFAULT_THEME</code></td>
<td>UI 主题（<code>light</code>/<code>dark</code>/<code>auto</code>）</td>
<td><code>auto</code></td>
</tr>
<tr>
<td><code>LOGLEVEL</code></td>
<td>日志级别</td>
<td><code>INFO</code></td>
</tr>
</tbody>
</table>
<hr />
<h2>四、yt-dlp 选项配置详解</h2>
<p dir="auto">MeTube 支持三个层级的 yt-dlp 选项配置，从全局到具体依次为：</p>
<ol>
<li><strong>全局选项</strong> — 适用于所有下载</li>
<li><strong>预设（Presets）</strong> — 命名的选项包，用户可在 UI 中按下载选择</li>
<li><strong>单次下载覆盖</strong> — 在 UI 中为单个下载输入的自由格式选项</li>
</ol>
<p dir="auto">当下载启动时，这些层级按顺序合并。如果同一选项出现在多个层级中，更具体的层级优先：单次覆盖 &gt; 预设 &gt; 全局选项。</p>
<h3>4.1 全局选项</h3>
<p dir="auto"><strong>方式一：通过环境变量内联</strong></p>
<pre><code class="language-yaml">environment:
  - 'YTDL_OPTIONS={"writesubtitles": true, "subtitleslangs": ["en", "de"], "updatetime": false, "writethumbnail": true}'
</code></pre>
<p dir="auto"><strong>方式二：通过 JSON 文件</strong></p>
<pre><code class="language-yaml">volumes:
  - /path/to/ytdl-options.json:/config/ytdl-options.json
environment:
  - YTDL_OPTIONS_FILE=/config/ytdl-options.json
</code></pre>
<p dir="auto">JSON 文件内容示例：</p>
<pre><code class="language-json">{
  "writesubtitles": true,
  "subtitleslangs": ["en", "de"],
  "updatetime": false,
  "writethumbnail": true
}
</code></pre>
<p dir="auto">文件会被自动监控，修改后无需重启容器。如果两种方式同时使用且定义了相同的键，<strong>文件优先</strong>。</p>
<h3>4.2 预设（Presets）</h3>
<p dir="auto">预设文件示例：</p>
<pre><code class="language-json">{
  "sponsorblock": {
    "postprocessors": [
      { "key": "SponsorBlock", "categories": ["sponsor", "selfpromo", "interaction"] },
      { "key": "ModifyChapters", "remove_sponsor_segments": ["sponsor", "selfpromo", "interaction"] }
    ]
  },
  "embed-subs": {
    "writesubtitles": true,
    "writeautomaticsub": true,
    "subtitleslangs": ["en", "de"],
    "postprocessors": [{ "key": "FFmpegEmbedSubtitle" }]
  },
  "limit-rate": {
    "ratelimit": 5000000
  }
}
</code></pre>
<p dir="auto">以上预设含义：</p>
<ul>
<li><strong>sponsorblock</strong> — 去除视频中的赞助商、自我推广和互动片段</li>
<li><strong>embed-subs</strong> — 下载英德字幕并嵌入视频文件</li>
<li><strong>limit-rate</strong> — 限制下载速度约 5 MB/s</li>
</ul>
<h3>4.3 单次下载覆盖</h3>
<p dir="auto">启用方式：</p>
<pre><code class="language-yaml">environment:
  - ALLOW_YTDL_OPTIONS_OVERRIDES=true
</code></pre>
<blockquote>
<p dir="auto"><img src="https://www.cnp.cc/assets/plugins/nodebb-plugin-emoji/emoji/android/26a0.png?v=5fb672a5cbf" class="not-responsive emoji emoji-android emoji--warning" style="height:23px;width:auto;vertical-align:middle" title="⚠" alt="⚠" />️ <strong>安全提示</strong>：启用此功能允许任何有 UI 访问权限的人提供任意 yt-dlp API 选项，根据使用的选项，可能允许在容器内执行任意命令。仅在受信任的环境中启用。</p>
</blockquote>
<hr />
<h2>五、浏览器 Cookie 使用</h2>
<p dir="auto">如需使用浏览器 Cookie 下载受限或私密视频：</p>
<ol>
<li>安装浏览器 Cookie 导出扩展：
<ul>
<li><a href="https://addons.mozilla.org/en-US/firefox/addon/export-cookies-txt/" rel="nofollow ugc">Firefox 扩展</a></li>
<li><a href="https://chrome.google.com/webstore/detail/get-cookiestxt-locally/cclelndahbckbenkjhflpdbgdldlbecc" rel="nofollow ugc">Chrome 扩展</a></li>
</ul>
</li>
<li>导出 Cookie 为 <code>cookies.txt</code> 文件</li>
<li>在 MeTube 中打开 <strong>Advanced Options</strong>，点击 <strong>Upload Cookies</strong> 上传文件</li>
<li>上传后 Cookie 指示器将显示为激活状态</li>
</ol>
<hr />
<h2>六、浏览器扩展</h2>
<p dir="auto">浏览器扩展支持右键点击视频直接发送到 MeTube。使用扩展时需设置 <code>CORS_ALLOWED_ORIGINS=*</code>。</p>
<ul>
<li><strong>Chrome</strong>：由 <a href="https://github.com/rpsl" rel="nofollow ugc">Rpsl</a> 贡献，可从 <a href="https://chrome.google.com/webstore/detail/metube-downloader/fbmkmdnlhacefjljljlbhkodfmfkijdh" rel="nofollow ugc">Chrome Web Store</a> 安装</li>
<li><strong>Firefox</strong>：由 <a href="https://github.com/nanocortex" rel="nofollow ugc">nanocortex</a> 贡献</li>
</ul>
<hr />
<h2>七、相关链接</h2>
<ul>
<li><strong>GitHub 仓库</strong>：<a href="https://github.com/alexta69/metube" rel="nofollow ugc">https://github.com/alexta69/metube</a></li>
<li><strong>Docker 镜像</strong>：<a href="https://github.com/alexta69/metube/pkgs/container/metube" rel="nofollow ugc">ghcr.io/alexta69/metube</a></li>
<li><strong>yt-dlp 项目</strong>：<a href="https://github.com/yt-dlp/yt-dlp" rel="nofollow ugc">https://github.com/yt-dlp/yt-dlp</a></li>
<li><strong>配置 Cookbook</strong>：<a href="https://github.com/alexta69/metube/wiki" rel="nofollow ugc">MeTube Wiki</a></li>
</ul>
]]></description><link>https://www.cnp.cc/topic/3/metube自托管视频下载工具-基于yt-dlp的web-ui部署与配置教程</link><generator>RSS for Node</generator><lastBuildDate>Sun, 31 May 2026 11:15:43 GMT</lastBuildDate><atom:link href="https://www.cnp.cc/topic/3.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 30 May 2026 18:35:10 GMT</pubDate><ttl>60</ttl></channel></rss>