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

aria2cexec=$pkgdatadir/../../bin/aria2c
ffmpegexec=$pkgdatadir/../../bin/ffmpeg
sevenzexec=$pkgdatadir/../../bin/7zz
denoexec=$pkgdatadir/../../bin/deno

if !(test -f $aria2cexec;) || !(test -f $ffmpegexec;) || !(test -f $sevenzexec;) || !(test -f $denoexec;)
then
	aria2cexec=$(which aria2c)
	ffmpegexec=$(which ffmpeg)
	sevenzexec=$(which 7z)
	denoexec=$(which deno)
	if !(test -f $aria2cexec;) || !(test -f $ffmpegexec;) || !(test -f $sevenzexec;) || !(test -f $denoexec;)
	then
		echo "aria2c and/or ffmpeg and/or 7z and/or deno not found. Exiting."
		exit
	fi
fi

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