Created
July 7, 2023 21:09
-
-
Save davidpcrd/f8ab1560760683c2d4e43d93a8d568bc to your computer and use it in GitHub Desktop.
Extract "ass" sub from newly download on sonarr for plex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| if [ "$sonarr_eventtype" = "Test" ]; then | |
| exit 0 | |
| fi | |
| echo "" > "/volume1/homes/david/log.txt" | |
| echo "$sonarr_episodefile_path" >> "/volume1/homes/david/log.txt" | |
| json=$(/volume1/@appstore/ffmpeg6/bin/ffprobe -v quiet -print_format json -show_streams -select_streams s "$sonarr_episodefile_path") | |
| stream_count=$(echo "$json" | jq '.streams | length') | |
| directory=$(dirname "$sonarr_episodefile_path") | |
| filename=$(basename "$sonarr_episodefile_path") | |
| filename="${filename%.*}" | |
| echo "" >> "/volume1/homes/david/log.txt" | |
| echo "$sonarr_series_title" >> "/volume1/homes/david/log.txt" | |
| echo "$directory" >> "/volume1/homes/david/log.txt" | |
| for ((i=0; i<$stream_count; i++)); do | |
| index=$(echo "$json" | jq -r ".streams[$i].index") | |
| language=$(echo "$json" | jq -r ".streams[$i].tags.language") | |
| codec_name=$(echo "$json" | jq -r ".streams[$i].codec_name") | |
| forced=$(echo "$json" | jq -r ".streams[$i].disposition.forced") | |
| # Vérifier si "codec_name" n'est pas égal à "ass" | |
| if [ "$codec_name" != "ass" ]; then | |
| continue | |
| fi | |
| if [ "$forced" = "1" ]; then | |
| forced=".forced" | |
| else | |
| forced="" | |
| fi | |
| # Affichage des valeurs extraites | |
| echo "Index: $index" >> "/volume1/homes/david/log.txt" | |
| echo "Language: $language" >> "/volume1/homes/david/log.txt" | |
| echo "Codec Name: $codec_name" >> "/volume1/homes/david/log.txt" | |
| echo "Forced : $forced" >> "/volume1/homes/david/log.txt" | |
| echo "---" >> "/volume1/homes/david/log.txt" | |
| ffmpeg -y -v quiet -i "$sonarr_episodefile_path" -map "0:$index" "$directory/$filename.$language$forced.srt" | |
| echo "$directory/$filename.$language$forced.srt" >> "/volume1/homes/david/log.txt" | |
| done | |
| echo "" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment