NextPVR Forums

Full Version: Auto delete old recordings
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've been using NextPVR for about 2 months after my MythTV setup got borked.  I've got two things working that took some figuring:

The first is a ParallelProcessing.sh file that deletes the oldest recordings to make room for new recordings.  It will delete the oldest files to make a certain amount of free space on starting a new recording:  

Code:
#!/bin/bash
cd /home/eriberg/TV &&
  find . -type f -printf '%T@ %b :%p\0' |
    sort -zrn |
    gawk -v RS='\0' -v ORS='\0' '
      BEGIN {max=400e9} # 10GiB; use max=10e9 for 10GB
      {du += 512 * $2}
      du > max {
        sub("[^:]*:", ""); print
      }' | xargs -r0 rm -f

It will delete files in folders, but not the folders, so I have my recordings in one folder.

The second is a script to run comskip when a recording is started.  I had trouble with comskip from /usr/local/bin or /usr/bin (compiled or from apt) randomly failing with a segmentation fault on my system, but comskip in a docker container worked.  This was written with the help of ChatGPT and watches the recordings folder and launches comskip in a docker container:

Code:
#!/bin/bash
# Define the input and output folders
INPUT_FOLDER="/home/eriberg/TV/NextPVR"
# Start monitoring the input folder for new files
inotifywait -m -e create "$INPUT_FOLDER" | while read path action file; do
  if [[ "$file" =~ .*\.ts$ ]]; then
    # Use Docker to run the Comskip container and process the new file
    sleep 60
    docker run -d -v "$INPUT_FOLDER:/data" -v "/etc:/data1" --rm comskip/comskip --ini=/data1/comskip.ini "/data/$file"
  fi
done
wait

With these two things I have NextPVR working perfectly as my server and Kodi as the frontend.  I hope this helps somebody and I appreciate the support forum's help in figuring these things out.

Erik