diff --git a/snippets/language-overlay/README.md b/snippets/language-overlay/README.md new file mode 100644 index 0000000..a7b1503 --- /dev/null +++ b/snippets/language-overlay/README.md @@ -0,0 +1,24 @@ +# Flags on Movie Posters + +Ever wanted to easily identify the language of a movie at a glance? Now you can with this script! + +This script adds flags to movie posters, so that you can quickly determine the language of the movie. Currently, it supports German and Dutch flags, but can easily be modified to support any language. + +## Requirements + +* `exiftool` +* `jq` +* FFmpeg (for `ffprobe`) +* imagemagick (for `convert`) + +## Usage + +1. Save the script to a file, e.g. `movie_flags.sh` +2. Change the `MOVIES_DIR` and `OVERLAY_DIR` variables and modify to your desired languages +3. Change the file permissions to make it executable, e.g. `chmod +x movie_flags.sh` +4. Run the script, e.g. `./movie_flags.sh` + +## Credits + +This script was created by [u/ProductRockstar](https://www.reddit.com/user/ProductRockstar/). +[[Original Post](https://www.reddit.com/r/jellyfin/comments/11dgmp3/script_to_add_language_overlay_to_movie_poster/)] diff --git a/snippets/language-overlay/language-overlay.sh b/snippets/language-overlay/language-overlay.sh new file mode 100644 index 0000000..2f1d69e --- /dev/null +++ b/snippets/language-overlay/language-overlay.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# Author: u/ProductRockstar +# https://www.reddit.com/r/jellyfin/comments/11dgmp3/script_to_add_language_overlay_to_movie_poster/ + +MOVIES_DIR="/mnt_data/media/movies" +OVERLAY_DIR="/mnt_data/media" + +while true +do + cd "$MOVIES_DIR" + for dir in */; do + cd "$MOVIES_DIR/$dir" + pwd + + flink=$(readlink -f poster.jpg) + creatortool=$( exiftool -f -s3 -"creatortool" "$flink" ) + + if [ "${creatortool}" != "993" ]; then + mlink=$(readlink -f *.mkv) + langs=$( ffprobe "$mlink" -show_entries stream=index:stream_tags=language -select_streams a -v 0 -of json=c=1 | jq --raw-output '.streams[].tags.language') + + GER='ger' + DUT='dut' + + case $langs in + + *"$DUT"*) + widthposter=$( exiftool -f -s3 -"ImageWidth" "$flink" ) + convert "$OVERLAY_DIR/dut_overlay.png" -resize "$widthposter" "$OVERLAY_DIR/dut_overlay_tmp.png" + convert "$flink" "$OVERLAY_DIR/dut_overlay_tmp.png" -flatten "$flink" + chmod +644 "$flink" + chown nobody "$flink" + exiftool -creatortool="993" -overwrite_original "$flink" + ;; + + *"$GER"*) + widthposter=$( exiftool -f -s3 -"ImageWidth" "$flink" ) + convert "$OVERLAY_DIR/ger_overlay.png" -resize "$widthposter" "$OVERLAY_DIR/ger_overlay_tmp.png" + convert "$flink" "$OVERLAY_DIR/ger_overlay_tmp.png" -flatten "$flink" + chmod +644 "$flink" + chown nobody "$flink" + exiftool -creatortool="993" -overwrite_original "$flink" + ;; + esac + + fi + done + sleep 90000 +done