[GUIDE] Fully Automated Media Center with pyLoad

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
Gutz-Pilz
Power User
Posts: 17
Joined: 29 Aug 2013, 16:03

[GUIDE] Fully Automated Media Center with pyLoad

Post by Gutz-Pilz »

just activate "externalscript" plugin and create a bash file in /pyLoad/scripts/unrar_finished

use this script and edit the Global variables

Code: Select all

#!/bin/bash

# Globale Variablen #
DATE=$(date +%d.%m.%Y\ %H:%M:%S)
BaseDir=/media/5a24e136-09b9-48e1-95db-b44d5db3e28a
DownloadDir=${BaseDir}/Medien/Downloads
MediaDir=${BaseDir}/Medien
LogFile=$BaseDir/Scripts/filebot_manuell.log

#Pyload
DownloadFolder=$DownloadDir
SERVICE=filebot

#FileBot-defs
MovieFormat="movieFormat=Movies/{net.sourceforge.filebot.WebServices.TMDb.getMovieInfo(movie, Locale.GERMAN).name} {'('+y+')'}/{net.sourceforge.filebot.WebServices.TMDb.getMovieInfo(movie, Locale.GERMAN).name} {'('+y+')'}"
Ignore="ignore=\b(?i:doku)\b"
Execute="exec=sh $ExtScript \"{file}\""
Extras="clean=y artwork=y subtitles=de"

# check if we are the only local instance
if [[ "`pidof -x $(basename $0) -o %PPID`" ]]; then
        echo  -e "$DATE: \tDas Script wird schon ausgeführt als PID `pidof -x $(basename $0) -o %PPID`" | tee -a $LogFile
        exit
fi

if ps ax | grep -v grep | grep -v $0 | grep $SERVICE > /dev/null
then
	echo -e "$DATE: \t$SERVICE laeuft schon - lass es sein!" | tee -a $LogFile
else
	sleep 5
        echo -e "$DATE: \t$SERVICE laeuft nicht" | tee -a $LogFile
	cd "$DownloadFolder"
	count=`ls -1 *.rar 2>/dev/null | wc -l`
	
	if [ $count != 0 ]
	then
		echo -e "$DATE: \tHier sind noch Archive... abbruch!" | tee -a $LogFile
	else
		echo -e "$DATE: \tkeine rar-Dateien in $1 zu finden - es kann los gehen!" | tee -a $LogFile
		# Funktionen #
		sortiere(){
		filebot -script fn:amc "$DownloadFolder" --output "$MediaDir" --conflict override -non-strict --action move --def "$MovieFormat" "$Ignore" $Extras
		}
		cleaning(){
		filebot -script fn:cleaner "$DownloadFolder" --def root=y "$Ignore" "exts=jpg|nfo|rar|etc" "terms=sample|trailer|etc"
		}
		# Ausfuehren #
		echo -e "$DATE: \tFilebot ausfuehren" | tee -a $LogFile
		sortiere
		exit
	fi
fi
Post Reply