summaryrefslogtreecommitdiff
path: root/video_download.sh
diff options
context:
space:
mode:
authorzachir <zachir@librem.one>2025-07-15 21:01:25 -0500
committerzachir <zachir@librem.one>2025-07-15 21:01:25 -0500
commit728bfc73a762bc53f843e3c7c15700ad3bf0a7f3 (patch)
tree82e49a3a51e2d6b9c45ee5758dacafa204c648e0 /video_download.sh
parent7078e8ec74cf1fc02b041134fd57caf40506ef78 (diff)
Move some of my scripts out of bin to here
Diffstat (limited to 'video_download.sh')
-rwxr-xr-xvideo_download.sh30
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