Add --cam/--season/--mvt filters to make-finals.sh
Allows processing a single movement without waiting for the full backup scan, e.g.: ./make-finals.sh ~/drives/data2-main --cam north --season Autumn --mvt 1 Filters are applied as soon as the relevant variable is known (cam before calling season_info.py, season/mvt after) so skipped files cost almost nothing. https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
This commit is contained in:
+17
-5
@@ -24,18 +24,24 @@ export TIMEZONE
|
|||||||
|
|
||||||
BACKUP_ROOT=""
|
BACKUP_ROOT=""
|
||||||
DRY_RUN=false
|
DRY_RUN=false
|
||||||
|
FILTER_CAM=""
|
||||||
|
FILTER_SEASON=""
|
||||||
|
FILTER_MVT=""
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--dry-run) DRY_RUN=true; shift ;;
|
--dry-run) DRY_RUN=true; shift ;;
|
||||||
-*) echo "Unknown option: $1"; exit 1 ;;
|
--cam) FILTER_CAM="$2"; shift 2 ;;
|
||||||
*) BACKUP_ROOT="$1"; shift ;;
|
--season) FILTER_SEASON="$2"; shift 2 ;;
|
||||||
|
--mvt) FILTER_MVT="$2"; shift 2 ;;
|
||||||
|
-*) echo "Unknown option: $1"; exit 1 ;;
|
||||||
|
*) BACKUP_ROOT="$1"; shift ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -z "$BACKUP_ROOT" ]; then
|
if [ -z "$BACKUP_ROOT" ]; then
|
||||||
echo "Usage: $0 <backup_root> [--dry-run]"
|
echo "Usage: $0 <backup_root> [--cam CAM] [--season SEASON] [--mvt N] [--dry-run]"
|
||||||
echo " e.g. $0 ~/drives/data2-main --dry-run"
|
echo " e.g. $0 ~/drives/data2-main --cam north --season Autumn --mvt 1"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -46,6 +52,9 @@ music_base_dir="$MUSIC_DIR"
|
|||||||
$DRY_RUN && echo "DRY RUN — no files will be written"
|
$DRY_RUN && echo "DRY RUN — no files will be written"
|
||||||
echo "Scanning: $BACKUP_ROOT"
|
echo "Scanning: $BACKUP_ROOT"
|
||||||
echo "Output: $MOVIES_DIR"
|
echo "Output: $MOVIES_DIR"
|
||||||
|
[ -n "$FILTER_CAM" ] && echo "Filter: cam=$FILTER_CAM"
|
||||||
|
[ -n "$FILTER_SEASON" ] && echo "Filter: season=$FILTER_SEASON"
|
||||||
|
[ -n "$FILTER_MVT" ] && echo "Filter: mvt=$FILTER_MVT"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# Known camera names in order of specificity (longer matches first)
|
# Known camera names in order of specificity (longer matches first)
|
||||||
@@ -80,6 +89,7 @@ while IFS= read -r -d '' temp_file; do
|
|||||||
(( skipped++ )) || true
|
(( skipped++ )) || true
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
[ -n "$FILTER_CAM" ] && [ "$cam" != "$FILTER_CAM" ] && continue
|
||||||
|
|
||||||
_info="$(python3 "$SCRIPT_DIR/season_info.py" "$date_str" 2>/dev/null)" || {
|
_info="$(python3 "$SCRIPT_DIR/season_info.py" "$date_str" 2>/dev/null)" || {
|
||||||
echo "SKIP (season_info failed $date_str): $filename"
|
echo "SKIP (season_info failed $date_str): $filename"
|
||||||
@@ -87,6 +97,8 @@ while IFS= read -r -d '' temp_file; do
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
eval "$_info"
|
eval "$_info"
|
||||||
|
[ -n "$FILTER_SEASON" ] && [ "$SEASON" != "$FILTER_SEASON" ] && continue
|
||||||
|
[ -n "$FILTER_MVT" ] && [ "$MVT_NUM" != "$FILTER_MVT" ] && continue
|
||||||
|
|
||||||
music_file=$(find "$music_base_dir" -type f -iname "*${SEASON}*" \
|
music_file=$(find "$music_base_dir" -type f -iname "*${SEASON}*" \
|
||||||
| grep -iE "Mvt[^0-9]*${MVT_NUM}[^0-9]" | sort | head -n 1)
|
| grep -iE "Mvt[^0-9]*${MVT_NUM}[^0-9]" | sort | head -n 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user