diff options
author | zachir <zachir@librem.one> | 2025-07-15 21:01:25 -0500 |
---|---|---|
committer | zachir <zachir@librem.one> | 2025-07-15 21:01:25 -0500 |
commit | 728bfc73a762bc53f843e3c7c15700ad3bf0a7f3 (patch) | |
tree | 82e49a3a51e2d6b9c45ee5758dacafa204c648e0 /video_download.sh | |
parent | 7078e8ec74cf1fc02b041134fd57caf40506ef78 (diff) |
Move some of my scripts out of bin to here
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 |