hello there

MeTube is a web GUI for youtube-dl, a command-line tool for downloading videos from YouTube and several hundred other sites.

My goal for this project was to set up automation for downloading YouTube videos directly to my Plex library.

The primary reason is that I can’t trust myself with YouTube Shorts. Once I open YouTube, I’m likely to spend at least a few minutes browsing through them. The simplest solution was to add friction to the process: I removed the YouTube app from all my devices and blocked the domain using my local DNS server.

This worked like a charm. Now, I only visit YouTube every few days to add content that interests me to my Plex library.

You can read more about setting up your own DNS server here.

Prerequisites

This guide assumes you have configured common environment variables like PUID, PGID, TZ, DOCKERSTORAGEDIR, and DOCKERCONFDIR as outlined in the TrashGuides.

Installation Steps

1. Create Required Directories

First, we need to create folders for MeTube’s configuration and downloads. One folder will store MeTube’s application data, and the other will be the destination for your downloaded videos.

SSH into your Synology NAS and execute the following commands:

The commands below assume you’ve followed the linked guide exactly. Adjust paths like /volume1/data/media/youtube and /volume1/docker/appdata/metube if your storage volume or directory structure differs.

  • Folder for video downloads (e.g., your Plex library):
    sudo mkdir -p /volume1/data/media/youtube
    
  • Folder for the MeTube container’s configuration:
    sudo mkdir -p /volume1/docker/appdata/metube
    

2. Set Permissions

Next, execute the following commands via SSH to configure the correct permissions for the newly created directories:

sudo chown -R docker:users /volume1/data/media/youtube /volume1/docker/appdata/metube
sudo chmod -R a=,a+rX,u+w,g+w /volume1/data/media/youtube /volume1/docker/appdata/metube

This command ensures the docker user has the necessary ownership and read/write permissions.

3. Configure Docker Compose

Append the following service configuration to your main docker-compose.yml file. If you followed the TrashGuides setup, this file is located at /volume1/docker/.

services:
  metube:
    container_name: metube
    image: ghcr.io/alexta69/metube:latest
    restart: unless-stopped
    logging:
      driver: json-file
      options:
        max-file: ${DOCKERLOGGING_MAXFILE:-10}
        max-size: ${DOCKERLOGGING_MAXSIZE:-200m}
    ports:
      - "8081:8081"
    environment:
      - PUID=${PUID}
      - PGID=${PGID}
      - TZ=${TZ}
      - UMASK=002
      - DOWNLOAD_DIR=/downloads
      - AUDIO_DOWNLOAD_DIR=/downloads
      - STATE_DIR=/config/.metube
      - TEMP_DIR=/downloads/.temp
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - ${DOCKERSTORAGEDIR}/media/youtube:/downloads
      - ${DOCKERCONFDIR}/metube:/config

Note on Environment Variables and Volumes:

  • ${DOCKERSTORAGEDIR}/media/youtube maps your Synology’s media download folder to the /downloads directory inside the container. Ensure DOCKERSTORAGEDIR is correctly defined (e.g., DOCKERSTORAGEDIR=/volume1/data).
  • ${DOCKERCONFDIR}/metube maps your Synology’s MeTube appdata folder to the /config directory inside the container. Ensure DOCKERCONFDIR is correctly defined (e.g., DOCKERCONFDIR=/volume1/docker/appdata).

4. Start the Container

Navigate to the directory containing your docker-compose.yml file via SSH and run the following command:

docker compose up -d metube

The container will now download the image and start. You can then access the MeTube web interface by navigating to http://<your-synology-ip>:8081 in a web browser.

Check out MeTube’s README for a handy iOS shortcut that allows you share video URLs without opening MeTube!

Troubleshooting

  • Port Conflicts: If port 8081 is already in use, change the host port in the ports section of your docker-compose.yml. For example, to use port 8082, modify the line to - "8082:8081".
  • Permission Issues: If MeTube reports that it cannot write to the download or config directories, double-check the permissions set in Step 2. Also, verify that the PUID and PGID environment variables correspond to a user with write access to those folders.
  • Container Logs: If the container fails to start or you encounter other issues, check its logs with this command:
    docker compose logs metube
    

Resources