Automating Downloads

Automating Downloads#

One of the key capabilities of ytdl-sub is how well it runs without user input, but to take advantage of this you must set up scheduling to execute the commands at some interval. How you set up this scheduling depends on which version of ytdl-sub you downloaded.

Guide for Docker and Unraid Containers

Guide for Linux

Guide for Windows

Docker and Unraid#

The script that will execute automatically is located at /config/ytdl-sub-configs/run-cron.

Access your container at http://localhost:8443/, then in the GUI terminal run these commands:

echo '#!/bin/bash' > /config/ytdl-sub-configs/run_cron
echo "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" >> /config/ytdl-sub-configs/run_cron
echo "echo 'Cron started, running ytdl-sub...'" >> /config/ytdl-sub-configs/run_cron
echo "cd /config/ytdl-sub-configs" >> /config/ytdl-sub-configs/run_cron
echo "ytdl-sub --config=config.yaml sub subscriptions.yaml" >> /config/ytdl-sub-configs/run_cron
chmod +x /config/ytdl-sub-configs/run_cron
chown abc:abc /config/ytdl-sub-configs/run_cron

You can test the newly created script by running:

/config/ytdl-sub-configs/run_cron

To create the cron definition, run the following command:

echo "# min   hour    day     month   weekday command" > /config/crontabs/abc
echo "  0     */6     *       *       *       /config/ytdl-sub-configs/run_cron" >> /config/crontabs/abc

This will run the script every 6 hours. To run every hour, change */6 to */1, or to run once a day, change the same value to the hour (in 24hr format) that you want it to run at. See the cron tab manpage for more options.

The first step is to ensure you have LinuxServer’s Universal Cron mod enabled via the environment variable. For the GUI image, this is already included (no need to add it).

services:
  ytdl-sub:
    image: ghcr.io/jmbannon/ytdl-sub:latest
    container_name: ytdl-sub
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=America/Los_Angeles
      - DOCKER_MODS=linuxserver/mods:universal-cron  # <-- Make sure you have this!
    volumes:
      # ensure directories have user permissions
      - </path/to/ytdl-sub/config>:/config
      - </path/to/ytdl-sub/tv_shows>:/tv_shows
    restart: unless-stopped

This line will tell your container to install and enable cron on start.

If you had to add this line, you will need to restart your container.

docker compose restart

The script that will execute automatically is located at /config/run-cron.

Access your container from the terminal by running:

docker exec -itu abc ytdl-sub /bin/bash

then in the terminal run these commands:

echo '#!/bin/bash' > /config/ytdl-sub-configs/run_cron
echo "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" >> /config/ytdl-sub-configs/run_cron
echo "echo 'Cron started, running ytdl-sub...'" >> /config/ytdl-sub-configs/run_cron
echo "cd /config/ytdl-sub-configs" >> /config/ytdl-sub-configs/run_cron
echo "ytdl-sub --config=config.yaml sub subscriptions.yaml" >> /config/ytdl-sub-configs/run_cron
chmod +x /config/ytdl-sub-configs/run_cron
chown abc:abc /config/ytdl-sub-configs/run_cron

You can test the newly created script by running:

/config/run_cron

To create the cron definition, run the following command:

echo "# min   hour    day     month   weekday command" > /config/crontabs/abc
echo "  0     */6     *       *       *       /config/run_cron" >> /config/crontabs/abc

This will run the script every 6 hours. To run every hour, change */6 to */1, or to run once a day, change the same value to the hour (in 24hr format) that you want it to run at. See the cron tab manpage for more options.

Linux#

crontab -e
0     */6     *       *       *       /config/run_cron

Windows#

To be tested (please contact code owner or join the discord server if you can test this out for us)

ytdl-sub.exe --config \path\to\config\config.yaml sub \path\to\config\subscriptions.yaml