Jump to content

Command Crate ¿about?

Slice and rename podcast files for better compatibility (ffmpeg)

#!/bin/bash
PODCAST_DOWNLOAD_DIR="${HOME}/Ресурси/Преузимања/Podcasts"

if [ -e "$PODCAST_DOWNLOAD_DIR" ] && [ ! -z "$(command -v ffmpeg)" ]; then
  find "$PODCAST_DOWNLOAD_DIR" -type f -name '*.mp3' -execdir sh -c '
    PODCAST_FILE="$1"
    PODCAST_FILE_LENGHT_IN_SECONDS="1800"
    if [[ ! $PODCAST_FILE =~ ^[0-9]{2}- ]]; then
      random_filename_string=$(tr -dc "a-zA-Z0-9" < /dev/urandom | head -c 3)
      ffmpeg -i "$PODCAST_FILE" -c:a libmp3lame -q:a 6 -f segment -segment_time ${PODCAST_FILE_LENGHT_IN_SECONDS} -map 0:a -map_metadata -1 "${random_filename_string}-%02d-${PODCAST_FILE##*/}" && rm "$PODCAST_FILE"
    fi
  ' sh {} \;
fi

Verifies podcast directory and ffmpeg, slices long .mp3 files into 30-minute segments with random prefixes, renames them with 01-99 numbering, reduces file size, and removes originals

utilities [kb:210]