| .claude | ||
| .codex | ||
| .github | ||
| .vscode | ||
| app | ||
| ui | ||
| .dockerignore | ||
| .editorconfig | ||
| .gitignore | ||
| AGENTS.md | ||
| docker-compose.local.yml | ||
| docker-compose.yml | ||
| docker-entrypoint.sh | ||
| Dockerfile | ||
| LICENSE | ||
| mytube.af | ||
| pyproject.toml | ||
| README.md | ||
| screenshot.gif | ||
| uv.lock | ||
MyTube is a self-hosted web UI for yt-dlp, for downloading media from YouTube and dozens of other sites.
Key capabilities:
- Download videos, audio, captions, and thumbnails from a browser UI.
- Download playlists and channels, with configurable output and download options.
- Subscribe to channels and playlists, periodically check for new items, and queue new uploads automatically.
🐳 Run using Docker
docker run -d -p 8081:8081 -v /path/to/downloads:/downloads ghcr.io/tonyblur/mytube
🐳 Run using docker-compose
Save the following to docker-compose.yml in your working directory, update /path/to/downloads to your desired download location, then run docker-compose up -d:
services:
mytube:
image: ghcr.io/tonyblur/mytube
container_name: mytube
restart: unless-stopped
ports:
- "8081:8081"
volumes:
- /path/to/downloads:/downloads
environment:
- PUID=1000
- PGID=1000
- MAX_CONCURRENT_DOWNLOADS=3
A complete docker-compose.yml with all available configuration options is included in the repository. Use it as a template for advanced setups, or quickly start with:
docker-compose up -d
Logs can be viewed with:
docker-compose logs -f mytube
⚙️ Configuration via environment variables
Setting environment variables
Docker CLI: docker run -e PORT=9000 -e MAX_CONCURRENT_DOWNLOADS=5 ghcr.io/tonyblur/mytube
docker-compose: Add environment: section with key-value pairs (see docker-compose.yml for examples).
From .env file: docker-compose --env-file .env up or mount /path/to/.env:/app/.env:ro in volumes.
Available variables
You can also load variables from files:
- Docker CLI supports
--env-file /path/to/.env. - The container entrypoint auto-loads
/app/.envif present, and also loads a custom file whenENV_FILEpoints to it.
⬇️ Download Behavior
- MAX_CONCURRENT_DOWNLOADS: Max simultaneous downloads. Defaults to
3. - DELETE_FILE_ON_TRASHCAN: Delete files when trashed from UI. Defaults to
false. - DEFAULT_OPTION_PLAYLIST_ITEM_LIMIT: Max playlist items to download. Defaults to
0(no limit). - SUBSCRIPTION_DEFAULT_CHECK_INTERVAL: Minutes between subscription checks. Defaults to
60. - SUBSCRIPTION_SCAN_PLAYLIST_END: Max playlist/channel entries per check. Defaults to
50. - SUBSCRIPTION_MAX_SEEN_IDS: Cap on stored video IDs per subscription. Defaults to
50000. - CLEAR_COMPLETED_AFTER: Seconds until auto-removing completed downloads. Defaults to
0(disabled).
📁 Storage & Directories
- DOWNLOAD_DIR: Path to where the downloads will be saved. Defaults to
/downloadsin the Docker image, and.otherwise. - AUDIO_DOWNLOAD_DIR: Path to where audio-only downloads will be saved, if you wish to separate them from the video downloads. Defaults to the value of
DOWNLOAD_DIR. - CUSTOM_DIRS: Enable choosing custom subdirectories under DOWNLOAD_DIR or AUDIO_DOWNLOAD_DIR. Defaults to
true. - CREATE_CUSTOM_DIRS: Allow free-text directory names and create missing directories recursively. Defaults to
true. - CUSTOM_DIRS_EXCLUDE_REGEX: Regex for directories hidden from the dropdown. Empty disables exclusion. Defaults to
(^|/)[.@].*$. - DOWNLOAD_DIRS_INDEXABLE: If
true, the download directories (DOWNLOAD_DIR and AUDIO_DOWNLOAD_DIR) are indexable on the web server. Defaults tofalse. - STATE_DIR: Path to where mytube will store its persistent state files (
queue.json,pending.json,completed.json,subscriptions.json). Defaults to/downloads/.mytubein the Docker image, and.otherwise. - TEMP_DIR: Path for intermediary download files. Defaults to
/downloadsin the Docker image, and.otherwise.- Set this to an SSD or RAM filesystem (e.g.,
tmpfs) for better performance. - Note: Using a RAM filesystem may prevent downloads from being resumed.
- Set this to an SSD or RAM filesystem (e.g.,
- CHOWN_DIRS: If
false, skip chown for configured directories on container start. Defaults totrue.
📝 File Naming & yt-dlp
- OUTPUT_TEMPLATE: The template for the filenames of the downloaded videos, formatted according to this spec. Defaults to
%(title)s.%(ext)s. - OUTPUT_TEMPLATE_CHAPTER: The template for the filenames of the downloaded videos when split into chapters via postprocessors. Defaults to
%(title)s - %(section_number)s %(section_title)s.%(ext)s. - OUTPUT_TEMPLATE_PLAYLIST: The template for the filenames of the downloaded videos when downloaded as a playlist. Defaults to
%(playlist_title)s/%(title)s.%(ext)s. Set to empty to useOUTPUT_TEMPLATEinstead. - OUTPUT_TEMPLATE_CHANNEL: The template for the filenames of the downloaded videos when downloaded as a channel. Defaults to
%(channel)s/%(title)s.%(ext)s. Set to empty to useOUTPUT_TEMPLATEinstead. - YTDL_OPTIONS: Additional options to pass to yt-dlp, as a JSON object. See Configuring yt-dlp options for details, examples, and available options reference.
- YTDL_OPTIONS_FILE: Path to a JSON file containing yt-dlp options. Monitored and reloaded automatically on changes. See Configuring yt-dlp options.
- YTDL_OPTIONS_PRESETS: Named bundles of yt-dlp options, selectable per download in the UI. See Configuring yt-dlp options for format and examples.
- YTDL_OPTIONS_PRESETS_FILE: Path to a JSON file containing presets. Monitored and reloaded automatically on changes. See Configuring yt-dlp options.
- ALLOW_YTDL_OPTIONS_OVERRIDES: Whether to show a free-text field in the UI for per-download yt-dlp option overrides. Defaults to
false. See Configuring yt-dlp options for details and security considerations.
🌐 Web Server & URLs
- HOST: The host address the web server will bind to. Defaults to
0.0.0.0(all interfaces). - PORT: The port number the web server will listen on. Defaults to
8081. - URL_PREFIX: Base path for the web server (for use when hosting behind a reverse proxy). Defaults to
/. - PUBLIC_HOST_URL: Base URL for the download links shown in the UI for completed files. By default, mytube serves them under its own URL. If your download directory is accessible on another URL and you want the download links to be based there, use this variable to set it.
- PUBLIC_HOST_AUDIO_URL: Same as PUBLIC_HOST_URL but for audio downloads.
- HTTPS: Use
httpsinstead ofhttp(CERTFILE and KEYFILE required). Defaults tofalse. - CERTFILE: HTTPS certificate file path.
- KEYFILE: HTTPS key file path.
- CORS_ALLOWED_ORIGINS: Comma-separated origins allowed to call the API. Empty denies cross-origin requests;
*allows all. Required for browser extensions, bookmarklets, and similar tools. - ROBOTS_TXT: A path to a
robots.txtfile mounted in the container.
🏠 Basic Setup
- PUID: User under which mytube will run. Defaults to
1000(legacyUIDalso supported). - PGID: Group under which mytube will run. Defaults to
1000(legacyGIDalso supported). - UMASK: Umask value used by mytube. Defaults to
022. - DEFAULT_THEME: Default theme to use for the UI, can be set to
light,dark, orauto. Defaults toauto. - LOGLEVEL: Log level, can be set to
DEBUG,INFO,WARNING,ERROR,CRITICAL, orNONE. Defaults toINFO. - ENABLE_ACCESSLOG: Whether to enable access log. Defaults to
false. - PUBLIC_MODE: Hide other visitors' download history and disable subscriptions for shared/public instances. Defaults to
false.
🎛️ Configuring yt-dlp options
MyTube lets you customize how yt-dlp behaves at three levels, from broadest to most specific:
- Global options — apply to every download by default.
- Presets — named bundles of options that users can pick per download from the UI.
- Per-download overrides — free-form options entered in the UI for a single download.
When a download starts, these layers are combined in order. If the same option appears in more than one layer, the more specific one wins: per-download overrides beat presets, and presets beat global options.
In JSON presets and overrides, setting an option to null clears that option for that download (for example, "download_archive": null overrides a global archive path so the archive is not used). This follows yt-dlp’s usual meaning of None for that option.
Option format
yt-dlp options in MyTube are expressed as JSON objects. The keys are yt-dlp API option names, which roughly correspond to command-line flags with dashes replaced by underscores. For example, the command-line flag --write-subs becomes "writesubtitles": true in JSON.
Tip: Some command-line flags don't have a direct single-key equivalent — for instance,
--embed-thumbnailand--recode-videomust be expressed via"postprocessors". A full list of available API options can be found in the yt-dlp source, and this conversion script can help translate command-line flags to their API equivalents.
Global options
Global options form the baseline for every download. There are two ways to define them, and you can use either or both:
Inline via environment variable (YTDL_OPTIONS) — pass a JSON object directly:
environment:
- 'YTDL_OPTIONS={"writesubtitles": true, "subtitleslangs": ["en", "de"], "updatetime": false, "writethumbnail": true}'
Via a JSON file (YTDL_OPTIONS_FILE) — mount a file into the container and point to it:
volumes:
- /path/to/ytdl-options.json:/config/ytdl-options.json
environment:
- YTDL_OPTIONS_FILE=/config/ytdl-options.json
where ytdl-options.json contains:
{
"writesubtitles": true,
"subtitleslangs": ["en", "de"],
"updatetime": false,
"writethumbnail": true
}
The file is monitored for changes and reloaded automatically — no container restart needed. If you use both methods and they define the same key, the file takes precedence.
Presets
Presets let you define named bundles of options that appear in the web UI under Advanced Options as "Option Presets". Users can select one or more presets per download, making it easy to apply common option combinations without editing global settings.
Like global options, presets can be set inline or via a file:
YTDL_OPTIONS_PRESETS— a JSON object where each key is a preset name and its value is a set of yt-dlp options.YTDL_OPTIONS_PRESETS_FILE— path to a JSON file containing presets, monitored and reloaded on changes.
If both are used and they define a preset with the same name, the file's version takes precedence.
Example — a presets file defining three presets:
{
"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
}
}
This makes three presets available in the UI:
- sponsorblock — strips sponsor, self-promo, and interaction segments from videos.
- embed-subs — downloads English and German subtitles and embeds them into the video file.
- limit-rate — caps download speed to ~5 MB/s.
When multiple presets are selected for a download, they are applied in order. If two presets set the same option, the later one wins.
Per-download overrides
For one-off tweaks, MyTube can expose a free-text JSON field in the UI ("Custom yt-dlp Options") where users type yt-dlp options that apply only to that single download. This is disabled by default:
environment:
- ALLOW_YTDL_OPTIONS_OVERRIDES=true
Once enabled, the field appears under Advanced Options. Any options entered there take the highest priority, overriding both global options and selected presets.
⚠️ Security note: Enabling this allows arbitrary yt-dlp API options to be supplied by anyone with access to the UI. Depending on the options used, this may enable arbitrary command execution inside the container. Enable only in trusted environments.
How the layers combine
When a download starts, the final set of yt-dlp options is built in this order:
- Start with global options (
YTDL_OPTIONS/YTDL_OPTIONS_FILE). - Apply each selected preset in order (later presets overwrite earlier ones for conflicting keys).
- Apply any per-download overrides on top (overwrite everything else for conflicting keys).
MyTube always forces its own flat-extract behaviour during the initial metadata fetch (extract_flat, noplaylist, etc.); presets cannot override those keys for that phase.
Example: Suppose your global options set "writesubtitles": false, but you select a preset that sets "writesubtitles": true. Subtitles will be written for that download because the preset overrides the global setting. If you additionally enter {"writesubtitles": false} in the per-download overrides field, that value wins and subtitles will not be written.
Configuration cookbooks
The project's Wiki contains examples of useful configurations contributed by users of MyTube:
🍪 Using browser cookies
In case you need to use your browser's cookies with MyTube, for example to download restricted or private videos:
- Install in your browser an extension to extract cookies:
- Extract the cookies you need with the extension and save/export them as
cookies.txt. - In MyTube, open Advanced Options and use the Upload Cookies button to upload the file.
- After upload, the cookie indicator should show as active.
- Use Delete Cookies in the same section to remove uploaded cookies.
🔌 Browser extensions
Browser extensions allow right-clicking videos and sending them directly to MyTube. If you're on an HTTPS page, your MyTube instance must be behind an HTTPS reverse proxy (see below) for extensions to work.
Since browser extensions make requests from their own origin (chrome-extension://... or moz-extension://...), you must set CORS_ALLOWED_ORIGINS=* for them to work.
Chrome: contributed by Rpsl. You can install it from Google Chrome Webstore or use developer mode and install from sources.
Firefox: contributed by nanocortex. You can install it from Firefox Addons or get sources from here.
📱 iOS Shortcut
rithask created an iOS shortcut to send URLs to MyTube from Safari. Enter the mytube instance address when prompted which will be saved for later use. You can run the shortcut from Safari’s share menu. The shortcut can be downloaded from this iCloud link.
🔖 Bookmarklet
kushfest has created a Chrome bookmarklet for sending the currently open webpage to mytube. Please note that if you're on an HTTPS page, your MyTube instance must be configured with HTTPS as true in the environment, or be behind an HTTPS reverse proxy (see below) for the bookmarklet to work.
Since bookmarklets run in the context of the current page (e.g. youtube.com), the requests they make to mytube are cross-origin. You must add the origins of sites where you use the bookmarklet to the CORS_ALLOWED_ORIGINS environment variable, otherwise the browser will block the requests. For example, to use the bookmarklet on YouTube and Vimeo: CORS_ALLOWED_ORIGINS=https://www.youtube.com,https://www.vimeo.com.
GitHub doesn't allow embedding JavaScript as a link, so the bookmarklet has to be created manually by copying the following code to a new bookmark you create on your bookmarks bar. Change the hostname in the URL below to point to your MyTube instance.
javascript:!function(){xhr=new XMLHttpRequest();xhr.open("POST","https://mytube.domain.com/add");xhr.withCredentials=true;xhr.send(JSON.stringify({"url":document.location.href,"quality":"best"}));xhr.onload=function(){if(xhr.status==200){alert("Sent to mytube!")}else{alert("Send to mytube failed. Check the javascript console for clues.")}}}();
shoonya75 has contributed a Firefox version:
javascript:(function(){xhr=new XMLHttpRequest();xhr.open("POST","https://mytube.domain.com/add");xhr.send(JSON.stringify({"url":document.location.href,"quality":"best"}));xhr.onload=function(){if(xhr.status==200){alert("Sent to mytube!")}else{alert("Send to mytube failed. Check the javascript console for clues.")}}})();
The above bookmarklets use alert() for notifications. This variant shows a toast instead (Chrome — for Firefox, replace the !function(){...}() wrapper with (function(){...})()):
javascript:!function(){function notify(msg) {var sc = document.scrollingElement.scrollTop; var text = document.createElement('span');text.innerHTML=msg;var ts = text.style;ts.all = 'revert';ts.color = '#000';ts.fontFamily = 'Verdana, sans-serif';ts.fontSize = '15px';ts.backgroundColor = 'white';ts.padding = '15px';ts.border = '1px solid gainsboro';ts.boxShadow = '3px 3px 10px';ts.zIndex = '100';document.body.appendChild(text);ts.position = 'absolute'; ts.top = 50 + sc + 'px'; ts.left = (window.innerWidth / 2)-(text.offsetWidth / 2) + 'px'; setTimeout(function () { text.style.visibility = "hidden"; }, 1500);}xhr=new XMLHttpRequest();xhr.open("POST","https://mytube.domain.com/add");xhr.send(JSON.stringify({"url":document.location.href,"quality":"best"}));xhr.onload=function() { if(xhr.status==200){notify("Sent to mytube!")}else {notify("Send to mytube failed. Check the javascript console for clues.")}}}();
⚡ Raycast extension
dotvhs has created an extension for Raycast for adding videos to MyTube directly from Raycast.
🔒 HTTPS support, and running behind a reverse proxy
It's possible to configure MyTube to listen in HTTPS mode. docker-compose example:
services:
mytube:
image: ghcr.io/tonyblur/mytube
container_name: mytube
restart: unless-stopped
ports:
- "8081:8081"
volumes:
- /path/to/downloads:/downloads
- /path/to/ssl/crt:/ssl/crt.pem
- /path/to/ssl/key:/ssl/key.pem
environment:
- HTTPS=true
- CERTFILE=/ssl/crt.pem
- KEYFILE=/ssl/key.pem
MyTube can also run behind a reverse proxy for HTTPS termination or authentication. When serving under a subdirectory, set URL_PREFIX accordingly.
The linuxserver/swag image includes ready-made snippets for mytube in subfolder and subdomain modes, plus Authelia for authentication.
🌐 NGINX
location /mytube/ {
proxy_pass http://mytube:8081;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}
Note: the extra proxy_set_header directives are there to make WebSocket work.
🌐 Apache
Contributed by PIE-yt. Source here.
# For putting in your Apache sites site.conf
# Serves mytube under a /mytube/ subdir (http://yourdomain.com/mytube/)
<Location /mytube/>
ProxyPass http://localhost:8081/ retry=0 timeout=30
ProxyPassReverse http://localhost:8081/
</Location>
<Location /mytube/socket.io>
RewriteEngine On
RewriteCond %{QUERY_STRING} transport=websocket [NC]
RewriteRule /(.*) ws://localhost:8081/socket.io/$1 [P,L]
ProxyPass http://localhost:8081/socket.io retry=0 timeout=30
ProxyPassReverse http://localhost:8081/socket.io
</Location>
🌐 Caddy
The following example Caddyfile gets a reverse proxy going behind caddy.
example.com {
route /mytube/* {
uri strip_prefix mytube
reverse_proxy mytube:8081
}
}
🔄 Updating yt-dlp
MyTube is powered by yt-dlp, which requires frequent updates as video sites change their layouts. A nightly build automatically publishes a new Docker image whenever a new yt-dlp version is available, so keep your container up to date — watchtower works well for this.
🔧 Troubleshooting and submitting issues
MyTube is only a UI for yt-dlp. Issues with authentication, postprocessing, permissions, or YTDL_OPTIONS should be debugged with yt-dlp directly first — once working, import those options into MyTube. To test inside the container:
docker exec -ti mytube sh
cd /downloads
💡 Submitting feature requests
MyTube development relies on community contributions. If you need additional features, please submit a PR. Create an issue first to discuss the implementation — some PRs may not be accepted to reduce bloat. Feature requests without an accompanying PR are unlikely to be fulfilled.
🛠️ Building and running locally
Make sure you have Node.js 22+ and Python 3.13 installed.
# install Angular and build the UI
cd ui
curl -fsSL https://get.pnpm.io/install.sh | sh -
pnpm install
pnpm run build
# install python dependencies
cd ..
curl -LsSf https://astral.sh/uv/install.sh | sh
uv sync
# run
uv run python3 app/main.py
A Docker image can be built locally (it will build the UI too):
docker build -t mytube .
Note that if you're running the server in VSCode, your downloads will go to your user's Downloads folder (this is configured via the environment in .vscode/launch.json).
🍴 Fork note
This project is forked from alexta69/metube.
