Use Django setting to restrict find locations

This commit is contained in:
tcely 2025-04-01 00:11:03 -04:00 committed by GitHub
parent 993fdc2503
commit 2bf4af7920
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,14 +3,29 @@
playlist_id="${1}"
total_entries="${2}"
downloaded_entries="$( find / \
# select YOUTUBE_*DIR settings
# convert None to ''
# convert PosixPath('VALUE') to 'VALUE'
# assign a shell variable with the setting name and value
_awk_prog='$2 == "=" && $1 ~ /^YOUTUBE_/ && $1 ~ /DIR$/ {
sub(/^None$/, "'\'\''", $3);
r = sub(/^PosixPath[(]/, "", $3);
NF--;
if(r) {sub(/[)]$/, "", $NF);};
$3=$1 $2 $3; $1=$2=""; sub("^" OFS "+", "");
print;
}'
. <(python3 /app/manage.py diffsettings --output hash | awk "${_awk_prog}")
WHERE="${YOUTUBE_DL_CACHEDIR:-/dev/shm}"
downloaded_entries="$( find /dev/shm "${WHERE}" \
-path '*/infojson/playlist/postprocessor_*_temp\.info\.json' \
-name "postprocessor_[[]${playlist_id}[]]_*_${total_entries}_temp\.info\.json" \
-exec basename '{}' ';' | \
sed -e 's/^postprocessor_[[].*[]]_//;s/_temp.*\.json$//;' | \
cut -d '_' -f 1 )"
find / \
find /dev/shm "${WHERE}" \
-path '*/infojson/playlist/postprocessor_*_temp\.info\.json' \
-name "postprocessor_[[]${playlist_id}[]]_*_temp\.info\.json" \
-type f -delete