diff options
Diffstat (limited to 'video_download.sh')
-rwxr-xr-x | video_download.sh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/video_download.sh b/video_download.sh new file mode 100755 index 0000000..ffbc4f7 --- /dev/null +++ b/video_download.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +VIDE_DIR="/var/tank/videos/Videos/" +PLAY_DIR="/var/tank/videos/Playlists/" + +PLAY_SUBS="$(ls -1 ${PLAY_DIR})" + +LAST_FILE="${XDG_CACHE_HOME:-$HOME/.cache}/video_download" + +get_videos () { + cd "$VIDE_DIR" + yt-dlp "$(cat url.txt)" + date '+%s' > "${LAST_FILE}.video.txt" +} + +get_playlists () { + cd "$PLAY_DIR" + ls -1 | while read subdir; do + cd "$PLAY_DIR/$subdir" + 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 |