#!/bin/sh VIDE_DIR="/var/tank/videos/Videos/" PLAY_DIR="/var/tank/videos/Playlists/" LAST_FILE="${XDG_CACHE_HOME:-$HOME/.cache}/video_download" get_videos () { cd "$VIDE_DIR" || exit 1 yt-dlp "$(cat url.txt)" date '+%s' > "${LAST_FILE}.video.txt" } get_playlists () { cd "$PLAY_DIR" || exit 1 find ./* -maxdepth 1 -type d | while read -r subdir; do cd "$PLAY_DIR/$subdir" || exit 1 yt-dlp "$(cat url.txt)" done } if [ ! -f "${LAST_FILE}.video.txt" ] || [ "$(tail -1 "${LAST_FILE}.video.txt")" -lt "$(find "${VIDE_DIR}url.txt" -printf '%Cs\n')" ]; then get_videos fi if [ ! -f "${LAST_FILE}.playlist.txt" ] || [ "$(tail -1 "${LAST_FILE}.playlist.txt")" -lt "$(find "${PLAY_DIR}" -name 'url.txt' -printf '%Cs\n' | sort -n | tail -1)" ]; then get_playlists fi