feat: added flag-overlay snippet

This commit is contained in:
darmiel 2023-03-16 15:41:54 +01:00
parent 779b22fc81
commit be54a8e929
No known key found for this signature in database
GPG key ID: 04090C1F8851CE39
2 changed files with 74 additions and 0 deletions

View file

@ -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/)]

View file

@ -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