diff --git a/stream-recorder.sh b/stream-recorder.sh index c7f6530..1ab7df8 100644 --- a/stream-recorder.sh +++ b/stream-recorder.sh @@ -8,9 +8,9 @@ # Web: https://www.cleveradmin.de # Repository: https://git.techniverse.net/scriptos/stream-recorder.git # License: MIT -# Version: v2.6.1 +# Version: v2.6.2 # Date: 06.09.2026 -# Modifications: Doppelte Benachrichtigung entfernt +# Modifications: Mehrtägige Aufnahmen nun möglich ############################################### set -uo pipefail @@ -211,6 +211,7 @@ parse_duration() { [[ "$input" =~ ^[0-9]+$ ]] && { echo "$input"; return; } local total=0 + [[ "$input" =~ ([0-9]+)d ]] && total=$((total + ${BASH_REMATCH[1]} * 86400)) [[ "$input" =~ ([0-9]+)h ]] && total=$((total + ${BASH_REMATCH[1]} * 3600)) [[ "$input" =~ ([0-9]+)m ]] && total=$((total + ${BASH_REMATCH[1]} * 60)) [[ "$input" =~ ([0-9]+)s ]] && total=$((total + ${BASH_REMATCH[1]})) @@ -714,7 +715,11 @@ run_scheduler() { fi else if is_recording "$job_id" && [[ -f "${PID_DIR}/${job_id}.scheduled" ]]; then - if [[ -n "${SCHEDULE_STOP:-}" ]] || ! $is_today; then + if [[ -n "${SCHEDULE_STOP:-}" ]]; then + log "INFO" "Scheduler: Stoppe '${STREAM_NAME}' [${job_id}]" + stop_recording "$job_id" + rm -f "${PID_DIR}/${job_id}.scheduled" + elif ! $is_today && [[ "${SCHEDULE_ONCE:-false}" != "true" ]]; then log "INFO" "Scheduler: Stoppe '${STREAM_NAME}' [${job_id}]" stop_recording "$job_id" rm -f "${PID_DIR}/${job_id}.scheduled" @@ -858,49 +863,25 @@ create_job() { echo "Kein Datum angegeben - Zeitplan deaktiviert." sched_enabled="false" else - echo "" - echo "Wie soll die Aufnahme begrenzt werden?" - echo " 1) Endzeit angeben (z.B. 18:30)" - echo " 2) Laufzeit angeben (z.B. 1h, 30m)" - echo " 3) Unbegrenzt (läuft bis manuell gestoppt)" - read -rp "Auswahl [1/2/3]: " limit_choice - case "$limit_choice" in - 1) - read -rp "Endzeit (HH:MM): " sched_stop - if [[ -n "$sched_stop" ]]; then - local start_min stop_min diff_min - start_min=$(_time_to_minutes "$sched_start") - stop_min=$(_time_to_minutes "$sched_stop") - diff_min=$(( stop_min - start_min )) - [[ $diff_min -le 0 ]] && diff_min=$(( diff_min + 1440 )) - duration=$(( diff_min * 60 )) - echo " -> Laufzeit automatisch berechnet: ${diff_min} Minuten" + read -rp "Laufzeit (z.B. 2h, 30m, 2d, 1d12h oder leer=unbegrenzt): " duration_input + if [[ -n "$duration_input" ]]; then + duration=$(parse_duration "$duration_input") + if [[ -n "$duration" && $duration -lt 86400 ]]; then + local start_min end_min end_h end_m + start_min=$(_time_to_minutes "$sched_start") + end_min=$(( start_min + duration / 60 )) + if [[ $end_min -lt 1440 ]]; then + end_h=$(( end_min / 60 )) + end_m=$(( end_min % 60 )) + sched_stop=$(printf "%02d:%02d" "$end_h" "$end_m") fi - ;; - 2) - read -rp "Laufzeit (z.B. 1h, 30m, 1h30m, 3600): " duration_input - if [[ -n "$duration_input" ]]; then - duration=$(parse_duration "$duration_input") - if [[ -n "$duration" ]]; then - local start_min end_min end_h end_m - start_min=$(_time_to_minutes "$sched_start") - end_min=$(( start_min + duration / 60 )) - [[ $end_min -ge 1440 ]] && end_min=$(( end_min - 1440 )) - end_h=$(( end_min / 60 )) - end_m=$(( end_min % 60 )) - sched_stop=$(printf "%02d:%02d" "$end_h" "$end_m") - echo " -> Endzeit automatisch berechnet: ${sched_stop}" - fi - fi - ;; - *) - ;; - esac + fi + fi fi fi if [[ "$sched_enabled" != "true" ]]; then - read -rp "Laufzeit (z.B. 1h, 30m, 3600 oder leer=unbegrenzt): " duration_input + read -rp "Laufzeit (z.B. 2h, 30m, 2d, 1d12h oder leer=unbegrenzt): " duration_input if [[ -n "$duration_input" ]]; then duration=$(parse_duration "$duration_input") fi @@ -943,8 +924,10 @@ create_job() { echo " Format: ${ext:-auto}" local duration_display="unbegrenzt" if [[ -n "$duration" ]]; then - local d_h=$((duration / 3600)) d_m=$(( (duration % 3600) / 60 )) - duration_display="${d_h}h ${d_m}m (${duration}s)" + local d_d=$((duration / 86400)) d_h=$(( (duration % 86400) / 3600 )) d_m=$(( (duration % 3600) / 60 )) + duration_display="" + [[ $d_d -gt 0 ]] && duration_display+="${d_d}d " + duration_display+="${d_h}h ${d_m}m" fi echo " Dauer: ${duration_display}" if [[ "$sched_enabled" == "true" ]]; then