Last active
October 27, 2019 12:03
-
-
Save pablokbs/c33f46cd1e8a6325453abb3f42ad5e3a to your computer and use it in GitHub Desktop.
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 | |
FILEBOT=/usr/bin/filebot | |
MEDIA=/home/media | |
MOVIES="$MEDIA/peliculas" | |
SERIES="$MEDIA/series" | |
MOVIES_FORMAT="movieFormat=$MOVIES/{n} ({y})/{n} ({y})" | |
SERIES_FORMAT="seriesFormat=$SERIES/{n}/{'Season '+s}/{n} - {s00e00}" | |
LOG_FILE=/var/log/filebot/filebot.log | |
LOG_FILE_SCRIPT=/var/log/filebot/filebot_script.log | |
i=1 | |
function filebot_copy { | |
echo "Empiezo a copiar, intento #$i" | |
$FILEBOT -script fn:amc \ | |
--output "$MEDIA" \ | |
--action copy \ | |
--conflict override \ | |
-non-strict "$1" \ | |
--log-file $LOG_FILE \ | |
--def "$MOVIES_FORMAT" "$SERIES_FORMAT" | |
echo "Ya copie, ahora hago el checkeo" | |
md5_check $1 | |
} | |
function md5_check { | |
MD5_INPUT=`md5sum $1 | awk '{print $1}'` | |
MD5_OUTPUT=`find $MOVIES $SERIES -mmin -3 \( -name "*.mp4" -o -name "*.mkv" -o -name "*.avi" \) -exec md5sum '{}' \; | awk '{print $1}' | tail -1` | |
if [ $MD5_INPUT == $MD5_OUTPUT ]; then | |
echo MD5_INPUT: $MD5_INPUT | |
echo MD5_OUTPUT: $MD5_OUTPUT | |
echo "Los hashes estan bien, salgo" | |
return 0 | |
else | |
echo "Los archivos estan mal, pruebo de nuevo" | |
let i=i+1 | |
if [ $i -lt 4 ]; then | |
echo "Intento $i" | |
filebot_copy $1 | |
else | |
echo "Falle $i veces, salgo :(" | |
return 1 | |
fi | |
fi | |
} | |
filebot_copy $1 | tee -a $LOG_FILE_SCRIPT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment