#!/bin/bash
pythonexec='/usr/bin/python3'
pkgdatadir='/usr/share/varia'

aria2cexec=$pkgdatadir/../../bin/aria2c
ffmpegexec=$pkgdatadir/../../bin/ffmpeg

if !(test -f $aria2cexec;) || !(test -f $ffmpegexec;)
then
	echo "Trying to find the system's aria2c and ffmpeg..."
	aria2cexec=$(which aria2c)
	ffmpegexec=$(which ffmpeg)
	if !(test -f $aria2cexec;) || !(test -f $ffmpegexec;)
	then
		echo "aria2c and/or ffmpeg not found. Exiting."
		exit
	fi
fi

if [ -z "$SNAP" ];
then
	$pythonexec $pkgdatadir/../../bin/varia-py.py "$aria2cexec" "$ffmpegexec" "NOSNAP" "$@"
else
	python3 $SNAP/usr/bin/varia-py.py "$aria2cexec" "$ffmpegexec" "$SNAP" "$@"
fi
