#!/bin/bash

running_check=`ps -aef | grep "python? [o]bplayer.py" | wc -l`

if [ "$running_check" -ge "1" ]
then
	echo OpenBroadcaster Player already running.
	exit;
fi

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR

if [ ! -x "/usr/bin/python3" ] || ! python3 -c "import apsw"
then
	#echo "Switching to legacy OpenBroadcaster Player"
	#git checkout legacy
        #if [ $? -ne 0 ]; then
        #    echo ""
        #    echo "ERROR: failed to switch to the legacy branch.  Python2 is no longer supported.  Please install the Python3 dependencies listed in dependencies.txt of the source file and retry, or check out the \"legacy\" branch from the git repository to continue using Python2"
        #    echo ""

        python2 obplayer.py $@
        #fi
else
        python3 obplayer.py $@
fi
