Skip to content

Instantly share code, notes, and snippets.

@sanchon
Last active March 18, 2016 01:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sanchon/6980496 to your computer and use it in GitHub Desktop.
Save sanchon/6980496 to your computer and use it in GitHub Desktop.
Script para subtitular y clasificar las series
#!/bin/bash
RUTA_FINISHED="/mnt/discoInterno2/downloads/torrents-finished"
RUTA_WITHSUBS="/mnt/discoInterno2/downloads/torrents-withsubs"
# --------------------------------------------------------------------------------
# 1.- Sacamos los ficheros de video de sus posibles subdirectorios
# --------------------------------------------------------------------------------
# primero movemos los ficheros de sus subdirectorios a la RUTA_FINISHED
echo
echo extrayendo...
find $RUTA_FINISHED -mindepth 2 \( -name "*.mp4" -o -name "*.mkv" -o -name "*.avi" -o -name ".3gp" \) -exec mv "{}" $RUTA_FINISHED/ \; -exec echo moviendo {} \;
# luego borramos todos los subdirectorios
echo
echo eliminando directorios...
find $RUTA_FINISHED -mindepth 1 -type d -exec rm -rf '{}' \; -exec echo eliminando {} \;
# y los samples...
find $RUTA_FINISHED -mindepth 1 -type f -name "*sample*" -exec rm -rf '{}' \; -exec echo eliminando {} \;
# --------------------------------------------------------------------------------
# 2.- Le buscamos los subtitulos a las series en ingles, con el subliminal
# --------------------------------------------------------------------------------
echo
echo descargando subtitulos...
/usr/local/bin/subliminal -s -l en -- $RUTA_FINISHED/
# --------------------------------------------------------------------------------
# 3.- Movemos a "torrents-withsubs" los videos que tengan subtitulos
# --------------------------------------------------------------------------------
echo
echo moviendo series con subtitulos...
for file in $(find $RUTA_FINISHED -mindepth 1 -type f); do
if [ -f ${file%.*}.srt ];
then
mv ${file%.*}.* $RUTA_WITHSUBS
echo
echo "Movido: "${file%.*}
fi
done
# ------------------------------------------------------
# algunas series no tienen subtitulos, los movemos igual
# ------------------------------------------------------
echo
echo moviendo series sin subtitulos...
find $RUTA_FINISHED -mindepth 1 -type f -iname "wheeler*dealers*" -exec mv "{}" $RUTA_WITHSUBS \; -exec echo moviendo {} \;
# --------------------------------------------------------------------------------
# 4.- Movemos todo lo que haya terminado del amule
# --------------------------------------------------------------------------------
#mv /mnt/discoInterno2/downloads/emule-incoming/* /mnt/discoInterno2/del_emule
# --------------------------------------------------------------------------------
# 5.- Forzamos un refresco del sickbeard (para mover todo a su sitio)
# --------------------------------------------------------------------------------
echo
echo refrescando sickbeard...
curl -s http://localhost:8081/home/postprocess/processEpisode --form "dir=$RUTA_WITHSUBS" | grep "Processing folder"
# --------------------------------------------------------------------------------
# 6.- Forzamos un refresco del Plex
# --------------------------------------------------------------------------------
echo
echo refrescando plex...
curl http://localhost:32400/library/sections/1/refresh
curl http://localhost:32400/library/sections/2/refresh
curl http://localhost:32400/library/sections/3/refresh
curl http://localhost:32400/library/sections/4/refresh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment