Skip to content

Commit

Permalink
Added environment variable used to configure a list of file extension…
Browse files Browse the repository at this point in the history
…s to be considered as non-video files.
  • Loading branch information
jlesage committed Dec 8, 2019
1 parent a39a0d6 commit d32cc96
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ of this parameter has the format `<VARIABLE_NAME>=<VALUE>`.
|`AUTOMATED_CONVERSION_FORMAT`| Video container format used by the automatic video converter for output files. This is typically the video filename extension. See the [Automatic Video Conversion](#automatic-video-conversion) section for more details. | `mp4` |
|`AUTOMATED_CONVERSION_KEEP_SOURCE`| When set to `0`, a video that has been successfully converted is removed from the watch folder. | `1` |
|`AUTOMATED_CONVERSION_NON_VIDEO_FILE_ACTION`| When set to `ignore`, a non-video file found in the watch folder is ignored. If set to `copy`, a non-video file is copied as-is to the output folder. | `ignore` |
|`AUTOMATED_CONVERSION_NON_VIDEO_FILE_EXTENSIONS`| Space-separated list of file extensions to be considered as not being videos. Most non-video files are properly rejected by HandBrake. However, some files, like images, are convertible by HandBrake even if they are not video files. | `jpg jpeg bmp png gif txt nfo` |
|`AUTOMATED_CONVERSION_OUTPUT_DIR`| Root directory where converted videos should be written. | `/output` |
|`AUTOMATED_CONVERSION_OUTPUT_SUBDIR`| Subdirectory of the output folder into which converted videos should be written. By default, this variable is not set, meaning that videos are saved directly into `/output/`. If `Home/Movies` is set, converted videos will be written to `/output/Home/Movies`. Use the special value `SAME_AS_SRC` to use the same subfolder as the source. For example, if the video source file is `/watch/Movies/mymovie.mkv`, the converted video will be written to `/output/Movies/`. | (unset) |
|`AUTOMATED_CONVERSION_SOURCE_STABLE_TIME`| Time (in seconds) during which properties (e.g. size, time, etc) of a video file in the watch folder need to remain the same. This is to avoid processing a file that is being copied. | `5` |
Expand Down
11 changes: 11 additions & 0 deletions appdefs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,17 @@ On systems running unRAID, the `--ulimit core=-1` parameter can be added to the
<mask>false</mask>
</unraid_template>
</environment_variable>
<environment_variable>
<name>AUTOMATED_CONVERSION_NON_VIDEO_FILE_EXTENSIONS</name>
<description>Space-separated list of file extensions to be considered as not being videos. Most non-video files are properly rejected by HandBrake. However, some files, like images, are convertible by HandBrake even if they are not video files.</description>
<default>jpg jpeg bmp png gif txt nfo</default>
<unraid_template>
<title>Automatic Video Converter: Non-Video File Extensions</title>
<display>advanced</display>
<required>false</required>
<mask>false</mask>
</unraid_template>
</environment_variable>
<environment_variable>
<name>AUTOMATED_CONVERSION_OUTPUT_DIR</name>
<description>Root directory where converted videos should be written.</description>
Expand Down
15 changes: 11 additions & 4 deletions rootfs/etc/services.d/autovideoconverter/run
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,14 @@ process_video() {
OUTPUT_DIR="$(echo "$OUTPUT_DIR" | sed 's|/\+|/|g' | sed 's|/\+$||')"

# Get video titles.
VIDEO_TITLES="$(get_video_titles "$video")"
VIDEO_TITLES_RETVAL=$?
if echo "$AC_NON_VIDEO_FILE_EXTENSIONS" | grep -iwq "${video##*.}"; then
log "File '${video}' (${hash}) has an extension part of the exclusion list."
VIDEO_TITLES=UNSET
VIDEO_TITLES_RETVAL=1
else
VIDEO_TITLES="$(get_video_titles "$video")"
VIDEO_TITLES_RETVAL=$?
fi
hb_rc=0

VIDEO_TITLES="${VIDEO_TITLES:-UNSET}"
Expand All @@ -180,7 +186,7 @@ process_video() {
log "File '${video}' (${hash}) was not a video, copying (unchanged) to output..."
cp -p "${video}" "${OUTPUT_DIR}/$(basename "${video}")" # "-p" maintains permissions, times etc...
elif [ "$VIDEO_TITLES_RETVAL" -gt 0 ]; then
log "File '$video' ($hash) was not a video, ignoring..."
log "File '$video' ($hash) is not a video, ignoring..."
elif [[ ${NUM_VIDEO_TITLES} -eq 0 ]]; then
log "ERROR: Could not identify titles in '${video}' (${hash})..."
hb_rc=1
Expand Down Expand Up @@ -365,10 +371,11 @@ while true; do
AC_OUTPUT_SUBDIR="${AUTOMATED_CONVERSION_OUTPUT_SUBDIR:-UNSET}"
AC_KEEP_SOURCE="${AUTOMATED_CONVERSION_KEEP_SOURCE:-1}"
AC_NON_VIDEO_FILE_ACTION="${AUTOMATED_CONVERSION_NON_VIDEO_FILE_ACTION:-ignore}"
AC_NON_VIDEO_FILE_EXTENSIONS="${AUTOMATED_CONVERSION_NON_VIDEO_FILE_EXTENSIONS:-jpg jpeg bmp png gif txt nfo}"

# Apply per-watch folder settings.
if [ -n "${DIR#*/watch}" ]; then
for VAR in PRESET FORMAT SOURCE_STABLE_TIME SOURCE_MIN_DURATION OUTPUT_DIR OUTPUT_SUBDIR KEEP_SOURCE NON_VIDEO_FILE_ACTION
for VAR in PRESET FORMAT SOURCE_STABLE_TIME SOURCE_MIN_DURATION OUTPUT_DIR OUTPUT_SUBDIR KEEP_SOURCE NON_VIDEO_FILE_ACTION NON_VIDEO_FILE_EXTENSIONS
do
eval "AC_$VAR=\"\${AUTOMATED_CONVERSION_${VAR}_${DIR#*/watch}:-\$AC_$VAR}\""
done
Expand Down

0 comments on commit d32cc96

Please sign in to comment.