summaryrefslogtreecommitdiff
path: root/play
blob: bbe85889dcebd18598ebeba4e96f2894f7ecbec4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash

# bash script to play files from a slow network ressource with the mpv
# caches the file in /tmp, after finishing it asks to move to the archiv
# export global variable $ANIMEARCHIV
# set the exit code right for quitting
# echo "q quit 255" >> ~/.mpv/input.conf

function remove(){
	if [ ! $2 ]; then
		read -p "Removing the origin? [Y/n] " verify
		if [ ! $verify ] || [ $verify = "ja" ] || [ $verify = "yes" ] || [ $verify = "j" ] || [ $verify = "y" ] || [ $verify = "Y" ]; then
			rm -v "$1"
		else
			echo "Okay, we don't remove $1. We are currently on $pwd."
		fi
	else
		rm -v "$1"
	fi
}

pwd=$(pwd)

cp "$@" /tmp &
echo -n "Preparing the awesomeness! Starting playback in.."
echo -n " 3"
sleep 1
echo -n " 2"
sleep 1
echo -n " 1"
sleep 1
echo " Start!"

mpv /tmp/"$@"
if [ $? -eq 0 ]; then
	if [ -d $ANIMEARCHIV ]; then
		echo "Finished $@ succesfull."
		read -p "Should we move to the Archiv? ($ANIMEARCHIV) [Y/n/rm/other] " verify
			if [ ! $verify ] || [ $verify = "ja" ] || [ $verify = "yes" ] || [ $verify = "j" ] || [ $verify = "y" ] || [ $verify = "Y" ]; then
				echo "Moving the stuff to $ANIMEARCHIV"
				mv /tmp/"$@" "$ANIMEARCHIV"
				remove "$@" "verify"
			elif [ $verify = "other" ] || [ $verify = "o" ] || [ $verify = "O" ] || [ $verify = "OTHER" ]; then
				read -p "Please tell us the absolute path: " path
				if [ -d $path ]; then
					echo "Moving to $path."
					mv /tmp/"$@" "$path"
					remove "$@"
				else
					echo "Sorry, \"$path\" doesn't exist."
					exit 1
				fi
			elif [ $verify = "r" ] || [ $verify = "rm" ] || [ $verify = "remove" ] || [ $verify = "RM" ] || [ $verify = "R" ]; then
				echo "Cleaning the mess up. Removing file from /tmp."
				rm -v /tmp/"$@"
			else
				echo "Okay, don't touching the files."		
			fi
	else
		echo "Can't move to \"$ANIMEARCHIV\". Directory doesn't exist."
		exit 1
	fi
else
	echo "Something is broken with the media player!"
	exit 1
fi

echo "Have a nice day!"