-
Notifications
You must be signed in to change notification settings - Fork 80
7. Automate Downloading New Content Using Your Configs
Docker is the recommended way to use ytdl-sub
because it is easy to set up a cron job to automatically download new files. Setting this up is quite easy since we use the LinuxServer base image.
The first step is to ensure you have LinuxServer's Universal Cron mod enabled via the environment variable.
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 will tell your container to install and enable cron on start.
LinuxServer containers create the user abc
in the docker container and assigns it the respective PUID
and PGID
permissions to it. We want the cron job to run as this user to ensure downloaded files get these permissions instead of root permissions.
Log into the container as root
using:
docker exec -it ytdl-sub /bin/bash
and run the following command:
echo " 0 */6 * * * /config/run_cron" >> /config/crontabs/abc
This will write to the crontab file located at /config/crontabs/abc
. It is telling cron "Run /config/run_cron
every 6 hours". Feel free
to change the cron schedule to your liking.
Log back into the container as abc
using:
docker exec -u abc -it ytdl-sub /bin/bash
Create the script located at /config/run_cron
by running these commands:
echo '#!/bin/bash' > /config/run_cron
echo "echo 'Cron started, running ytdl-sub...'" >> /config/run_cron
echo "ytdl-sub --config=/config/config.yaml sub /config/subscriptions.yaml" >> /config/run_cron
chmod +x /config/run_cron
This will perform a download using config.yaml
and subscriptions.yaml
located in the /config
directory.
You can test that the script works by running:
/config/run_cron
Assuming you mounted the /tv_shows
directory, make sure ytdl-sub
is writing to that output directory.
You're done! You are now downloading your subscriptions every six hours.
<<-- Part VI: Modifying Your Config For Your Media Player -- Previous -- | -- Next -- Part VIII: Using Prebuilt Presets and our Example Presets -->>