#!/bin/sh

cd Movies
cd Games
cd Squaresoft
echo "Please pick a Title:"
ls | grep "" -n
read game
title=$(ls | grep "" -n | grep "^$game:" | cut -d ":" -f 2)
finaltitle="/home/michael/Movies/Games/Squaresoft/$title"
cd "$finaltitle"
echo "Please pick a Movie:"
ls *.avi *.mpg *.mov *.mpeg *.wmv | grep "" -n
read pickm
movie=$(ls *.avi *.mpg *.mov *.mpeg *.wmv | grep "" -n | grep "^$pickm:" | cut -d ":" -f 2)
finalmovie="$movie"
echo "Would you like subtitles?"
read subqa
if [ "$subqa" = "y" ]; then
	echo "Would you like to use the default subtitle if it exists?"
	read defaultsub
	if [ "$defaultsub" = "y" ]; then
		subqa="n"
	fi
	if [ "$defaultsub" = "n" ]; then
		echo "Please pick the Subtitle file to go with $movie:"
		ls *.srt | grep "" -n
		read pickm
		sub=$(ls *.srt | grep "" -n | grep "^$pickm:" | cut -d ":" -f 2)
	fi
fi
echo "Would you like fullscreen viewing?"
read fs
echo "How many times would you like to loop? (1 for no looping)"
read loop
if [ "$subqa" = "y" ]; then
	if [ "$fs" = "y" ]; then
		echo "mplayer '$finalmovie' -sub $sub -loop $loop -fs"
		mplayer "$finalmovie" -sub $sub -loop $loop -fs
		exit 0
	fi
	if [ "$fs" = "n" ]; then
		mplayer "$finalmovie" -sub $sub -loop $loop
		exit 0
	fi
fi
if [ "$subqa" = "n" ]; then
	if [ "$fs" = "y" ]; then
		mplayer "$finalmovie" -loop $loop -fs
		exit 0
	fi
	if [ "$fs" = "n" ]; then
		mplayer "$finalmovie" -loop $loop
		exit 0
	fi
fi
exit 0

