36 lines
1.2 KiB
Bash
36 lines
1.2 KiB
Bash
|
#!/bin/bash
|
||
|
|
||
|
NOW=`date +"%Y-%m-%d %T"`
|
||
|
|
||
|
# move to NAS temp directory
|
||
|
cd "/mnt/media/tmp"
|
||
|
|
||
|
# count existing MP4 files
|
||
|
EXISTING=$(find ./ -maxdepth 1 -type f -name "*.mp4" -printf x | wc -c)
|
||
|
|
||
|
# download playlist updates
|
||
|
declare -a LABELS=("..." "..." "...")
|
||
|
declare -a LISTS=("Hash1" "Hash2" "Hash3")
|
||
|
length=${#LISTS[@]}
|
||
|
|
||
|
for (( i=0; i<${length}; i++ )); do
|
||
|
echo "Checking ${LABELS[$i]} (${LISTS[$i]}) for new videos..." >> downloads.log
|
||
|
yt-dlp "${LISTS[$i]}" --no-flat-playlist --force-download-archive --download-archive playlists.archive --throttled-rate 2M --embed-thumbnail --write-thumbnail --convert-thumbnails png -o "%(channel)s - %(title)s [%(upload_date)s] [%(id)s].%(ext)s" -f bv*[ext=mp4]+ba[ext=m4a]/b[ext=mp4]/bv*+ba/b >>ytdlp.log 2>&1
|
||
|
echo "Done checking ${LABELS[$i]} for new videos." >> downloads.log
|
||
|
done
|
||
|
echo "Finished running yt-dlp"
|
||
|
|
||
|
# convert any WEBP thumbs that didn't make it to PNG
|
||
|
for FILE in *.webp; do
|
||
|
if [ "$FILE" ]; then
|
||
|
break
|
||
|
fi
|
||
|
dwebp "$FILE" -o "${FILE%.*}".png;
|
||
|
done
|
||
|
|
||
|
# count new total of MP4 files and get difference
|
||
|
TOTAL=$(find ./ -maxdepth 1 -type f -name "*.mp4" -printf x | wc -c)
|
||
|
ADDED=$((TOTAL-EXISTING))
|
||
|
|
||
|
# write results to log
|
||
|
printf '[%s] %s videos downloaded\n' "$NOW" "$ADDED" >> downloads.log
|